Commit 5645aa92 authored by Dan Abramov's avatar Dan Abramov Committed by GitHub
Browse files

Resolve babel-runtime relative to the config (#535)

This makes generators work with Jest.

Fixes #255.
Replaces #262.
parent 6fe904cd
No related merge requests found
Showing with 17 additions and 21 deletions
+17 -21
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
var path = require('path');
module.exports = { module.exports = {
// Don't try to find .babelrc because we want to force this configuration. // Don't try to find .babelrc because we want to force this configuration.
babelrc: false, babelrc: false,
...@@ -33,7 +35,10 @@ module.exports = { ...@@ -33,7 +35,10 @@ module.exports = {
[require.resolve('babel-plugin-transform-runtime'), { [require.resolve('babel-plugin-transform-runtime'), {
helpers: false, helpers: false,
polyfill: false, polyfill: false,
regenerator: true regenerator: true,
// Resolve the Babel runtime relative to the config.
// You can safely remove this after ejecting:
moduleName: path.dirname(require.resolve('babel-runtime/package'))
}] }]
] ]
}; };
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
var path = require('path');
module.exports = { module.exports = {
// Don't try to find .babelrc because we want to force this configuration. // Don't try to find .babelrc because we want to force this configuration.
babelrc: false, babelrc: false,
...@@ -30,7 +32,10 @@ module.exports = { ...@@ -30,7 +32,10 @@ module.exports = {
[require.resolve('babel-plugin-transform-runtime'), { [require.resolve('babel-plugin-transform-runtime'), {
helpers: false, helpers: false,
polyfill: false, polyfill: false,
regenerator: true regenerator: true,
// Resolve the Babel runtime relative to the config.
// You can safely remove this after ejecting:
moduleName: path.dirname(require.resolve('babel-runtime/package'))
}], }],
// Optimization: hoist JSX that never changes out of render() // Optimization: hoist JSX that never changes out of render()
// Disabled because of issues: // Disabled because of issues:
......
...@@ -68,15 +68,8 @@ module.exports = { ...@@ -68,15 +68,8 @@ module.exports = {
// These are the reasonable defaults supported by the Node ecosystem. // These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''], extensions: ['.js', '.json', ''],
alias: { alias: {
// This `alias` section can be safely removed after ejection. // Support React Native Web
// We do this because `babel-runtime` may be inside `react-scripts`, // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
// so when `babel-plugin-transform-runtime` imports it, it will not be
// available to the app directly. This is a temporary solution that lets
// us ship support for generators. However it is far from ideal, and
// if we don't have a good solution, we should just make `babel-runtime`
// a dependency in generated projects.
// See https://github.com/facebookincubator/create-react-app/issues/255
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator'),
'react-native': 'react-native-web' 'react-native': 'react-native-web'
} }
}, },
......
...@@ -63,15 +63,8 @@ module.exports = { ...@@ -63,15 +63,8 @@ module.exports = {
// These are the reasonable defaults supported by the Node ecosystem. // These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''], extensions: ['.js', '.json', ''],
alias: { alias: {
// This `alias` section can be safely removed after ejection. // Support React Native Web
// We do this because `babel-runtime` may be inside `react-scripts`, // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
// so when `babel-plugin-transform-runtime` imports it, it will not be
// available to the app directly. This is a temporary solution that lets
// us ship support for generators. However it is far from ideal, and
// if we don't have a good solution, we should just make `babel-runtime`
// a dependency in generated projects.
// See https://github.com/facebookincubator/create-react-app/issues/255
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator'),
'react-native': 'react-native-web' 'react-native': 'react-native-web'
} }
}, },
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment