TreeShakingSharedPlugin
Stability: Experimental
Overview
- Performs on-demand build and export optimization for
shareddependencies based on Module Federation configuration.
Options
mfConfig:ModuleFederationPluginOptions, configuration passed to the Module Federation plugin.plugins: extra plugins reused during independent builds.secondary: whether to perform a second tree-shake during independent builds (typically used when the deployment platform has determined complete dependency info and triggers a fresh build to improve tree-shake accuracy for shared dependencies).
Usage
rspack.config.mjs
Behavior
- Normalizes
sharedinto[shareName, SharedConfig][]. - Registers
SharedUsedExportsOptimizerPluginwhensecondaryisfalseto inject used-exports from the stats manifest. - Triggers independent compilation for shared entries with
tree shaking: true, and writes the produced assets back to thestats/manifest(fallback fields).

