rslib icon indicating copy to clipboard operation
rslib copied to clipboard

[Feature]: Remove Rspack runtime from CommonJS output files

Open sanfengliao opened this issue 7 months ago • 3 comments

What problem does this feature solve?

Currently, each file in the CommonJS format output contains Rspack's runtime code. Is it possible to remove the Rspack runtime and only use require() to import other modules

What does the proposed API look like?

Generate clean CommonJS files that only use standard require() statements to import dependencies, without embedding Rspack runtime in each file.

sanfengliao avatar Jun 15 '25 12:06 sanfengliao

Same as #594. This is what we expect to optimize in the future, but currently, the focus of our output optimization is on ESM format. We will draw experience from the ESM optimization to better complete the optimization of CJS outputs. Stay tuned!

Timeless0911 avatar Jun 15 '25 14:06 Timeless0911

Currently, each file in the CommonJS format output contains Rspack's runtime code. Is it possible to remove the Rspack runtime and only use require() to import other modules

Could you specify what's the purpose of this feature request (bundle size or readability or others)?

fi3ework avatar Jun 16 '25 06:06 fi3ework

Currently, each file in the CommonJS format output contains Rspack's runtime code. Is it possible to remove the Rspack runtime and only use require() to import other modules

Could you specify what's the purpose of this feature request (bundle size or readability or others)?

We're hoping to improve bundle size and readability to make them more developer-friendly. Also, since rslib's primary purpose is for building JavaScript libraries, ​​removing the rspack runtime in CJS format​​ would likely align better with its intended use?

sanfengliao avatar Jul 02 '25 07:07 sanfengliao