Skip to content

Conversation

@3ru
Copy link
Member

@3ru 3ru commented Aug 17, 2025

Description:
For ESM libraries (experiments.outputModule + library.type: "module"), replace runtime string concatenation with a compile‑time chunkId → URL mapping and emit import(new URL("<literal>", import.meta.url).href). This makes dynamic imports statically analyzable by other bundlers and robust under file://, while avoiding unused __webpack_require__.u/publicPath code.

Fixes:

Testing:
Added test/configCases/library/module-dynamic-import-url to assert:

  • presence of new URL(..., import.meta.url).href in output
  • absence of __webpack_require__.u and publicPath concatenation
  • dynamic import executes successfully

Breaking Changes:
None

Documentation Updates:
na

Related:
Part of #17121

@3ru 3ru force-pushed the fix/esm-library-dynamic-import-new-url branch from 8eef1ac to a4027ea Compare August 17, 2025 07:01
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 17, 2025

CodSpeed Performance Report

Merging #19814 will degrade performances by 31.01%

Comparing 3ru:fix/esm-library-dynamic-import-new-url (b8c489f) with main (1f5e8e5)

Summary

⚡ 2 improvements
❌ 1 regression
✅ 39 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark "devtool-source-map", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 73.1 ms 105.9 ms -31.01%
benchmark "many-modules-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 149.5 ms 116.2 ms +28.7%
benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 124.9 ms 97.3 ms +28.45%

@3ru 3ru force-pushed the fix/esm-library-dynamic-import-new-url branch from e98d574 to 49984f1 Compare August 17, 2025 07:36
@3ru 3ru force-pushed the fix/esm-library-dynamic-import-new-url branch from 49984f1 to cf2634d Compare August 17, 2025 08:21
@3ru 3ru marked this pull request as ready for review August 17, 2025 08:30
@3ru 3ru marked this pull request as draft September 1, 2025 02:50
@3ru 3ru marked this pull request as ready for review September 15, 2025 15:24
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.

2 participants