Skip to content

Commit 44a7c21

Browse files
author
Morten N.O. Henriksen
committed
Fix swc browserlists support
1 parent 8e1d6fa commit 44a7c21

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

packages/react-scripts/config/createSwcConfig.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ const hasJsxRuntime = require('./hasJsxRuntime');
1212
module.exports = function createSwcConfig({
1313
shouldUseSourceMap = true,
1414
isEnvDevelopment = false,
15+
isEnvProduction = false,
1516
shouldUseReactRefresh = false,
1617
} = {}) {
18+
const env =
19+
isEnvDevelopment | isEnvProduction
20+
? {
21+
mode: 'entry',
22+
coreJs: 3,
23+
}
24+
: {};
1725
return {
1826
ecmascript: {
1927
sourceMaps: shouldUseSourceMap,
@@ -31,6 +39,7 @@ module.exports = function createSwcConfig({
3139
},
3240
},
3341
},
42+
env,
3443
},
3544
typescript: {
3645
sourceMaps: shouldUseSourceMap,
@@ -45,9 +54,11 @@ module.exports = function createSwcConfig({
4554
react: {
4655
runtime: hasJsxRuntime ? 'automatic' : 'clasic',
4756
refresh: shouldUseReactRefresh,
57+
development: isEnvDevelopment,
4858
},
4959
},
5060
},
5161
},
62+
env,
5263
};
5364
};

packages/react-scripts/config/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ module.exports = function (webpackEnv) {
9090
const swcConfig = createSwcConfig({
9191
shouldUseSourceMap,
9292
isEnvDevelopment,
93+
isEnvProduction,
9394
shouldUseReactRefresh,
9495
});
9596

packages/react-scripts/scripts/utils/createJestConfig.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const modules = require('../../config/modules');
1414
const createSwcConfig = require('../../config/createSwcConfig');
1515
const swcConfig = createSwcConfig({
1616
shouldUseSourceMap: true,
17-
isEnvDevelopment: true,
1817
});
1918

2019
module.exports = (resolve, rootDir, isEjecting) => {

0 commit comments

Comments
 (0)