babel-preset-react-app 6.1.0 → 7.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/README.md +8 -8
- package/create.js +16 -2
- package/package.json +17 -17
package/README.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
This package includes the Babel preset used by [Create React App](https://github.com/facebook/create-react-app).<br>
|
4
4
|
Please refer to its documentation:
|
5
5
|
|
6
|
-
- [Getting Started](https://github.
|
7
|
-
- [User Guide](https://github.
|
6
|
+
- [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
|
7
|
+
- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.
|
8
8
|
|
9
9
|
## Usage in Create React App Projects
|
10
10
|
|
@@ -12,7 +12,7 @@ The easiest way to use this configuration is with [Create React App](https://git
|
|
12
12
|
|
13
13
|
## Usage Outside of Create React App
|
14
14
|
|
15
|
-
If you want to use this Babel preset in a project not built with Create React App, you can install it with following steps.
|
15
|
+
If you want to use this Babel preset in a project not built with Create React App, you can install it with the following steps.
|
16
16
|
|
17
17
|
First, [install Babel](https://babeljs.io/docs/setup/).
|
18
18
|
|
@@ -24,7 +24,7 @@ npm install babel-preset-react-app --save-dev
|
|
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
29
|
"presets": ["react-app"]
|
30
30
|
}
|
@@ -34,9 +34,9 @@ This preset uses the `useBuiltIns` option with [transform-object-rest-spread](ht
|
|
34
34
|
|
35
35
|
## Usage with Flow
|
36
36
|
|
37
|
-
|
37
|
+
Make sure you have a `.flowconfig` file at the root directory. You can also use the `flow` option on `.babelrc`:
|
38
38
|
|
39
|
-
```
|
39
|
+
```json
|
40
40
|
{
|
41
41
|
"presets": [["react-app", { "flow": true, "typescript": false }]]
|
42
42
|
}
|
@@ -44,9 +44,9 @@ Flow is enabled by default. Make sure you have a `.flowconfig` file at the root
|
|
44
44
|
|
45
45
|
## Usage with TypeScript
|
46
46
|
|
47
|
-
|
47
|
+
Make sure you have a `tsconfig.json` file at the root directory. You can also use the `typescript` option on `.babelrc`:
|
48
48
|
|
49
|
-
```
|
49
|
+
```json
|
50
50
|
{
|
51
51
|
"presets": [["react-app", { "flow": false, "typescript": true }]]
|
52
52
|
}
|
package/create.js
CHANGED
@@ -29,6 +29,11 @@ module.exports = function(api, opts, env) {
|
|
29
29
|
var isEnvProduction = env === 'production';
|
30
30
|
var isEnvTest = env === 'test';
|
31
31
|
|
32
|
+
var useESModules = validateBoolOption(
|
33
|
+
'useESModules',
|
34
|
+
opts.useESModules,
|
35
|
+
isEnvDevelopment || isEnvProduction
|
36
|
+
);
|
32
37
|
var isFlowEnabled = validateBoolOption('flow', opts.flow, true);
|
33
38
|
var isTypeScriptEnabled = validateBoolOption(
|
34
39
|
'typescript',
|
@@ -108,8 +113,13 @@ module.exports = function(api, opts, env) {
|
|
108
113
|
// Strip flow types before any other transform, emulating the behavior
|
109
114
|
// order as-if the browser supported all of the succeeding features
|
110
115
|
// https://github.com/facebook/create-react-app/pull/5182
|
111
|
-
|
116
|
+
// We will conditionally enable this plugin below in overrides as it clashes with
|
117
|
+
// @babel/plugin-proposal-decorators when using TypeScript.
|
118
|
+
// https://github.com/facebook/create-react-app/issues/5741
|
119
|
+
isFlowEnabled && [
|
112
120
|
require('@babel/plugin-transform-flow-strip-types').default,
|
121
|
+
false,
|
122
|
+
],
|
113
123
|
// Experimental macros support. Will be documented after it's had some time
|
114
124
|
// in the wild.
|
115
125
|
require('babel-plugin-macros'),
|
@@ -151,7 +161,7 @@ module.exports = function(api, opts, env) {
|
|
151
161
|
// https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
|
152
162
|
// We should turn this on once the lowest version of Node LTS
|
153
163
|
// supports ES Modules.
|
154
|
-
useESModules
|
164
|
+
useESModules,
|
155
165
|
// Undocumented option that lets us encapsulate our runtime, ensuring
|
156
166
|
// the correct version is used
|
157
167
|
// https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
|
@@ -172,6 +182,10 @@ module.exports = function(api, opts, env) {
|
|
172
182
|
require('babel-plugin-dynamic-import-node'),
|
173
183
|
].filter(Boolean),
|
174
184
|
overrides: [
|
185
|
+
isFlowEnabled && {
|
186
|
+
exclude: /\.tsx?$/,
|
187
|
+
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
|
188
|
+
},
|
175
189
|
isTypeScriptEnabled && {
|
176
190
|
test: /\.tsx?$/,
|
177
191
|
plugins: [
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "babel-preset-react-app",
|
3
|
-
"version": "
|
3
|
+
"version": "7.0.2",
|
4
4
|
"description": "Babel preset used by Create React App",
|
5
5
|
"repository": "facebook/create-react-app",
|
6
6
|
"license": "MIT",
|
@@ -17,24 +17,24 @@
|
|
17
17
|
"test.js"
|
18
18
|
],
|
19
19
|
"dependencies": {
|
20
|
-
"@babel/core": "7.
|
21
|
-
"@babel/plugin-proposal-class-properties": "7.
|
22
|
-
"@babel/plugin-proposal-decorators": "7.
|
23
|
-
"@babel/plugin-proposal-object-rest-spread": "7.
|
24
|
-
"@babel/plugin-syntax-dynamic-import": "7.
|
25
|
-
"@babel/plugin-transform-classes": "7.
|
26
|
-
"@babel/plugin-transform-destructuring": "7.
|
27
|
-
"@babel/plugin-transform-flow-strip-types": "7.
|
28
|
-
"@babel/plugin-transform-react-constant-elements": "7.
|
29
|
-
"@babel/plugin-transform-react-display-name": "7.
|
30
|
-
"@babel/plugin-transform-runtime": "7.
|
31
|
-
"@babel/preset-env": "7.1
|
20
|
+
"@babel/core": "7.2.2",
|
21
|
+
"@babel/plugin-proposal-class-properties": "7.3.0",
|
22
|
+
"@babel/plugin-proposal-decorators": "7.3.0",
|
23
|
+
"@babel/plugin-proposal-object-rest-spread": "7.3.2",
|
24
|
+
"@babel/plugin-syntax-dynamic-import": "7.2.0",
|
25
|
+
"@babel/plugin-transform-classes": "7.2.2",
|
26
|
+
"@babel/plugin-transform-destructuring": "7.3.2",
|
27
|
+
"@babel/plugin-transform-flow-strip-types": "7.2.3",
|
28
|
+
"@babel/plugin-transform-react-constant-elements": "7.2.0",
|
29
|
+
"@babel/plugin-transform-react-display-name": "7.2.0",
|
30
|
+
"@babel/plugin-transform-runtime": "7.2.0",
|
31
|
+
"@babel/preset-env": "7.3.1",
|
32
32
|
"@babel/preset-react": "7.0.0",
|
33
33
|
"@babel/preset-typescript": "7.1.0",
|
34
|
-
"@babel/runtime": "7.
|
35
|
-
"babel-loader": "8.0.
|
34
|
+
"@babel/runtime": "7.3.1",
|
35
|
+
"babel-loader": "8.0.5",
|
36
36
|
"babel-plugin-dynamic-import-node": "2.2.0",
|
37
|
-
"babel-plugin-macros": "2.
|
38
|
-
"babel-plugin-transform-react-remove-prop-types": "0.4.
|
37
|
+
"babel-plugin-macros": "2.5.0",
|
38
|
+
"babel-plugin-transform-react-remove-prop-types": "0.4.24"
|
39
39
|
}
|
40
40
|
}
|