Skip to content

Commit 72d4ab0

Browse files
authored
Strip flow syntax before any other transform (#5182)
* Strip flow syntax before any other transform Plugins run before presets so we can't use the flow preset * Add informative comment
1 parent 70b3110 commit 72d4ab0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/babel-preset-react-app/create.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@ module.exports = function(api, opts, env) {
9595
useBuiltIns: true,
9696
},
9797
],
98-
isFlowEnabled && [require('@babel/preset-flow').default],
9998
].filter(Boolean),
10099
plugins: [
100+
// Strip flow types before any other transform, emulating the behavior
101+
// order as-if the browser supported all of the succeeding features
102+
// https://github.com/facebook/create-react-app/pull/5182
103+
isFlowEnabled &&
104+
require('@babel/plugin-transform-flow-strip-types').default,
101105
// Experimental macros support. Will be documented after it's had some time
102106
// in the wild.
103107
require('babel-plugin-macros'),

packages/babel-preset-react-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
"@babel/plugin-syntax-dynamic-import": "7.0.0",
2424
"@babel/plugin-transform-classes": "7.1.0",
2525
"@babel/plugin-transform-destructuring": "7.0.0",
26+
"@babel/plugin-transform-flow-strip-types": "7.0.0",
2627
"@babel/plugin-transform-react-constant-elements": "7.0.0",
2728
"@babel/plugin-transform-react-display-name": "7.0.0",
2829
"@babel/plugin-transform-runtime": "7.1.0",
2930
"@babel/preset-env": "7.1.0",
30-
"@babel/preset-flow": "7.0.0",
3131
"@babel/preset-react": "7.0.0",
3232
"@babel/runtime": "7.0.0",
3333
"babel-loader": "8.0.4",

0 commit comments

Comments
 (0)