Related to symfony/symfony#59707
The plan generated by Claude Opus 4.5 after some discussions, and may evolve in the future.
Plan: Experimental Rspack Support in Webpack Encore
Allow users to use rspack as an alternative to webpack via Encore.enableRspack(). Rspack is a webpack-compatible bundler written in Rust, offering significantly better performance.
Phase 1: Base Infrastructure
Phase 2: Public API enableRspack()
Phase 3: Dynamic Bundler CLI Switch
Phase 4: Config Generator Adaptation
Phase 5: Plugin Adaptation
Phase 6: Loader Adaptation
Phase 7: Custom Encore Plugin Adaptation
Phase 8: features.js Update
Phase 9: Tests
Phase 10: Documentation
Out of Scope (v1) / Future Improvements
Identified Risks
| Risk |
Impact |
Mitigation |
copy-files-loader.js uses internal webpack APIs |
🔴 Blocking |
Mandatory rewrite (Phase 6.2) |
| Custom plugins incompatible with rspack hooks |
🟡 Medium |
Manual testing, adapt if needed |
| Third-party loaders not compatible |
🟡 Medium |
Document limitations, suggest alternatives |
friendly-errors-webpack-plugin incompatible |
🟢 Low |
Disabled, rspack has its own reporting |
Resources
Related to symfony/symfony#59707
The plan generated by Claude Opus 4.5 after some discussions, and may evolve in the future.
Plan: Experimental Rspack Support in Webpack Encore
Allow users to use rspack as an alternative to webpack via
Encore.enableRspack(). Rspack is a webpack-compatible bundler written in Rust, offering significantly better performance.Caution
Before starting anything, web-infra-dev/rspack#12682 must be solved.
Phase 1: Base Infrastructure
webpack,webpack-cli,webpack-dev-serveroptional viapeerDependenciesMeta@rspack/core,@rspack/cli,@rspack/dev-serveras optionalpeerDependencieslib/utils/bundler.jsexposing:isWebpackInstalled(): checks ifwebpackandwebpack-cliare presentisRspackInstalled(): checks if@rspack/coreand@rspack/cliare presentgetBundlerModule(): returnsrequire('webpack')orrequire('@rspack/core')based on contextPhase 2: Public API
enableRspack()useRspack = falseflag in WebpackConfig.jsenableRspack()method in WebpackConfig.js:useRspackflag totrue[EXPERIMENTAL] Rspack support is experimental and may not work with all featuresenableRspack()in index.js via the Encore proxyuseRspackis enabled but rspack is not installed, throw explicit error. Same if rspack is enabled but webpack-dev-server is used without @rspack/dev-serverPhase 3: Dynamic Bundler CLI Switch
useRspackwebpack/bin/webpack→@rspack/cliwebpack-dev-server/bin/webpack-dev-server→@rspack/dev-servershowUsageInstructions()to mention rspack if installedPhase 4: Config Generator Adaptation
getBundlerModule()helperDefinePlugin,ProvidePlugin,HotModuleReplacementPluginfromwebpackor@rspack/corePhase 5: Plugin Adaptation
CssExtractRspackPlugin(builtin) if rspack, otherwiseMiniCssExtractPluginSwcJsMinimizerRspackPlugin(builtin) if rspack, otherwiseTerserWebpackPluginLightningCssMinimizerRspackPlugin(builtin) if rspack, otherwiseCssMinimizerPluginDefinePluginfrom the correct moduleProvidePluginfrom the correct modulenull), rspack has its own error reporting system viastatsPhase 6: Loader Adaptation
MiniCssExtractPlugin.loadervs rspack builtin loaderwebpack/lib/dependencies/LoaderDependency(internal API incompatible with rspack). Possible alternatives:rspack.CopyPlugin/copy-webpack-pluginPhase 7: Custom Encore Plugin Adaptation
compiler.hooks.compilationandcompilation.hooks.additionalAssetswith rspackcompiler.hooks.afterEmitcompiler.hooks.emitPhase 8: features.js Update
rspackfeature in features.js with required packages:@rspack/core,@rspack/clirspack-dev-serverfeature with package@rspack/dev-serverPhase 9: Tests
test_apps/rspack/: minimal test application with rspacktest_apps/rspack-with-babel/: test with babel-loaderbundler: [webpack, rspack]Phase 10: Documentation
npm install @rspack/core @rspack/cli @rspack/dev-server --save-devEncore.enableRspack()Out of Scope (v1) / Future Improvements
handlebars-loadersupport with rspack (to be investigated)Encore.disableRspack()method (for override if both bundlers are installed)enableRspack()call)Identified Risks
copy-files-loader.jsuses internal webpack APIsfriendly-errors-webpack-pluginincompatibleResources