This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
Enable @babel/preset-env's ShippedProposals mode #1580
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enabling this means that preset-env now injects additional plugins for any features that aren't yet stage 3, but have been shipped in at least one browser (meaning they are as good as finalised):
https://babeljs.io/docs/en/babel-preset-env#shippedproposals
Using this new mode also means we no longer need to manually include the
@babel/plugin-proposal-class-properties
plugin, since it's included in the shipped proposals list as of Babel 7.10.0:babel/babel#11451
This change does mean that
@babel/plugin-proposal-class-properties
will be used in strict mode rather than loose mode if browsers in the target list do not support it (so slight bundle size increase), however that seems like a reasonable trade-off to:...especially given several browsers already support it natively:
https://github.com/babel/babel/blob/426acf336e0ab8402714e25b12edf1a61a735ce5/packages/babel-compat-data/data/plugins.json#L13-L19
I've tested this change locally to ensure class properties do indeed continue to work (wish we had a better test suite for sample functionality that wasn't just the create-project templates, where we really don't want to add complexity since the examples should be simple).