-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
docs: clarify modules option in preset-env #2301
Merged
JLHwung
merged 4 commits into
babel:master
from
JLHwung:clarify-modules-preset-env-option
Jul 30, 2020
Merged
docs: clarify modules option in preset-env #2301
JLHwung
merged 4 commits into
babel:master
from
JLHwung:clarify-modules-preset-env-option
Jul 30, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deploy preview for babel ready! Built without sensitive environment variables with commit 17d14a5 |
This was referenced Jul 27, 2020
Co-authored-by: Brian Ng <[email protected]>
docs/options.md
Outdated
Comment on lines
49
to
52
supportsStaticESM: boolean; | ||
supportsDynamicImport: boolean; | ||
supportsTopLevelAwait: boolean; | ||
} |
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.
Suggested change
supportsStaticESM: boolean; | |
supportsDynamicImport: boolean; | |
supportsTopLevelAwait: boolean; | |
} | |
supportsStaticESM?: boolean; | |
supportsDynamicImport?: boolean; | |
supportsTopLevelAwait?: boolean; | |
} |
These should all be optional
nicolo-ribaudo
approved these changes
Jul 28, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
{ modules: false }
has been long used as a fast switch to "preserve ES module" so bundlers can leverage from the module syntax. However the defaults{ modules: "auto" }
should be preferred because it reads caller support data and reduces cognitive loads -- Idea like "I want to disable module transforms so Webpack can do tree shaking" is not straightforward, it is the defaults that should work out of that for you.Since Babel 7.11,
preset-env
will assume{ modules: false }
as to "preserve ES module" and the compiled code will be served without bundling. By doing sopreset-env
can determine whether it should transpileexport * as ns
based on the targets. This assumption only works when it is not passed to bundlers, where bundlers may not support latest module syntax, (e.g. Webpack 5.0.0-beta.21 supports this recently, thusexport * as ns
will break on Webpack 4.Although
export * as ns
will break on Webpack 4, since it is not included inpreset-env
before, users should have supplied@babel/plugin-proposal-export-namesapce-from
so they are good when upgrading to Babel 7.11. However users just begin to useexport * as ns
inpreset-env
7.11 withmay surprisedly find that
preset-env
does not transpileexport * as ns
and errors are thrown from Webpack.