-
Notifications
You must be signed in to change notification settings - Fork 2k
Use babel-preset-env #880
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
Use babel-preset-env #880
Conversation
package.json
Outdated
"babel-plugin-transform-es2015-block-scoping": "6.24.1", | ||
"babel-plugin-transform-es2015-classes": "6.24.1", | ||
"babel-plugin-transform-es2015-computed-properties": "6.24.1", | ||
"babel-plugin-transform-class-properties": "^6.24.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was missing from the package.json
and was only working through an accidental transitive dep.
.babelrc
Outdated
"transform-es2015-modules-commonjs", | ||
"transform-regenerator", | ||
"transform-es3-property-literals" | ||
["transform-es2015-spread", {"loose": true}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was defined twice. I kept the loose
mode dep but if loose
can be turned off, both this and the destructuring transform could be removed since they are already applied in the Node4 preset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this. We're not compiling for Node v4, we support lots of browsers as well. I'm concerned that lying about our compile target will result in difficult to detect issues for slightly older browsers.
What's the value this provides us over an explicit list of transforms?
.babelrc
Outdated
@@ -1,27 +1,16 @@ | |||
{ | |||
"presets": [["env", { | |||
"targets": { | |||
"node": 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this guarantee the same scope of transforms as below?
package.json
Outdated
"babel-plugin-syntax-async-generators": "6.13.0", | ||
"babel-plugin-transform-class-properties": "6.24.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's defined here - your change just caused the line to appear added since a ^
was added to the version
tl;dr I think there is value in doing this but the PR, as it is now, is not correct as you pointed out. I'd love to work together to get it sorted out.
I had been thinking of this as a set of server side modules but you're right, some parts of this will be run on both the client and on the server in things like Relay-Modern, Apollo and others.
The intention was not to lie about the compile target (although, yes, I took care to make sure the same transformations were applied) the intention was to be explicit about what you are compiling for. It was my mistake to assume
Full disclosure, I wrote some of |
Also, thanks for all the work you've done on this project and specifically for the quick review! |
We could (and maybe should) consider adding a Actually, now that I write it, I think perhaps we should specify a |
Another quick note w/r to browser support is that often Uglify2 is the limiting factor. Most folks do compression on their full bundle as a post-build step and unfortunately Uglify2/3 does not support any ES-next syntax. This is changing with things like uglify-es and Babili but that's far from the norm. You'll notice that in included the I think the strongest case for this plugin is an explicit statement of support for some environments without having to manage the |
I agree this is pretty compelling. If updated to list all of this out (we should support IE9+, old chrome/ff, etc) while maintaining the "loose mode" transforms to preserve performance, and to guarantee avoiding bundling in polyfills, then this could be merged. Otherwise, my primary concern is that some future version of |
Okay, all done! After this diff, the transformations will be identical to what is in master but fully managed by caveat: The following transformations are new. Below is a list of transforms and a comma-separated list indicating the browsers that triggered babel-preset-env to include them.
|
Thanks for your work on this @baer. I think what you've got here is reasonable at this point. Let's ship it and revise it as necessary if we discover some unanticipated downside. |
This PR updates the
.babelrc
file to follow the guidelines set by the Babel team. The following changes were made:.babelrc
andpackage.json
transform-class-properties
dep to thepackage.json
The fallout from this is that the
.babelrc
file is much cleaner and, much more importantly, the file that is shipped to clients should be much leaner since it only applies the presets that a required for that platform.