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

@ -0,0 +1,35 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {RuleSetRule} from 'webpack';
export function getSwcJsLoaderFactory({
isServer,
}: {
isServer: boolean;
}): RuleSetRule {
return {
loader: require.resolve('swc-loader'),
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
target: 'es2017',
},
module: {
type: isServer ? 'commonjs' : 'es6',
},
},
};
}