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

Upgrade Babel to 7.0 #4662

Merged
merged 11 commits into from
Aug 30, 2018
Merged

Upgrade Babel to 7.0 #4662

merged 11 commits into from
Aug 30, 2018

Conversation

kevinji
Copy link
Collaborator

@kevinji kevinji commented Jan 29, 2018

This shouldn't be merged until Babel 7.0 is actually released.

@kevinji kevinji changed the title [WIP] Upgrade Babel to 7.0 Upgrade Babel to 7.0 Aug 30, 2018
… subclass implementations

Babel 7 is more spec compliant, in that it always assigns `undefined` to an own property for each undefined object property;
since these methods are meant to be defined on the prototype, this always overrides the implementation with undefined.
Copy link
Collaborator

@erikdesjardins erikdesjardins left a comment

Choose a reason for hiding this comment

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

Originally the Babel config was all in one file, but there are enough subtle differences (see review comments) that trying to add exceptions for everything was more complex than duplicating it.

I think that's still the case, so I'm going to revert those changes for now, but we can look into doing it in the future, especially if: ESLint/Ava support import/export syntax (so we can remove the commonjs plugin entirely), and we keep using transform-define via Webpack for NODE_ENV, so we don't have duplication (in setting "production" and replacing process.env).

.babelrc Outdated
"transform-es2015-modules-commonjs",
"transform-flow-strip-types"
],
"sourceMaps": "inline"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Inline sourcemaps are required for Ava to give correct line numbers (perhaps not anymore?), but don't work in Webpack. In addition to the settings incompatibility, Webpack handles sourcemaps separately from the source file (e.g.).

babel.config.js Outdated
'@babel/plugin-proposal-export-namespace-from',
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
'@babel/plugin-transform-modules-commonjs',
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should only be used for ESLint/Ava which don't understand modules (maybe they do now?), and not Webpack, since it prevents module concatenation, leading to a size (1.84 -> 2.14 MB) and startup time regression.

babel.config.js Outdated

module.exports = {
presets: [
'@babel/preset-env',
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need preset-env, since we only use experimental syntax and already individually include the plugins. I prefer doing it this way so that we have to explicitly opt in to new syntax.

I feel like @preset/env is more targeted towards webapps that support much older browsers and need to compile a lot more syntax (-> a lot of plugins to add manually), while we just have a few plugins.

package.json Outdated
@@ -16,11 +16,11 @@
"scripts": {
"preinstall": "npm -v && node -v && git rev-parse HEAD && git status --porcelain",
"prestart": "rimraf dist",
"start": "webpack --watch --progress --mode development --env.browsers",
"start": "cross-env NODE_ENV=development webpack --watch --progress --mode development --env.browsers",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like using two separate ways of setting "production" (NODE_ENV and --mode)

babel.config.js Outdated
['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-flow-strip-types',
'transform-node-env-inline',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Originally I avoided this plugin because it didn't work as well as transform-define (leaving 'production' === 'production' checks in the code along with dead code). Even if it works now, using two separate ways to replace process.env properties doesn't seem simpler than the previous solution.

Copy link
Collaborator

@erikdesjardins erikdesjardins left a comment

Choose a reason for hiding this comment

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

Thanks for all your work on this!

@erikdesjardins erikdesjardins merged commit 542bcd6 into honestbleeps:master Aug 30, 2018
@kevinji
Copy link
Collaborator Author

kevinji commented Aug 30, 2018

Sounds good to me, thanks for the help!

@kevinji kevinji deleted the babel-7 branch August 31, 2018 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants