Use @babel/preset-env exclusively #395
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.
Closes #394. This:
@babel/preset-envexclusively, which reducesdevDependenciesand ensures we have all the necessary transforms to support intended target environments.babelrc, ensuring thatbuild/build.jsandnpm run update-browser-errorsuse the same setup.As a result, there are now 12 new transforms applied to code imported from node core. Most notably (going by the amount of diff):
transform-block-scoped-functionsfunction foo () {}to hoistedvar foo = function () {}transform-function-namefunction.namethough?From the new transforms, I excluded:
transform-typeof-symbolbecause a quick benchmark showed that its fallback is 2-3x slower than nativetypeof, we have replacements in place forSymbolusage and I couldn't find any code liketypeof Symbol().transform-regeneratorbecause it'd only apply to tests and I think we shouldn't transpile "optional features" (like generators and async functions) but rather run tests selectively in target environments that support these features.We may want to exclude some target environments as well if they're not officially supported. For example, do we support Android?
Here's a full list of resolved targets and plugins, logged by
@babel/preset-env:Click to expand
Of those plugins, the following are new to
build/build.js(not necessarily used):Click to expand
transform-block-scoped-functionstransform-function-nametransform-duplicate-keystransform-new-targettransform-object-superproposal-unicode-property-regextransform-unicode-regextransform-sticky-regextransform-dotall-regextransform-exponentiation-operatorproposal-json-stringstransform-literals