Skip to content

Commit

Permalink
Resolve regenerator runtime relative to react-scripts (#2175)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed May 16, 2017
1 parent 5868913 commit 50aaae6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 0 additions & 4 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
*/
'use strict';

var path = require('path');

const plugins = [
// class { handleClick = () => { } }
require.resolve('babel-plugin-transform-class-properties'),
Expand All @@ -36,8 +34,6 @@ const plugins = [
helpers: false,
polyfill: false,
regenerator: true,
// Resolve the Babel runtime relative to the config.
moduleName: path.dirname(require.resolve('babel-runtime/package')),
},
],
];
Expand Down
6 changes: 4 additions & 2 deletions packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"babel-plugin-transform-regenerator": "6.24.1",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-env": "1.4.0",
"babel-preset-react": "6.24.1",
"babel-runtime": "6.23.0"
"babel-preset-react": "6.24.1"
},
"peerDependencies": {
"babel-runtime": "^6.23.0"
}
}
9 changes: 9 additions & 0 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx'],
alias: {
// @remove-on-eject-begin
// Resolve Babel runtime relative to react-scripts.
// It usually still works on npm 3 without this but it would be
// unfortunate to rely on, as react-scripts could be symlinked,
// and thus babel-runtime might not be resolvable from the source.
'babel-runtime': path.dirname(
require.resolve('babel-runtime/package.json')
),
// @remove-on-eject-end
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
Expand Down
9 changes: 9 additions & 0 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx'],
alias: {
// @remove-on-eject-begin
// Resolve Babel runtime relative to react-scripts.
// It usually still works on npm 3 without this but it would be
// unfortunate to rely on, as react-scripts could be symlinked,
// and thus babel-runtime might not be resolvable from the source.
'babel-runtime': path.dirname(
require.resolve('babel-runtime/package.json')
),
// @remove-on-eject-end
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
Expand Down

0 comments on commit 50aaae6

Please sign in to comment.