rslib icon indicating copy to clipboard operation
rslib copied to clipboard

Bundler support track

Open fi3ework opened this issue 1 year ago • 0 comments

Bundler supports

Tracking the bundler supports for the optimal output (webpack[^1] and Rspack).

[^1]: Reference: https://github.com/webpack/webpack/issues/17121

(ESM) Tree shakable export

(ESM) ESM export should be tree-shakable.

  • [x] webpack: https://github.com/webpack/webpack/pull/18272
  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/6877

(ESM) ESM output won't break by scope isolation when bundling module bailout from concatenation.

  • [x] webpack: https://github.com/webpack/webpack/pull/18348
  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/6697

(ESM) Remove unnecessary webpack exports runtime

  • [x] webpack: https://github.com/webpack/webpack/pull/18338
  • [x] webpack: https://github.com/webpack/webpack/pull/18565
  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7102

(ESM) Force concatenation single module

  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7317
  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7394

(ESM) Externals

Externalized module import / dynamic import will introduce redundant runtime in webpack / Rspack. Dynamic import will be hoisted to the top level (https://github.com/webpack/webpack/issues/17986). Furthermore, the import and import() should be leave unchanged.

  • [x] support "module-import" external type

    • [x] webpack: https://github.com/webpack/webpack/pull/18620
    • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7479
  • [x] Rspack misaligned: Port https://github.com/webpack/webpack/pull/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.

    • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7533
  • [x] dynamic external introduce webpack runtime

    • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7759
  • [x] In concatenated module, static external module namespace import re-assign breaks tree shaking (demo)

    • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7839
  • [x] Not work with star export from external module (bundleless) https://github.com/webpack/webpack/issues/15270

    • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/8217
  • [x] preserve import() when import() is supported in that Node.js version in CJS. (BLOCK: can't distinguish static / dynamic from external callback except adding new information) https://github.com/webpack/webpack/discussions/16272

    • [ ] webpack: https://redirect.github.com/webpack/webpack/pull/18784
    • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/8414

(ESM) Avoid using namespace import for external module for better readability P0

  • [x] https://github.com/web-infra-dev/rslib/issues/869
  • [x] https://github.com/web-infra-dev/rslib/discussions/806

(ESM) Dynamic import (Chunk splitting) P1

Static analysis is not possible due to the public path at runtime.

  • [ ] https://github.com/webpack/webpack/issues/15697
  • [ ] https://github.com/webpack/webpack/issues/12801

(ESM) Preserve CSS Import

  • [x] CSS import statement will be extracted out.

(ESM) Node.js Shims

  • [x] https://github.com/web-infra-dev/rspack/pull/7465

(CJS) Support static analyzable export.

  • [x] webpack: https://github.com/webpack/webpack/pull/19303
  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/9630

(CJS / ESM) preserve require

  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7939

require and require.resolve

  • ESM:
    • [x] require(...) should be either behave like esbuild (sniff and throw as a fallback) or be shimmed with createRequire.
    • [x] require.resolve(...) should be either behave like esbuild (sniff and throw as a fallback) or be shimmed with createRequire.
  • CJS:
    • [x] require(...) with externals should work like __non_webpack_require__
    • [x] require.resolve(...) should preserve as-is.
    • [x] 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 as succeedModule is readonly in JS side)

(ESM) Re-export with property access or eval

  • [x] Rspack: https://github.com/web-infra-dev/rspack/pull/7394

(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.

  • [x] https://github.com/web-infra-dev/rslib/issues/316

(ESM) Multiple entries P2

Export in library works only for last entry module

  • [ ] https://github.com/webpack/webpack/issues/15936

(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

fi3ework avatar Jul 26 '24 06:07 fi3ework