Skip to content

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

Merged
sokra merged 10 commits into
masterfrom
feature/esm-chunk-loading
Jun 28, 2021
Merged

sokra merged 10 commits into
masterfrom
feature/esm-chunk-loading

Conversation

@sokra

@sokra sokra commented Jun 23, 2021 •

Copy link
Copy Markdown
Member

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

webpack-bot commented Jun 23, 2021 •

Copy link
Copy Markdown
Contributor

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
@sokra
sokra force-pushed the feature/esm-chunk-loading branch from a43edfd to 4da99d8 Compare June 23, 2021 12:50
Comment thread lib/config/defaults.js
D(
output,
"hotUpdateChunkFilename",
`[id].[fullhash].hot-update.${output.module ? "mjs" : "js"}`

Copy link
Copy Markdown
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
sokra added 2 commits June 25, 2021 10:37
… externals

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
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
Copy Markdown
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants