Skip to content

Commit 50aaae6

Browse files
authored
Resolve regenerator runtime relative to react-scripts (#2175)
1 parent 5868913 commit 50aaae6

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

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

-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*/
99
'use strict';
1010

11-
var path = require('path');
12-
1311
const plugins = [
1412
// class { handleClick = () => { } }
1513
require.resolve('babel-plugin-transform-class-properties'),
@@ -36,8 +34,6 @@ const plugins = [
3634
helpers: false,
3735
polyfill: false,
3836
regenerator: true,
39-
// Resolve the Babel runtime relative to the config.
40-
moduleName: path.dirname(require.resolve('babel-runtime/package')),
4137
},
4238
],
4339
];

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"babel-plugin-transform-regenerator": "6.24.1",
2323
"babel-plugin-transform-runtime": "6.23.0",
2424
"babel-preset-env": "1.4.0",
25-
"babel-preset-react": "6.24.1",
26-
"babel-runtime": "6.23.0"
25+
"babel-preset-react": "6.24.1"
26+
},
27+
"peerDependencies": {
28+
"babel-runtime": "^6.23.0"
2729
}
2830
}

packages/react-scripts/config/webpack.config.dev.js

+9
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ module.exports = {
9393
// https://github.com/facebookincubator/create-react-app/issues/290
9494
extensions: ['.js', '.json', '.jsx'],
9595
alias: {
96+
// @remove-on-eject-begin
97+
// Resolve Babel runtime relative to react-scripts.
98+
// It usually still works on npm 3 without this but it would be
99+
// unfortunate to rely on, as react-scripts could be symlinked,
100+
// and thus babel-runtime might not be resolvable from the source.
101+
'babel-runtime': path.dirname(
102+
require.resolve('babel-runtime/package.json')
103+
),
104+
// @remove-on-eject-end
96105
// Support React Native Web
97106
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
98107
'react-native': 'react-native-web',

packages/react-scripts/config/webpack.config.prod.js

+9
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ module.exports = {
9090
// https://github.com/facebookincubator/create-react-app/issues/290
9191
extensions: ['.js', '.json', '.jsx'],
9292
alias: {
93+
// @remove-on-eject-begin
94+
// Resolve Babel runtime relative to react-scripts.
95+
// It usually still works on npm 3 without this but it would be
96+
// unfortunate to rely on, as react-scripts could be symlinked,
97+
// and thus babel-runtime might not be resolvable from the source.
98+
'babel-runtime': path.dirname(
99+
require.resolve('babel-runtime/package.json')
100+
),
101+
// @remove-on-eject-end
93102
// Support React Native Web
94103
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
95104
'react-native': 'react-native-web',

0 commit comments

Comments
 (0)