[v3.0] Keep dynamic imports in CommonJS output#4647
Merged
lukastaegert merged 4 commits intorelease-3.0.0from Oct 7, 2022
Merged
[v3.0] Keep dynamic imports in CommonJS output#4647lukastaegert merged 4 commits intorelease-3.0.0from
lukastaegert merged 4 commits intorelease-3.0.0from
Conversation
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#rollup-3-cjs-dynamic-importor load it into the REPL: |
Codecov Report
@@ Coverage Diff @@
## release-3.0.0 #4647 +/- ##
================================================
Coverage ? 98.97%
================================================
Files ? 213
Lines ? 7485
Branches ? 2115
================================================
Hits ? 7408
Misses ? 23
Partials ? 54
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
24ededd to
b46330e
Compare
f75b690 to
a5df4a1
Compare
lukastaegert
added a commit
that referenced
this pull request
Oct 10, 2022
* Support dynamic imports in cjs output and make default * Add documentation * Also use import for unresolvable dynamic imports * Extend CLI docs
Collaborator
|
This PR has been released as part of rollup@3.0.0-8. Note that this is a pre-release, so to test it, you need to install Rollup via |
lukastaegert
added a commit
that referenced
this pull request
Oct 11, 2022
* Support dynamic imports in cjs output and make default * Add documentation * Also use import for unresolvable dynamic imports * Extend CLI docs
Collaborator
|
This PR has been released as part of rollup@3.0.0. You can test it via |
divdavem
added a commit
to AmadeusITGroup/kassette
that referenced
this pull request
Dec 1, 2022
cf rollup/rollup#4647 This fixes e2e tests on Windows.
divdavem
added a commit
to AmadeusITGroup/kassette
that referenced
this pull request
Dec 1, 2022
cf rollup/rollup#4647 This fixes e2e tests on Windows.
vreynolds
pushed a commit
to honeycombio/libhoney-js
that referenced
this pull request
Apr 21, 2023
Bumps [rollup](https://github.com/rollup/rollup) from 2.79.0 to 3.20.2. The only difference in artifacts is in the CJS file. The dynamic import of superagent is no longer rewritten as require (rollup/rollup#4647). We can turn that off with rollup config, but it should work with this change since dynamic import in CJS has been available since node version 9. Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or 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
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.
BREAKING CHANGE: We keep external dynamic imports in CommonJS output by default as
import()This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
In order to complete the Node ESM story in Rollup 3, I decided to add this last feature to Rollup 3. This will by default keep external (and only those) dynamic imports in CommonJS output as
import(…)to support ESM interop. You can deactivate this behavior via a new optiondynamicImportInCjs: false, which will activate the old rewriting behavior.output.dynamicImportInCjs
Type:
booleanCLI:
--dynamicImportInCjs/--no-dynamicImportInCjsDefault:
trueWhile CommonJS output originally supported only
require(…)to import dependencies, recent Node versions also started to supportimport(…), which is the only way to import ES modules from CommonJS files. If this option istrue, which is the default, Rollup will keep external dynamic imports asimport(…)expressions in CommonJS output. Set this tofalseto rewrite dynamic imports usingrequire(…)syntax.