Add Rspack + RSC compatibility tests and documentation (#1828)#3120
Add Rspack + RSC compatibility tests and documentation (#1828)#3120
Conversation
Addresses #1828. Adds comprehensive generator specs that verify the generated RSC config content is correct for Rspack runtime compatibility: conditionNames, aliases, loader chain handling, bundler-agnostic plugin usage, and three-bundle env var routing. Also adds docs/pro/react-server-components/rspack-compatibility.md with a compatibility matrix, analysis of WebpackPlugin internal API usage, and known limitations. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
WalkthroughAdds a new Pro documentation page describing experimental Rspack compatibility for React on Rails Pro’s React Server Components and extends generator specs with assertions that Rspack-specific RSC config files, bundle naming, loader-chain handling, plugin conditionals, and environment-variable routing are generated. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 244703c842
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review SummaryOverall this is a well-scoped PR — documentation-only plus generator spec additions, no runtime behaviour changed. A few things to address before merging: Must fixWeak alias assertion ( Unverified citation ( Suggestions
Looks good
|
Greptile SummaryThis PR adds a new documentation page ( Confidence Score: 5/5Safe to merge — only documentation and additional generator spec assertions are changed; no production or generator logic is modified. All findings from prior review rounds are resolved. Both changed files are non-production: one is a markdown doc page (all relative links verified to exist), the other is a spec file adding 9 tests inside an existing generator context with a shared before(:all). No P0 or P1 issues remain. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[RSC Generator] --> B{rspack_configured_in_project?}
B -- Yes --> C[Write to config/rspack/]
B -- No --> D[Write to config/webpack/]
C --> E["rscWebpackConfig.js\nconditionNames + react-server alias\nWebpackLoader chain\nserverWebpackConfig(true)"]
C --> F["serverWebpackConfig.js\nrscBundle param\nif(!rscBundle) RSCWebpackPlugin\nLimitChunkCountPlugin"]
C --> G["ServerClientOrBoth.js\nRSC_BUNDLE_ONLY routing\nclientConfig + serverConfig + rscConfig"]
E --> H[rsc-bundle.js\nNo plugin needed]
F --> I[react-client-manifest.json\nreact-ssr-manifest.json]
G --> J[Three-bundle build]
F -.->|Needs Rspack v2 verification| K[RSCWebpackPlugin\nwebpack internal APIs]
Reviews (2): Last reviewed commit: "Address PR review feedback on RSC genera..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb (2)
691-695: Add a negative assertion for plugin omission in the RSC bundle config.This spec currently infers omission via
serverWebpackConfig(true)but never asserts the RSC config itself does not includeRSCWebpackPlugin.Suggested assertion hardening
it "rscWebpackConfig.js passes true to skip RSCWebpackPlugin in RSC bundle" do assert_file "config/rspack/rscWebpackConfig.js" do |content| expect(content).to include("serverWebpackConfig(true)") + expect(content).not_to include("RSCWebpackPlugin") end end🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb` around lines 691 - 695, The test currently only checks for the presence of "serverWebpackConfig(true)" in config/rspack/rscWebpackConfig.js; add a negative assertion to ensure the RSC plugin is omitted by asserting the file content does not include "RSCWebpackPlugin" (e.g. add an expectation like expect(content).not_to include("RSCWebpackPlugin") alongside the existing serverWebpackConfig(true) check in the it block).
679-683: Tighten the alias assertion to verify the compatibility contract.Line 681 only proves
react-dom/serverappears somewhere; it does not verify aliasing tofalse.Suggested assertion hardening
it "rscWebpackConfig.js aliases react-dom/server to false for RSC bundle" do assert_file "config/rspack/rscWebpackConfig.js" do |content| - expect(content).to include("react-dom/server") + expect(content).to match(/react-dom\/server['"]?\s*:\s*false/) end end🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb` around lines 679 - 683, The spec currently only checks that "react-dom/server" appears in config/rspack/rscWebpackConfig.js; tighten it to assert the actual alias mapping to false by asserting the exact alias entry (e.g., the string that represents the alias key/value pair such as '"react-dom/server": false' or equivalent JSON/JS literal) is present so the test verifies the compatibility contract; update the example in the "rscWebpackConfig.js aliases react-dom/server to false for RSC bundle" test in rsc_generator_spec.rb to look for that exact alias token rather than just the module name.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb`:
- Around line 691-695: The test currently only checks for the presence of
"serverWebpackConfig(true)" in config/rspack/rscWebpackConfig.js; add a negative
assertion to ensure the RSC plugin is omitted by asserting the file content does
not include "RSCWebpackPlugin" (e.g. add an expectation like
expect(content).not_to include("RSCWebpackPlugin") alongside the existing
serverWebpackConfig(true) check in the it block).
- Around line 679-683: The spec currently only checks that "react-dom/server"
appears in config/rspack/rscWebpackConfig.js; tighten it to assert the actual
alias mapping to false by asserting the exact alias entry (e.g., the string that
represents the alias key/value pair such as '"react-dom/server": false' or
equivalent JSON/JS literal) is present so the test verifies the compatibility
contract; update the example in the "rscWebpackConfig.js aliases
react-dom/server to false for RSC bundle" test in rsc_generator_spec.rb to look
for that exact alias token rather than just the module name.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5bd52509-d9db-4714-94d1-e97c9153aeb4
📒 Files selected for processing (2)
docs/pro/react-server-components/rspack-compatibility.mdreact_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb
- Tighten react-dom/server alias assertion to verify the `false` value, not just the key name (flagged by 3 reviewers) - Clarify LimitChunkCountPlugin test originates from Pro generator, not the RSC generator - Rename loader-chain test description to accurately reflect what it checks - Add comment explaining intentional overlap with earlier assertion block Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Review feedback addressed in ab3fb6dFixed (4 items):
Skipped (verified):
All 76 RSpec examples pass. All 7 review threads resolved. — I (Claude Code) |
|
To use Codex here, create an environment for this repo. |
Follow-up review (commit ab3fb6d)All four items from the first review are addressed:
One remaining nitThe test at line 694 verifies the skip via an indirect signal ( Documentation
No security, performance, or correctness concerns. Safe to merge as-is. |
| `'use client'` component references during streaming. | ||
|
|
||
| **Rspack v2 compatibility**: Rspack v2 has significantly improved webpack plugin | ||
| compatibility. The [Rspack team has confirmed](https://github.com/shakacode/react_on_rails/issues/1828#issuecomment-3350629010) |
There was a problem hiding this comment.
The link to #issuecomment-3350629010 should be verified before merge. Comment IDs in this range (>3 billion, beyond Int32 max) are unusual and this specific anchor may not resolve. If the comment doesn't exist the documentation makes an unverifiable authoritative claim ("The Rspack team has confirmed") that could mislead users. Please open the URL and confirm it loads the intended comment, or remove the anchor link and just cite the issue.
| # just the key name). The duplication is intentional. | ||
| # See: https://github.com/shakacode/react_on_rails/issues/1828 | ||
|
|
||
| describe "Rspack RSC runtime compatibility" do |
There was a problem hiding this comment.
Nit: the describe name "Rspack RSC runtime compatibility" is misleading — these are generator output tests that assert the content of generated files, not runtime compatibility checks. A name like "Rspack RSC generator output" or "generated Rspack RSC config bundler-agnostic patterns" would more accurately describe what's being tested.
| assert_file "config/rspack/serverWebpackConfig.js" do |content| | ||
| # This content comes from the Pro generator, not the RSC generator. | ||
| # Verified here to ensure the full Rspack server config is bundler-agnostic. | ||
| expect(content).to include("bundler.optimize.LimitChunkCountPlugin") |
There was a problem hiding this comment.
The comment "This content comes from the Pro generator, not the RSC generator" is misleading. In this test context the file is created by the pro_server_webpack_content fixture in generator_spec_helper.rb, not by actually running the Pro generator. The test's real intent is to verify that the RSC generator's modification of serverWebpackConfig.js doesn't accidentally strip the existing bundler.optimize.LimitChunkCountPlugin call — which is a valid regression guard, but the comment obscures that intent. Suggest replacing with something like: # Regression guard: the RSC generator modifies this file (to add rscBundle param + RSCWebpackPlugin) but must preserve the existing LimitChunkCountPlugin call.
| it "rscWebpackConfig.js renames entry to rsc-bundle" do | ||
| assert_file "config/rspack/rscWebpackConfig.js" do |content| | ||
| expect(content).to include("'rsc-bundle'") | ||
| expect(content).to include("rsc-bundle.js") | ||
| end | ||
| end |
There was a problem hiding this comment.
This test asserts two distinct config concerns: the entry key ('rsc-bundle') and the output filename (rsc-bundle.js). These come from separate lines in the generated file (rscConfig.entry assignment and rscConfig.output.filename). Splitting into two focused tests would make failure messages more informative and keep each test at a single concern.
Review: #3120 — Rspack + RSC compatibility tests and documentationLow-risk PR overall. The documentation is clear and the test additions are well-motivated. A few issues worth addressing before merge: CriticalUnverifiable documentation claim (doc line 52) — The link ModerateMisleading comment in test 7 ( Minor
What looks good
|
The test for serverWebpackConfig(true) now also verifies that RSCWebpackPlugin is not instantiated in the RSC config, catching future template drift where the plugin is accidentally added. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Follow-up review feedback addressed in 17708efFixed (1 item):
Skipped (5 items):
All 76 RSpec examples pass. All 8 review threads now resolved. — I (Claude Code) |
…ages * origin/main: Fix initial page startup race for late-loading client bundles (#3151) chore: apply prettier formatting to tracked docs files (#3153) docs: comprehensive RSC API documentation and registration consolidation (#3140) Split rspec-package-tests into parallel generator/unit shards (#3134) fix: add concurrency groups to long-running CI workflows (#3133) refactor: add RenderRequest, JsCodeBuilder, and RenderingStrategy abstractions (#3094) fix: address deferred review items from PR #2849 (#3093) Add complimentary OSS license policy for React on Rails Pro (#3123) fix: centralize CI docs-only detection and add CLI flag validation (#3091) refactor: replace stub-throw + Object.assign with capability-based composition (#3096) Enhance address-review with parallel fixes, self-review, and Greptile verification (#3121) fix: Doctor no longer fails custom projects for missing bin/dev (#3117) fix: cap webpack <5.106.0 to prevent ExecJS SSR breakage (#3095) Add Rspack + RSC compatibility tests and documentation (#1828) (#3120) Add error scenarios hub and test pages (#2497) docs: document polyfill requirements for web-targeted server bundles (#3092) docs: RSC integration pitfalls from tutorial app (#3087) docs: fix render function/helper API documentation (#3088) Doctor: accept TS/TSX server bundle suffixes (#3111) feat: add CI guard requiring sidebar updates when adding docs (#3089)
## Summary Addresses #1828 — researches and documents whether Rspack works with React on Rails Pro's RSC implementation. - Adds 9 new RSpec tests verifying the generated RSC config content is correct for Rspack runtime compatibility (conditionNames, aliases, loader chain, bundler-agnostic plugins, three-bundle routing) - Creates `docs/pro/react-server-components/rspack-compatibility.md` with a compatibility matrix, analysis of `react-server-dom-webpack` internal API usage, and known limitations ### Key Findings | Component | Compatible | Notes | |---|---|---| | RSC bundle config | **Yes** | Skips WebpackPlugin; uses only loader + resolve | | WebpackLoader | **Yes** | Standard loader interface | | conditionNames / aliases | **Yes** | Rspack supports both | | LimitChunkCountPlugin | **Yes** | Bundler-agnostic via `bundler.optimize` variable | | Loader chain (SWC + Babel) | **Yes** | Handles both function and array `rule.use` | | Three-bundle env routing | **Yes** | `RSC_BUNDLE_ONLY` is bundler-agnostic | | **WebpackPlugin** | **Needs verification** | Uses webpack internal APIs (`ModuleDependency`, `AsyncDependenciesBlock`, compiler hooks) | The RSC **bundle** itself should work with Rspack today — it only uses the loader and resolve settings. The `RSCWebpackPlugin` (added to server/client configs for manifest generation) is the one component requiring runtime verification with Rspack v2's compatibility layer. ## Test plan - [x] `bundle exec rspec react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb` — 76 examples, 0 failures - [x] `bundle exec rubocop` passes on changed files - [x] All pre-commit hooks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: changes are limited to documentation and RSpec coverage of generated config output, with no runtime or production code modifications. > > **Overview** > Adds a new Pro RSC doc, `rspack-compatibility.md`, summarizing the current Rspack compatibility status, what parts rely on `react-on-rails-rsc`, and what still needs runtime verification (notably the manifest-generating plugin). > > Expands `rsc_generator_spec.rb` with a dedicated Rspack runtime-compatibility spec block asserting the generated `config/rspack/*` RSC configs use bundler-agnostic patterns (e.g., `conditionNames`, `react-dom/server: false`, loader-chain handling, skipping `RSCWebpackPlugin` for the RSC bundle, and `RSC_BUNDLE_ONLY` routing), and links the new doc into `docs/sidebars.ts`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 17708ef. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added a Pro guide on React Server Components compatibility with Rspack, describing generator integration, three-bundle architecture, environment routing, compatibility notes, testing checklist, and known limitations. * **Tests** * Added specs validating generated Rspack RSC configuration, loader-chain handling, conditional plugin behavior, bundler-agnostic runtime arrangements, and runtime entry/bundle naming outcomes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Summary
Addresses #1828 — researches and documents whether Rspack works with React on Rails Pro's RSC implementation.
docs/pro/react-server-components/rspack-compatibility.mdwith a compatibility matrix, analysis ofreact-server-dom-webpackinternal API usage, and known limitationsKey Findings
bundler.optimizevariablerule.useRSC_BUNDLE_ONLYis bundler-agnosticModuleDependency,AsyncDependenciesBlock, compiler hooks)The RSC bundle itself should work with Rspack today — it only uses the loader and resolve settings. The
RSCWebpackPlugin(added to server/client configs for manifest generation) is the one component requiring runtime verification with Rspack v2's compatibility layer.Test plan
bundle exec rspec react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb— 76 examples, 0 failuresbundle exec rubocoppasses on changed files🤖 Generated with Claude Code
Note
Low Risk
Low risk: changes are limited to documentation and RSpec coverage of generated config output, with no runtime or production code modifications.
Overview
Adds a new Pro RSC doc,
rspack-compatibility.md, summarizing the current Rspack compatibility status, what parts rely onreact-on-rails-rsc, and what still needs runtime verification (notably the manifest-generating plugin).Expands
rsc_generator_spec.rbwith a dedicated Rspack runtime-compatibility spec block asserting the generatedconfig/rspack/*RSC configs use bundler-agnostic patterns (e.g.,conditionNames,react-dom/server: false, loader-chain handling, skippingRSCWebpackPluginfor the RSC bundle, andRSC_BUNDLE_ONLYrouting), and links the new doc intodocs/sidebars.ts.Reviewed by Cursor Bugbot for commit 17708ef. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Documentation
Tests