Rspack provides experimental EsmLibraryPlugin plugin, provides statically analyzable, cleaner output for ESM library, and also supports code splitting.
EsmLibraryPlugin
🚧 This plugin is still work-in-progress, config may change at anytime.
import { rspack } from '@rspack/core'; export default { plugins: [new rspack.experiments.EsmLibraryPlugin()], optimization: { runtimeChunk: true, // recommended to enable runtime chunk, otherwise consumers need to import runtime code from entry }, };