-
Notifications
You must be signed in to change notification settings - Fork 39
Support all ES2016, ES2017 plugins and some ES2018. #313
Conversation
Hang on isn't this not needed if we go with babel-preset-env? |
@stramel maybe not, but we're not sure yet how we want to configure preset-env so no transform is required in certain browsers. If this is temporary until then that's fine. |
Yes, but we're not on babel-preset-env yet, just wanted to throw this in quickly. My open question about babel-preset-env is how to handle the minify-but-not-transform case. I'm not sure how to get babel-preset-env to give us all the syntax plugins so that babel doesn't blow up on new syntax, without also getting the transpilation plugins. LMK if you know a way, otherwise will investigate later. |
src/js-transform.ts
Outdated
require('babel-plugin-syntax-async-functions'), | ||
]; | ||
const babelCompilePlugins = [ | ||
require('babel-plugin-transform-object-rest-spread'), |
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.
is this now everything from ES2018? Did we get all of ES2016&7 too? Why not change the below to use babel-preset-es2015
?
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.
is this now everything from ES2018? Did we get all of ES2016&7 too?
I can go through and find any missing ones. We don't have exponentiation operator, for example. But it does feel like we should just do preset env. I just sent this PR because we had some specific requests for these features.
Why not change the below to use babel-preset-es2015?
Not sure I understand. We do use babel-preset-es2015, but only during transform. All the babel-preset-es* plugins do transformations. Similar problem we have with preset env. So we have to extract all the specific syntax plugins anyway, for the minimize-but-not-compile case.
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.
But this is the transform and not just syntax plugin, yes? So if we're adding this to the list of transforms, couldn't we just update the preset below to use babel-preset-es2015
?
Or maybe you meant to add the syntax plugin here?
Sorry if I'm confused here too, I keep reading syntax or transform and thinking the other... :(
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.
Oh, you mean update preset-es2015 to preset-es2017. Yes, let's just do that, then we don't need to list the specific transform plugins. We do still need to list the specific syntax plugins, though.
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.
preset-es2018 if we're talking about object spread
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.
^ no README, no repo link, barely any downloads. Ok, don't use that :)
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.
Looked at that. It's just there to prevent squatting I assume: https://unpkg.com/babel-preset-es2018@1.0.0/ Created by hzoo.
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.
ahhh... I originally just saw hzoo and was like "cool, use it"
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.
Ok, PTAL.
I added more documentation, a couple plugins (exponentiation and async generators), and organized the plugins by year.
All of the ES2018 features are not yet available, e.g. regexp named capture groups is still in development: babel/babel#7105.
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.
Oh also, decided not to use the ES2017 preset, because turns out these presets don't include their prior year plugins. Since ES2016 and ES2017 only add one plugin each, it seemed simpler to just list them (since we have to list the syntax plugins separately anyway) than to merge the presets.
Also add tests for existing features that we want to support but are not in the standard ES2015 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.
Nice!
Perhaps I'm missing something but because this doesn't update the gulpfile to uncomment the appropriate babel helpers you can't really use any of the ES2017+ features after the build since the helpers won't be injected into |
Which gulpfile? |
Oh, gross, I didn't realize that's how we generated the helpers. Need to think about that. |
Adds:
Also improves tests and documentation.
Supersedes Polymer/polyserve#238
cc @LarsDenBakker