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.
Files changed (2) hide show
  1. package/create.js +13 -2
  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
- ...(opts.runtime !== 'automatic' ? { useBuiltIns: true } : {}),
98
- runtime: opts.runtime || 'classic'
108
+ ...(reactRuntime !== 'automatic' ? { useBuiltIns: true } : {}),
109
+ runtime: reactRuntime
99
110
  }
100
111
  ],
101
112
  isTypeScriptEnabled && [require('@babel/preset-typescript').default]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-react-app-new",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Babel preset used by Create React App",
5
5
  "repository": {
6
6
  "type": "git",