Description
Bundler supports
Tracking the bundler supports for the optimal output (webpack1 and Rspack).
(ESM) Tree shakable export
(ESM) ESM export should be tree-shakable.
- webpack: feat: tree shakable output for module library webpack/webpack#18272
- Rspack: feat: tree shakable output for module library rspack#6877
(ESM) ESM output won't break by scope isolation when bundling module bailout from concatenation.
- webpack: feat: root module is less prone to be wrapped in IIFE webpack/webpack#18348
- Rspack: feat: root module is less prone to be wrapped in IIFE rspack#6697
(ESM) Remove unnecessary webpack exports runtime
- webpack: fix: only render init code when need moduleRemapping webpack/webpack#18338
- webpack: feat: reduce unnecessary exports runtime webpack/webpack#18565
- Rspack: feat: reduce unnecessary exports runtime rspack#7102
(ESM) Force concatenation single module
- Rspack: feat(modern-module): force concaten single module rspack#7317
- Rspack: fix(modern-module): compat with more export cases rspack#7394
(ESM) Externals
Externalized module import / dynamic import will introduce redundant runtime in webpack / Rspack. Dynamic import will be hoisted to the top level (webpack/webpack#17986). Furthermore, the import
and import()
should be leave unchanged.
-
support
"module-import"
external type -
Rspack misaligned: Port fix: only render init code when need moduleRemapping webpack/webpack#18338. However, the simple module remapping runtime in Rspack (https://github.com/web-infra-dev/rspack/blob/main/crates/rspack_core/src/external_module.rs#L266-L269) is totally unused now.
-
dynamic external introduce webpack runtime
-
In concatenated module, static external module namespace import re-assign breaks tree shaking (demo)
-
Not work with star export from external module (bundleless) Preserve star exports for externalized dependencies in module output webpack/webpack#15270
-
preserve
import()
whenimport()
is supported in that Node.js version in CJS. (BLOCK: can't distinguish static / dynamic from external callback except adding new information) Allow Dynamic Import in `commonjs2` webpack/webpack#16272
(ESM) Avoid using namespace import for external module for better readability P0
- [Feature]: provide option to stop injecting __webpack_exports__ and __WEBPACK_EXTERNAL_MODULE_ variable prefix #869
- Unbundled esm output #806
(ESM) Dynamic import (Chunk splitting) P1
Static analysis is not possible due to the public path at runtime.
- Output statically resolvable dynamic import expressions webpack/webpack#15697
- Single runtime chunk incompatible with library output in Webpack 5 webpack/webpack#12801
(ESM) Preserve CSS Import
- CSS import statement will be extracted out.
(ESM) Node.js Shims
(CJS) Support static analyzable export.
- webpack: fix(commonjs-static): export unprovided variables webpack/webpack#19303
- Rspack: fix(commonjs-static): export unprovided variables rspack#9630
(CJS / ESM) preserve require
require
and require.resolve
- ESM:
-
require(...)
should be either behave like esbuild (sniff and throw as a fallback) or be shimmed withcreateRequire
. -
require.resolve(...)
should be either behave like esbuild (sniff and throw as a fallback) or be shimmed withcreateRequire
.
-
- CJS:
-
require(...)
with externals should work like__non_webpack_require__
-
require.resolve(...)
should preserve as-is. - preserve
require('./' + expression + '.js')
like dynamic require with expression. (BLOCK: https://github.com/microsoft/rushstack/blob/main/webpack/preserve-dynamic-require-plugin/README.md not available in Rspack assucceedModule
is readonly in JS side)
-
(ESM) Re-export with property access or eval
(ESM) Multiple entries shares module graph
Multiple entries share the same module graph which will make bail out reason turn out to be a merge of all the entries and breaks the concatenation.
(ESM) Multiple entries P2
Export in library works only for last entry module
(ESM) Entry module demanding not to be bailed out.
- Entry module must not trigger concatenation bail out (such as contains eval expression), otherwise it will break the current
"modern-module"
's ESM export premise.
non-Rslib related ESM feature support in Rspack
- HMR