Rspack support#186
Conversation
|
|
@alexeagle We're looking into Rspack as an alternative to Webpack under Bazel. What do you think of something like this? |
b72b65b to
8549558
Compare
cf22960 to
d2e9889
Compare
…logic
The worker script hardcoded `require('webpack-cli')`, so rspack targets
with `supports_workers = True` silently ran webpack instead of rspack.
Extract the shared worker logic into bundler_worker.js with thin entry
points for each bundler. The Bazel macro copies the appropriate entry
point based on the `bundler` attribute. Also regenerate the expected
rspack worker test output for rspack 1.6.4.


Adds Rspack as an alternative bundler for
webpack_bundleandwebpack_devserver, addressing #159.A new
bundlerparameter ("webpack"or"rspack", default"webpack") controls which bundler is used. When set to"rspack", the rules use@rspack/coreand@rspack/cliinstead ofwebpackandwebpack-cli, via a newrspack_binarymacro that mirrors the existingwebpack_binary.Config merging:
Rspack CLI doesn't support
--merge, so when a customwebpack_configis provided it replaces the generated base config entirely. Without a custom config the generated base config is used as-is. This is documented in thebundlerparam docstrings and the README.Performance:
Rspack's Rust-based architecture provides significant speedups over webpack. In published benchmarks rspack is 4-6x faster for production builds and up to 15x+ faster for dev startup on larger projects. In a real-world production web application (~10k modules with SWC loaders, CSS extraction, and code splitting), we measured approximately 2.3x (dev) and 3.2x (prod) end-to-end Bazel build speedup.
Changes are visible to end-users: yes
Test plan
webpack/tests/simple: rspack with custom config and with generated configwebpack/tests/devtool-override: rspack with devtool overridewebpack/tests/worker: rspack with workers enabledwebpack/tests/devserver: rspack devserver targete2e/smoke: rspack end-to-end smoke test with production-mode output comparison