feat(core): faster transpiler option - siteConfig.future.experimental_faster.swcJsLoader (#10435)

This commit is contained in:
Sébastien Lorber 2024-08-23 13:48:52 +02:00 committed by GitHub
parent 349a58453a
commit 418247ec87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 1298 additions and 847 deletions

View file

@ -53,7 +53,7 @@ async function createVersionedSidebarFile({
}
// Tests depend on non-default export for mocking.
export async function cliDocsVersionCommand(
async function cliDocsVersionCommand(
version: unknown,
{id: pluginId, path: docsPath, sidebarPath}: PluginOptions,
{siteDir, i18n}: LoadContext,
@ -142,3 +142,17 @@ export async function cliDocsVersionCommand(
logger.success`name=${pluginIdLogPrefix}: version name=${version} created!`;
}
// TODO try to remove this workaround
// Why use a default export instead of named exports here?
// This is only to make Jest mocking happy
// After upgrading Jest/SWC we got this weird mocking error in extendCli tests
// "spyOn: Cannot redefine property cliDocsVersionCommand"
// I tried various workarounds, and it's the only one that worked :/
// See also:
// - https://pyk.sh/fixing-typeerror-cannot-redefine-property-x-error-in-jest-tests#heading-solution-2-using-barrel-imports
// - https://github.com/aelbore/esbuild-jest/issues/26
// - https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property/69951703#69951703
export default {
cliDocsVersionCommand,
};