babel-preset-react-app-new 0.0.1 → 0.0.3

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/README.md CHANGED
@@ -16,17 +16,17 @@ If you want to use this Babel preset in a project not built with Create React Ap
16
16
 
17
17
  First, [install Babel](https://babeljs.io/docs/setup/).
18
18
 
19
- Then install babel-preset-react-app.
19
+ Then install babel-preset-react-app-new.
20
20
 
21
21
  ```sh
22
- npm install babel-preset-react-app --save-dev
22
+ npm install babel-preset-react-app-new --save-dev
23
23
  ```
24
24
 
25
25
  Then create a file named `.babelrc` with following contents in the root folder of your project:
26
26
 
27
27
  ```json
28
28
  {
29
- "presets": ["react-app"]
29
+ "presets": ["react-app-new"]
30
30
  }
31
31
  ```
32
32
 
@@ -38,7 +38,7 @@ Make sure you have a `.flowconfig` file at the root directory. You can also use
38
38
 
39
39
  ```json
40
40
  {
41
- "presets": [["react-app", { "flow": true, "typescript": false }]]
41
+ "presets": [["react-app-new", { "flow": true, "typescript": false }]]
42
42
  }
43
43
  ```
44
44
 
@@ -48,7 +48,7 @@ Make sure you have a `tsconfig.json` file at the root directory. You can also us
48
48
 
49
49
  ```json
50
50
  {
51
- "presets": [["react-app", { "flow": false, "typescript": true }]]
51
+ "presets": [["react-app-new", { "flow": false, "typescript": true }]]
52
52
  }
53
53
  ```
54
54
 
@@ -58,6 +58,6 @@ Absolute paths are enabled by default for imports. To use relative paths instead
58
58
 
59
59
  ```
60
60
  {
61
- "presets": [["react-app", { "absoluteRuntime": false }]]
61
+ "presets": [["react-app-new", { "absoluteRuntime": false }]]
62
62
  }
63
63
  ```
package/create.js CHANGED
@@ -14,7 +14,7 @@ const validateBoolOption = (name, value, defaultValue) => {
14
14
  }
15
15
 
16
16
  if (typeof value !== 'boolean') {
17
- throw new Error(`Preset react-app: '${name}' option must be a boolean.`);
17
+ throw new Error(`Preset react-app-new: '${name}' option must be a boolean.`);
18
18
  }
19
19
 
20
20
  return value;
@@ -40,7 +40,7 @@ module.exports = function (api, opts, env) {
40
40
  absoluteRuntimePath = path.dirname(require.resolve('@babel/runtime/package.json'));
41
41
  }
42
42
 
43
- var corejsVerson = '3.30';
43
+ var corejsVerson = '3.31';
44
44
 
45
45
  try {
46
46
  corejsVerson = require('core-js/package.json').version;
@@ -48,7 +48,7 @@ module.exports = function (api, opts, env) {
48
48
 
49
49
  if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
50
50
  throw new Error(
51
- 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
51
+ 'Using `babel-preset-react-app-new` requires that you specify `NODE_ENV` or ' +
52
52
  '`BABEL_ENV` environment variables. Valid values are "development", ' +
53
53
  '"test", and "production". Instead, received: ' +
54
54
  JSON.stringify(env) +
package/dependencies.js CHANGED
@@ -9,135 +9,138 @@
9
9
  const path = require('path');
10
10
 
11
11
  const validateBoolOption = (name, value, defaultValue) => {
12
- if (typeof value === 'undefined') {
13
- value = defaultValue;
14
- }
12
+ if (typeof value === 'undefined') {
13
+ value = defaultValue;
14
+ }
15
15
 
16
- if (typeof value !== 'boolean') {
17
- throw new Error(`Preset react-app: '${name}' option must be a boolean.`);
18
- }
16
+ if (typeof value !== 'boolean') {
17
+ throw new Error(`Preset react-app-new: '${name}' option must be a boolean.`);
18
+ }
19
19
 
20
- return value;
20
+ return value;
21
21
  };
22
22
 
23
23
  module.exports = function (api, opts) {
24
- if (!opts) {
25
- opts = {};
26
- }
24
+ if (!opts) {
25
+ opts = {};
26
+ }
27
27
 
28
- // This is similar to how `env` works in Babel:
29
- // https://babeljs.io/docs/usage/babelrc/#env-option
30
- // We are not using `env` because it’s ignored in versions > babel-core@6.10.4:
31
- // https://github.com/babel/babel/issues/4539
32
- // https://github.com/facebook/create-react-app/issues/720
33
- // It’s also nice that we can enforce `NODE_ENV` being specified.
34
- var env = process.env.BABEL_ENV || process.env.NODE_ENV;
35
- var isEnvDevelopment = env === 'development';
36
- var isEnvProduction = env === 'production';
37
- var isEnvTest = env === 'test';
28
+ // This is similar to how `env` works in Babel:
29
+ // https://babeljs.io/docs/usage/babelrc/#env-option
30
+ // We are not using `env` because it’s ignored in versions > babel-core@6.10.4:
31
+ // https://github.com/babel/babel/issues/4539
32
+ // https://github.com/facebook/create-react-app/issues/720
33
+ // It’s also nice that we can enforce `NODE_ENV` being specified.
34
+ var env = process.env.BABEL_ENV || process.env.NODE_ENV;
35
+ var isEnvDevelopment = env === 'development';
36
+ var isEnvProduction = env === 'production';
37
+ var isEnvTest = env === 'test';
38
38
 
39
- var areHelpersEnabled = validateBoolOption('helpers', opts.helpers, false);
40
- var useAbsoluteRuntime = validateBoolOption(
41
- 'absoluteRuntime',
42
- opts.absoluteRuntime,
43
- true
44
- );
39
+ var areHelpersEnabled = validateBoolOption('helpers', opts.helpers, false);
40
+ var useAbsoluteRuntime = validateBoolOption('absoluteRuntime', opts.absoluteRuntime, true);
45
41
 
46
- var absoluteRuntimePath = undefined;
47
- if (useAbsoluteRuntime) {
48
- absoluteRuntimePath = path.dirname(
49
- require.resolve('@babel/runtime/package.json')
50
- );
51
- }
42
+ var absoluteRuntimePath = undefined;
43
+ if (useAbsoluteRuntime) {
44
+ absoluteRuntimePath = path.dirname(require.resolve('@babel/runtime/package.json'));
45
+ }
52
46
 
53
- if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
54
- throw new Error(
55
- 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
56
- '`BABEL_ENV` environment variables. Valid values are "development", ' +
57
- '"test", and "production". Instead, received: ' +
58
- JSON.stringify(env) +
59
- '.'
60
- );
61
- }
47
+ var corejsVerson = '3.30';
62
48
 
63
- return {
64
- // Babel assumes ES Modules, which isn't safe until CommonJS
65
- // dies. This changes the behavior to assume CommonJS unless
66
- // an `import` or `export` is present in the file.
67
- // https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
68
- sourceType: 'unambiguous',
69
- presets: [
70
- isEnvTest && [
71
- // ES features necessary for user's Node version
72
- require('@babel/preset-env').default,
73
- {
74
- targets: {
75
- node: 'current',
76
- },
77
- // Exclude transforms that make all code slower
78
- exclude: ['transform-typeof-symbol'],
79
- },
80
- ],
81
- (isEnvProduction || isEnvDevelopment) && [
82
- // Latest stable ECMAScript features
83
- require('@babel/preset-env').default,
84
- {
85
- // Allow importing core-js in entrypoint and use browserlist to select polyfills
86
- useBuiltIns: 'entry',
87
- // Set the corejs version we are using to avoid warnings in console
88
- // This will need to change once we upgrade to corejs@3
89
- corejs: 3,
90
- // Exclude transforms that make all code slower
91
- exclude: ['transform-typeof-symbol'],
92
- },
93
- ],
94
- ].filter(Boolean),
95
- plugins: [
96
- // Disabled as it's handled automatically by preset-env, and `selectiveLoose` isn't
97
- // yet merged into babel: https://github.com/babel/babel/pull/9486
98
- // Related: https://github.com/facebook/create-react-app/pull/8215
99
- // [
100
- // require('@babel/plugin-transform-destructuring').default,
101
- // {
102
- // // Use loose mode for performance:
103
- // // https://github.com/facebook/create-react-app/issues/5602
104
- // loose: false,
105
- // selectiveLoose: [
106
- // 'useState',
107
- // 'useEffect',
108
- // 'useContext',
109
- // 'useReducer',
110
- // 'useCallback',
111
- // 'useMemo',
112
- // 'useRef',
113
- // 'useImperativeHandle',
114
- // 'useLayoutEffect',
115
- // 'useDebugValue',
116
- // ],
117
- // },
118
- // ],
119
- // Polyfills the runtime needed for async/await, generators, and friends
120
- // https://babeljs.io/docs/en/babel-plugin-transform-runtime
121
- [
122
- require('@babel/plugin-transform-runtime').default,
123
- {
124
- corejs: false,
125
- helpers: areHelpersEnabled,
126
- // By default, babel assumes babel/runtime version 7.0.0-beta.0,
127
- // explicitly resolving to match the provided helper functions.
128
- // https://github.com/babel/babel/issues/10261
129
- version: require('@babel/runtime/package.json').version,
130
- regenerator: true,
131
- // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
132
- // We should turn this on once the lowest version of Node LTS
133
- // supports ES Modules.
134
- useESModules: isEnvDevelopment || isEnvProduction,
135
- // Undocumented option that lets us encapsulate our runtime, ensuring
136
- // the correct version is used
137
- // https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
138
- absoluteRuntime: absoluteRuntimePath,
139
- },
140
- ],
141
- ].filter(Boolean),
142
- };
49
+ try {
50
+ corejsVerson = require('core-js/package.json').version;
51
+ } catch (err) {}
52
+
53
+ if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
54
+ throw new Error(
55
+ 'Using `babel-preset-react-app-new` requires that you specify `NODE_ENV` or ' +
56
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
57
+ '"test", and "production". Instead, received: ' +
58
+ JSON.stringify(env) +
59
+ '.'
60
+ );
61
+ }
62
+
63
+ return {
64
+ // Babel assumes ES Modules, which isn't safe until CommonJS
65
+ // dies. This changes the behavior to assume CommonJS unless
66
+ // an `import` or `export` is present in the file.
67
+ // https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
68
+ sourceType: 'unambiguous',
69
+ presets: [
70
+ isEnvTest && [
71
+ // ES features necessary for user's Node version
72
+ require('@babel/preset-env').default,
73
+ {
74
+ targets: {
75
+ node: 'current'
76
+ },
77
+ // Exclude transforms that make all code slower
78
+ exclude: ['transform-typeof-symbol']
79
+ }
80
+ ],
81
+ (isEnvProduction || isEnvDevelopment) && [
82
+ // Latest stable ECMAScript features
83
+ require('@babel/preset-env').default,
84
+ Object.assign(
85
+ {
86
+ // Allow importing core-js in entrypoint and use browserlist to select polyfills
87
+ useBuiltIns: 'entry',
88
+ // Set the corejs version we are using to avoid warnings in console
89
+ // This will need to change once we upgrade to corejs@3
90
+ corejs: corejsVerson,
91
+ // Exclude transforms that make all code slower
92
+ exclude: ['transform-typeof-symbol']
93
+ },
94
+ opts.presetEnvOptions
95
+ )
96
+ ]
97
+ ].filter(Boolean),
98
+ plugins: [
99
+ // Disabled as it's handled automatically by preset-env, and `selectiveLoose` isn't
100
+ // yet merged into babel: https://github.com/babel/babel/pull/9486
101
+ // Related: https://github.com/facebook/create-react-app/pull/8215
102
+ // [
103
+ // require('@babel/plugin-transform-destructuring').default,
104
+ // {
105
+ // // Use loose mode for performance:
106
+ // // https://github.com/facebook/create-react-app/issues/5602
107
+ // loose: false,
108
+ // selectiveLoose: [
109
+ // 'useState',
110
+ // 'useEffect',
111
+ // 'useContext',
112
+ // 'useReducer',
113
+ // 'useCallback',
114
+ // 'useMemo',
115
+ // 'useRef',
116
+ // 'useImperativeHandle',
117
+ // 'useLayoutEffect',
118
+ // 'useDebugValue',
119
+ // ],
120
+ // },
121
+ // ],
122
+ // Polyfills the runtime needed for async/await, generators, and friends
123
+ // https://babeljs.io/docs/en/babel-plugin-transform-runtime
124
+ [
125
+ require('@babel/plugin-transform-runtime').default,
126
+ {
127
+ corejs: false,
128
+ helpers: areHelpersEnabled,
129
+ // By default, babel assumes babel/runtime version 7.0.0-beta.0,
130
+ // explicitly resolving to match the provided helper functions.
131
+ // https://github.com/babel/babel/issues/10261
132
+ version: require('@babel/runtime/package.json').version,
133
+ regenerator: true,
134
+ // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
135
+ // We should turn this on once the lowest version of Node LTS
136
+ // supports ES Modules.
137
+ useESModules: isEnvDevelopment || isEnvProduction,
138
+ // Undocumented option that lets us encapsulate our runtime, ensuring
139
+ // the correct version is used
140
+ // https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
141
+ absoluteRuntime: absoluteRuntimePath
142
+ }
143
+ ]
144
+ ].filter(Boolean)
145
+ };
143
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-react-app-new",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Babel preset used by Create React App",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,20 +21,21 @@
21
21
  "test.js"
22
22
  ],
23
23
  "dependencies": {
24
- "@babel/core": "^7.16.0",
25
- "@babel/plugin-proposal-class-properties": "^7.16.0",
26
- "@babel/plugin-proposal-decorators": "^7.16.4",
27
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
28
- "@babel/plugin-proposal-numeric-separator": "^7.16.0",
29
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
30
- "@babel/plugin-proposal-private-methods": "^7.16.0",
31
- "@babel/plugin-transform-flow-strip-types": "^7.16.0",
32
- "@babel/plugin-transform-react-display-name": "^7.16.0",
33
- "@babel/plugin-transform-runtime": "^7.16.4",
34
- "@babel/preset-env": "^7.16.4",
35
- "@babel/preset-react": "^7.16.0",
36
- "@babel/preset-typescript": "^7.16.0",
37
- "@babel/runtime": "^7.16.3",
24
+ "@babel/core": "^7.22.9",
25
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
26
+ "@babel/plugin-proposal-decorators": "^7.22.7",
27
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
28
+ "@babel/plugin-proposal-numeric-separator": "^7.18.6",
29
+ "@babel/plugin-proposal-optional-chaining": "^7.21.0",
30
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
31
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
32
+ "@babel/plugin-transform-flow-strip-types": "^7.22.5",
33
+ "@babel/plugin-transform-react-display-name": "^7.22.5",
34
+ "@babel/plugin-transform-runtime": "^7.22.9",
35
+ "@babel/preset-env": "^7.22.9",
36
+ "@babel/preset-react": "^7.22.5",
37
+ "@babel/preset-typescript": "^7.22.5",
38
+ "@babel/runtime": "^7.22.6",
38
39
  "babel-plugin-macros": "^3.1.0",
39
40
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24"
40
41
  }