Skip to content

Rspack support#186

Open
ngranander wants to merge 4 commits into
aspect-build:mainfrom
ngranander:rspack
Open

Rspack support#186
ngranander wants to merge 4 commits into
aspect-build:mainfrom
ngranander:rspack

Conversation

@ngranander
Copy link
Copy Markdown

Adds Rspack as an alternative bundler for webpack_bundle and webpack_devserver, addressing #159.

A new bundler parameter ("webpack" or "rspack", default "webpack") controls which bundler is used. When set to "rspack", the rules use @rspack/core and @rspack/cli instead of webpack and webpack-cli, via a new rspack_binary macro that mirrors the existing webpack_binary.

Config merging:
Rspack CLI doesn't support --merge, so when a custom webpack_config is provided it replaces the generated base config entirely. Without a custom config the generated base config is used as-is. This is documented in the bundler param 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

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

New: webpack_bundle and webpack_devserver now support Rspack as a drop-in alternative bundler. Set bundler = "rspack" and ensure @rspack/core and @rspack/cli are linked in your node_modules. See the README for details.

Test plan

  • Covered by existing test cases
  • New test cases added
    • webpack/tests/simple: rspack with custom config and with generated config
    • webpack/tests/devtool-override: rspack with devtool override
    • webpack/tests/worker: rspack with workers enabled
    • webpack/tests/devserver: rspack devserver target
    • e2e/smoke: rspack end-to-end smoke test with production-mode output comparison

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 16, 2026

CLA assistant check
All committers have signed the CLA.

@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Apr 16, 2026

Bazel 7 (Test)

19 test targets passed

Targets
//.github/workflows:bazel7.update_test [k8-fastbuild]                          92ms
//docs:update_test [k8-fastbuild]                                              21ms
//tools:preset.update_test [k8-fastbuild]                                      140ms
//webpack/tests/create_configs:tests_0_test [k8-fastbuild]                     96ms
//webpack/tests/create_configs:tests_1_test [k8-fastbuild]                     164ms
//webpack/tests/create_configs:tests_2_test [k8-fastbuild]                     95ms
//webpack/tests/create_configs:tests_3_test [k8-fastbuild]                     60ms
//webpack/tests/create_configs:tests_4_test [k8-fastbuild]                     60ms
//webpack/tests/devtool-override:rspack_bundle_matches_expected [k8-fastbuild] 86ms
//webpack/tests/devtool-override:write_bundle_test [k8-fastbuild]              85ms
//webpack/tests/devtool-override:write_rspack_bundle_test [k8-fastbuild]       74ms
//webpack/tests/simple:bundle_no_execroot_entry_point_matches [k8-fastbuild]   111ms
//webpack/tests/simple:entries_match [k8-fastbuild]                            133ms
//webpack/tests/simple:rspack_bundle_matches_expected [k8-fastbuild]           71ms
//webpack/tests/simple:write_bundle_test [k8-fastbuild]                        96ms
//webpack/tests/simple:write_rspack_bundle_test [k8-fastbuild]                 72ms
//webpack/tests/worker:rspack_bundle_matches_expected [k8-fastbuild]           59ms
//webpack/tests/worker:write_bundle_test [k8-fastbuild]                        100ms
//webpack/tests/worker:write_rspack_bundle_test [k8-fastbuild]                 91ms

Bazel 8 (Test)

All tests were cache hits

16 tests (100.0%) were fully cached saving 2s.


Bazel 9 (Test)

All tests were cache hits

16 tests (100.0%) were fully cached saving 2s.


Bazel 7 (Test)

e2e/loaders

1 test target passed

Targets
//:test [k8-fastbuild]                                                         19ms

Bazel 8 (Test)

e2e/loaders

All tests were cache hits

1 test (100.0%) was fully cached saving 36ms.


Bazel 9 (Test)

e2e/loaders

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/loaders_jslib

1 test target passed

Targets
//:test [k8-fastbuild]                                                         19ms

Bazel 8 (Test)

e2e/loaders_jslib

All tests were cache hits

1 test (100.0%) was fully cached saving 62ms.


Bazel 9 (Test)

e2e/loaders_jslib

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel 7 (Test)

e2e/smoke

3 test targets passed

Targets
//src:bundles_0_test [k8-fastbuild]                                            20ms
//src:bundles_1_test [k8-fastbuild]                                            19ms
//src:bundles_2_test [k8-fastbuild]                                            46ms

Bazel 8 (Test)

e2e/smoke

All tests were cache hits

3 tests (100.0%) were fully cached saving 98ms.


Bazel 9 (Test)

e2e/smoke

All tests were cache hits

3 tests (100.0%) were fully cached saving 150ms.


Bazel 7 (Test)

e2e/worker

2 test targets passed

Targets
//:bundles_match [k8-fastbuild]                                                23ms
//:write_bundle_test [k8-fastbuild]                                            27ms

Bazel 8 (Test)

e2e/worker

All tests were cache hits

2 tests (100.0%) were fully cached saving 64ms.


Bazel 9 (Test)

e2e/worker

All tests were cache hits

2 tests (100.0%) were fully cached saving 67ms.


Buildifier

@ngranander ngranander marked this pull request as ready for review April 27, 2026 08:44
@ngranander
Copy link
Copy Markdown
Author

@alexeagle We're looking into Rspack as an alternative to Webpack under Bazel. What do you think of something like this?

@ngranander ngranander force-pushed the rspack branch 2 times, most recently from b72b65b to 8549558 Compare May 7, 2026 13:35
@ngranander ngranander force-pushed the rspack branch 2 times, most recently from cf22960 to d2e9889 Compare May 12, 2026 14:08
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants