Skip to content
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

improvements to ESM support, module library, import chunk loading, module externals #13622

Merged
merged 10 commits into from Jun 28, 2021

Conversation

sokra
Copy link
Member

@sokra sokra commented Jun 23, 2021

What kind of change does this PR introduce?
feature

Did you add tests for your changes?
yes

Does this PR introduce a breaking change?
no

What needs to be documented once your changes are merged?

  • output.library.type: "module" is now experimentally supported
  • output.chunkLoading: "import" uses import() to load chunks
  • output.chunkFormat: "module" uses ESM exports to expose chunk data
  • experiments.outputModule will now use output.chunkFormat: "module", output.chunkLoading: "import"
  • externalsType: "module" generates now import * as X from "..." (in a module) or import("...") (in a script)
  • externalsType: "node-commonjs" generates import { createRequire } from "module" when in a module
  • externalsPresets use node-commonjs now when node.js related

@webpack-bot
Copy link
Contributor

webpack-bot commented Jun 23, 2021

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

@sokra sokra force-pushed the feature/esm-chunk-loading branch from b6b94a7 to a43edfd Compare June 23, 2021 11:59
D(
output,
"hotUpdateChunkFilename",
`[id].[fullhash].hot-update.${output.module ? "mjs" : "js"}`
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can read package.json here and use js when "type": "module" (same for filename)?

@sokra sokra changed the title improvements to ESM support, module library, import chunk loading improvements to ESM support, module library, import chunk loading, module externals Jun 24, 2021
… externals

for `module` externals, fallback to `import()` when not in module mode
@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra sokra merged commit 3bcd719 into master Jun 28, 2021
@sokra sokra deleted the feature/esm-chunk-loading branch June 28, 2021 08:55
@webpack-bot
Copy link
Contributor

I've created an issue to document this in webpack/webpack.js.org.

@@ -0,0 +1,16 @@
module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot let my webpack 5.46 emit import(...) with this config. Is this feature released?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry I forgot to export config file

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

Successfully merging this pull request may close these issues.

None yet

4 participants