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

Turn on Babel helpers #5093

Merged
merged 14 commits into from
Sep 25, 2018
2 changes: 1 addition & 1 deletion packages/babel-preset-react-app/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function(api, opts, env) {
var isEnvProduction = env === 'production';
var isEnvTest = env === 'test';
var isFlowEnabled = validateBoolOption('flow', opts.flow, true);
var areHelpersEnabled = validateBoolOption('helpers', opts.helpers, false);
var areHelpersEnabled = validateBoolOption('helpers', opts.helpers, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, shouldn't default be false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the non-dependency version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it's for app code. Hmm.

Would it break these instructions?

https://reactjs.org/docs/add-react-to-a-website.html#run-jsx-preprocessor

If so I think it should still be off by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right but I don't want this to break non-commonjs usage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we should have a separate entry point for "standalone" usage.


if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-react-app/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
const create = require('./create');

module.exports = function(api, opts) {
return create(api, opts, 'development');
return create(api, { helpers: false, ...(opts || {}) }, 'development');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to spread undefined. I don't think you need || {}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is object spread though. Is it supported in all envs we target?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look at that. they thought of everything.

};
2 changes: 1 addition & 1 deletion packages/babel-preset-react-app/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
const create = require('./create');

module.exports = function(api, opts) {
return create(api, opts, 'production');
return create(api, { helpers: false, ...(opts || {}) }, 'production');
};
2 changes: 1 addition & 1 deletion packages/babel-preset-react-app/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
const create = require('./create');

module.exports = function(api, opts) {
return create(api, opts, 'test');
return create(api, { helpers: false, ...(opts || {}) }, 'test');
};
2 changes: 1 addition & 1 deletion packages/react-error-overlay/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": [["react-app", { "helpers": true }]]
"presets": ["react-app"]
}
7 changes: 1 addition & 6 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,7 @@ module.exports = {
options: {
// @remove-on-eject-begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed on eject. Where do we decide what to write on eject? Seems like we'd lose this. Maybe it means I wasn't right about the app default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babelrc: false,
presets: [
[
require.resolve('babel-preset-react-app'),
{ helpers: true },
],
],
presets: [require.resolve('babel-preset-react-app')],
// Make sure we have a unique cache identifier, erring on the
// side of caution.
// We remove this when the user ejects because the default
Expand Down
7 changes: 1 addition & 6 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,7 @@ module.exports = {
options: {
// @remove-on-eject-begin
babelrc: false,
presets: [
[
require.resolve('babel-preset-react-app'),
{ helpers: true },
],
],
presets: [require.resolve('babel-preset-react-app')],
// Make sure we have a unique cache identifier, erring on the
// side of caution.
// We remove this when the user ejects because the default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"dependencies": {
"bootstrap": "4.1.1",
"jest": "23.6.0",
"ky": "0.3.0",
"node-sass": "4.8.3",
"normalize.css": "7.0.0",
"prop-types": "15.5.6",
Expand Down
5 changes: 0 additions & 5 deletions packages/react-scripts/fixtures/kitchensink/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ class App extends Component {
this.setFeature(f.default)
);
break;
case 'babel-node-modules':
import('./features/syntax/NodeModulesCompilation').then(f =>
this.setFeature(f.default)
);
break;
case 'image-inclusion':
import('./features/webpack/ImageInclusion').then(f =>
this.setFeature(f.default)
Expand Down

This file was deleted.

This file was deleted.