Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Support all ES2016, ES2017 plugins and some ES2018. #313

Merged
merged 3 commits into from
Mar 16, 2018
Merged

Conversation

aomarks
Copy link
Member

@aomarks aomarks commented Mar 16, 2018

Adds:

  • exponentiation (ES2016)
  • async/await (ES2017)
  • async generators (ES2018)

Also improves tests and documentation.

Supersedes Polymer/polyserve#238

cc @LarsDenBakker

  • CHANGELOG.md has been updated

@stramel
Copy link

stramel commented Mar 16, 2018

Hang on isn't this not needed if we go with babel-preset-env?

@justinfagnani
Copy link
Contributor

@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.

@aomarks
Copy link
Member Author

aomarks commented Mar 16, 2018

Hang on isn't this not needed if we go with babel-preset-env?

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.

require('babel-plugin-syntax-async-functions'),
];
const babelCompilePlugins = [
require('babel-plugin-transform-object-rest-spread'),
Copy link
Contributor

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?

Copy link
Member Author

@aomarks aomarks Mar 16, 2018

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.

Copy link
Contributor

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... :(

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Contributor

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 :)

Copy link
Member Author

@aomarks aomarks Mar 16, 2018

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.

Copy link
Contributor

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"

Copy link
Member Author

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.

Copy link
Member Author

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.

@aomarks aomarks changed the base branch from js-transform-amd to master March 16, 2018 03:49
Also add tests for existing features that we want to support but are not
in the standard ES2015 preset.
@aomarks aomarks changed the title Support async/await in jsTransform. Support all ES2016, ES2017 plugins and some ES2018. Mar 16, 2018
@aomarks aomarks removed the request for review from usergenic March 16, 2018 05:43
Copy link
Contributor

@justinfagnani justinfagnani left a comment

Choose a reason for hiding this comment

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

Nice!

@aomarks aomarks merged commit 6c2b032 into master Mar 16, 2018
@aomarks aomarks deleted the es-features branch March 16, 2018 06:56
@shawncplus
Copy link

shawncplus commented Mar 26, 2018

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 lib/babel-helpers.min.js and therefor as part of polymer-cli won't be injected into the entrypoint

@aomarks
Copy link
Member Author

aomarks commented Mar 26, 2018

Which gulpfile?

@shawncplus
Copy link

@aomarks
Copy link
Member Author

aomarks commented Mar 26, 2018

Oh, gross, I didn't realize that's how we generated the helpers. Need to think about that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants