web-infra-dev / rslib

Create JavaScript libraries in a simple and intuitive way.
https://lib.rsbuild.dev/
MIT License
461 stars 23 forks source link

Bundler support track #45

Open fi3ework opened 3 months ago

fi3ework commented 3 months ago

Bundler supports

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

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

CJS support

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

Tree shakable export

ESM artifacts should be tree-shakable.

Remove unnecessary webpack exports runtime

Externals P0

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.

Dynamic import (Chunk splitting) P1

Can't be static analysis because of the public path runtime.

Preserve CSS Import

CSS import statement will be extracted out.

Node.js Shims

Miscellaneous

require

require and require.resolve

Extra runtime when bundling single module

Re-export with property access or eval

Multiple entries P2

Export in library works only for last entry module

fi3ework commented 3 months ago

🚧 ESM output quality track

Not aim to strict alignment with esbuild, compare the differences between esbuild artifacts and create a more compact output.