Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Babel issues in tests by applying the right transforms #1179

Merged
merged 1 commit into from
Dec 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ const plugins = [
[require.resolve('babel-plugin-transform-react-jsx'), {
useBuiltIns: true
}],
// function* () { yield 42; yield 43; }
[require.resolve('babel-plugin-transform-regenerator'), {
// Async functions are converted to generators by babel-preset-latest
async: false
}],
// Polyfills the runtime needed for async/await and generators
[require.resolve('babel-plugin-transform-runtime'), {
helpers: false,
Expand Down Expand Up @@ -69,13 +64,10 @@ if (env === 'development' || env === 'test') {
}

if (env === 'test') {
// The following plugins are a temporary workaround because
// `babel-plugin-transform-regenerator` apparently needs them
// and `babel-preset-env` doesn't detect it.
// https://github.com/facebookincubator/create-react-app/issues/1156
plugins.push.apply(plugins, [
require.resolve('babel-plugin-transform-es2015-arrow-functions'),
require.resolve('babel-plugin-transform-es2015-destructuring'),
// We always include this plugin regardless of environment
// because of a Babel bug that breaks object rest/spread without it:
// https://github.com/babel/babel/issues/4851
require.resolve('babel-plugin-transform-es2015-parameters')
]);

Expand All @@ -100,7 +92,13 @@ if (env === 'test') {
// JSX, Flow
require.resolve('babel-preset-react')
],
plugins: plugins
plugins: plugins.concat([
// function* () { yield 42; yield 43; }
[require.resolve('babel-plugin-transform-regenerator'), {
// Async functions are converted to generators by babel-preset-latest
async: false
}],
])
};

if (env === 'production') {
Expand Down
2 changes: 0 additions & 2 deletions packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
],
"dependencies": {
"babel-plugin-transform-class-properties": "6.16.0",
"babel-plugin-transform-es2015-arrow-functions": "6.8.0",
"babel-plugin-transform-es2015-destructuring": "6.19.0",
"babel-plugin-transform-es2015-parameters": "6.18.0",
"babel-plugin-transform-object-rest-spread": "6.19.0",
"babel-plugin-transform-react-constant-elements": "6.9.1",
Expand Down