babel-preset-react-app-new 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/create.js +13 -2
- package/package.json +1 -1
package/create.js
CHANGED
|
@@ -20,6 +20,15 @@ const validateBoolOption = (name, value, defaultValue) => {
|
|
|
20
20
|
return value;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
const hasJsxRuntime = (() => {
|
|
24
|
+
try {
|
|
25
|
+
require.resolve('react/jsx-runtime');
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
|
+
|
|
23
32
|
module.exports = function (api, opts, env) {
|
|
24
33
|
if (!opts) {
|
|
25
34
|
opts = {};
|
|
@@ -39,6 +48,8 @@ module.exports = function (api, opts, env) {
|
|
|
39
48
|
absoluteRuntimePath = path.dirname(require.resolve('@babel/runtime/package.json'));
|
|
40
49
|
}
|
|
41
50
|
|
|
51
|
+
var reactRuntime = opts.runtime || (hasJsxRuntime ? 'automatic' : 'classic');
|
|
52
|
+
|
|
42
53
|
var corejsVerson = '3.31';
|
|
43
54
|
|
|
44
55
|
try {
|
|
@@ -94,8 +105,8 @@ module.exports = function (api, opts, env) {
|
|
|
94
105
|
development: isEnvDevelopment || isEnvTest,
|
|
95
106
|
// Will use the native built-in instead of trying to polyfill
|
|
96
107
|
// behavior for any plugins that require one.
|
|
97
|
-
...(
|
|
98
|
-
runtime:
|
|
108
|
+
...(reactRuntime !== 'automatic' ? { useBuiltIns: true } : {}),
|
|
109
|
+
runtime: reactRuntime
|
|
99
110
|
}
|
|
100
111
|
],
|
|
101
112
|
isTypeScriptEnabled && [require('@babel/preset-typescript').default]
|