Skip to content

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Nov 26, 2025

Summary

  • Adds comprehensive documentation for migrating from Webpack to Rspack with Shakapacker 9
  • Covers CSS Modules breaking changes, SSR configuration, bundler auto-detection pattern
  • Based on real-world migration experience from react-webpack-rails-tutorial

Closes #1863

Details

The guide covers all known issues from the migration experience:

  • CSS Modules namedExport default change in Shakapacker 9
  • Server bundle CSS extraction filter differences between Webpack and Rspack
  • CSS Modules configuration preservation for SSR
  • Bundler auto-detection pattern for dual Webpack/Rspack support
  • SWC React runtime considerations
  • ReScript module resolution

Test plan

  • Documentation renders correctly in markdown
  • All code examples are syntactically valid
  • Links to external resources are correct

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive migration guide for upgrading from Webpack to Rspack in React on Rails projects using Shakapacker 9. The guide includes step-by-step instructions, configuration adjustments for CSS modules and SSR support, and troubleshooting for common issues.

✏️ Tip: You can customize this high-level summary in your review settings.

Closes #1863

Comprehensive guide documenting all challenges and solutions for
migrating from Webpack to Rspack with Shakapacker 9:

- CSS Modules breaking change (namedExport default)
- Server bundle CSS extraction filter for Rspack
- CSS Modules configuration preservation for SSR
- Bundler auto-detection pattern for dual support
- SWC React runtime considerations
- ReScript module resolution

Based on real-world migration experience from react-webpack-rails-tutorial.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Warning

Rate limit exceeded

@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between cd1bf8c and 2406819.

📒 Files selected for processing (1)
  • docs/migrating/migrating-to-rspack.md (1 hunks)

Walkthrough

This PR adds documentation for migrating from Webpack to Rspack with Shakapacker 9. It includes a reference link in the main README and a comprehensive migration guide covering configuration updates, CSS modules handling, SSR considerations, ReScript-specific fixes, and troubleshooting steps.

Changes

Cohort / File(s) Summary
Documentation Index
docs/README.md
Added bullet point under "Migrating from Other Solutions" linking to the new Rspack migration guide
Migration Guide
docs/migrating/migrating-to-rspack.md
New comprehensive guide for migrating Webpack projects to Rspack, including prerequisites, step-by-step configuration updates, CSS Modules breaking changes, SSR-specific handling, ReScript adjustments, bundler auto-detection patterns, SWC runtime considerations, and troubleshooting section with common issues and solutions

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify migration steps accuracy against Shakapacker 9 and Rspack documentation
  • Review code snippets for correctness (config examples, webpack configuration patterns, CSS loader options)
  • Confirm SSR configuration guidance for CSS extraction and module handling
  • Validate ReScript-specific instructions (resolve.extensions, patch-package approach)
  • Check troubleshooting section for completeness and relevance

Possibly related PRs

Suggested labels

review-needed

Suggested reviewers

  • Romex91
  • alexeyr-ci2

Poem

🐰 A guide hops forth from Webpack's land,
To Rspack's future, swiftly planned!
CSS, SSR, ReScript too,
Migration magic, shiny and new! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding comprehensive Rspack migration documentation for Shakapacker 9.
Linked Issues check ✅ Passed The pull request comprehensively addresses all coding requirements from issue #1863, including CSS Modules breaking changes, server-side CSS handling, ReScript fixes, SWC runtime recommendations, bundler auto-detection patterns, and troubleshooting documentation.
Out of Scope Changes check ✅ Passed The pull request contains only scope-aligned changes: the README was updated with a link to the new migration guide, and the migration guide itself was added with comprehensive coverage of all specified topics.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Nov 26, 2025

Code Review: Rspack Migration Guide

✅ Overall Assessment

This is excellent documentation that provides real-world migration guidance based on actual experience. The guide is well-structured, comprehensive, and addresses critical edge cases that developers will encounter.


📝 Issues Found

1. CRITICAL: Package Manager Inconsistency

The guide uses yarn commands throughout, but this project uses pnpm (see package.json: "packageManager": "[email protected]").

Lines affected:

  • Line 24: yarn add -D @rspack/core
  • Line 217: yarn add -D patch-package postinstall-postinstall

Fix required:

# Change from:
yarn add -D @rspack/core

# To:
pnpm add -D @rspack/core

Per CLAUDE.md: "Only use pnpm as the JS package manager, never npm or yarn"


2. Code Error: Undefined Variable Reference

Line 83: References commonOptions but it's not defined in the code example:

return merge({}, baseWebpackConfig, commonOptions);  // commonOptions is undefined\!

Fix: Either:

  1. Show the commonOptions definition earlier in the example, OR
  2. Remove it from the example if it's not essential to the migration

3. Minor: Inconsistent Code Example Completeness

Lines 61-87: The first commonWebpackConfig example shows a complete function but references undefined variables. This could confuse developers.

Suggestion: Add a comment indicating this is a partial example:

// Partial example - see 'Complete Configuration Example' section for full context
const commonWebpackConfig = () => {
  // ...

🎯 Positive Highlights

  1. Excellent structure - Progressive steps from simple to complex
  2. Real-world grounding - References actual PR (Consider retaining existing prerequisites for assets:precompile #680) for verification
  3. Critical warnings - Properly emphasizes breaking changes with ⚠️ symbols
  4. Troubleshooting section - Addresses common failure modes
  5. Complete examples - Final section shows working configuration
  6. Performance benefits - Sets proper expectations (2-5x improvements)
  7. Both bundlers supported - Auto-detection pattern is elegant

💡 Suggestions for Enhancement (Optional)

  1. Add version compatibility table:

    | Component | Minimum Version | Recommended |
    |-----------|----------------|-------------|
    | Shakapacker | 9.0.0 | 9.3.0+ |
    | Node.js | 18.0 | 22.0+ |
    | @rspack/core | 1.0.0 | Latest |
  2. Add testing verification step:
    After migration, recommend running:

    # Verify SSR still works
    bundle exec rake run_rspec:dummy
    
    # Verify client build works
    pnpm run build
  3. Link to Shakapacker 9 release notes for additional breaking changes users should be aware of


✏️ Required Changes Summary

Must fix before merge:

  1. ✅ Change yarnpnpm (2 locations)
  2. ✅ Fix undefined commonOptions variable (line 83)

Nice to have:
3. 📋 Add partial example disclaimer
4. 📋 Add testing verification step


🔒 Security, Performance, Test Coverage

  • Security: No concerns - documentation only
  • Performance: Guide improves performance (2-5x build times)
  • Test Coverage: N/A - documentation PR
  • Best Practices: Follows React on Rails conventions

Great work on documenting this migration path! This will save developers significant troubleshooting time. 🎉

@claude
Copy link

claude bot commented Nov 26, 2025

Code Review - Rspack Migration Guide

This is an excellent documentation addition that will save developers significant time when migrating to Rspack. The guide is comprehensive, well-structured, and based on real-world experience. Here's my detailed review:


✅ Strengths

1. Outstanding Documentation Quality

  • Clear step-by-step structure that's easy to follow
  • Real code examples with proper context
  • Explains both the "what" and "why" for each issue
  • Based on actual migration experience (react-webpack-rails-tutorial PR Consider retaining existing prerequisites for assets:precompile #680)
  • Excellent troubleshooting section addressing common failure modes

2. Critical Breaking Changes Highlighted

The guide prominently documents the Shakapacker 9 CSS Modules breaking change (namedExport: true default). This is critical and properly emphasized with warning callouts.

3. Complete Configuration Examples

  • Provides both isolated snippets AND complete working examples
  • Shows dual Webpack/Rspack compatibility pattern
  • Includes proper JSDoc comments in code examples

4. Comprehensive Coverage

Addresses all known issues from the migration:

  • CSS Modules configuration (Steps 2-3)
  • Server bundle SSR handling
  • SWC React runtime compatibility
  • ReScript module resolution
  • Bundler auto-detection pattern

5. Excellent Structure

  • Prerequisites clearly stated upfront
  • Steps are logically ordered (dependencies → core issues → edge cases)
  • Troubleshooting section maps symptoms to solutions
  • Links to reference implementations and external resources

📝 Suggestions for Improvement

1. Minor: Package Manager Consistency

The guide uses yarn throughout, but React on Rails uses pnpm (see CLAUDE.md: "Never run npm commands, only equivalent pnpm ones").

Suggested changes:

- yarn add -D @rspack/core
+ pnpm add -D @rspack/core

- yarn add -D patch-package postinstall-postinstall
+ pnpm add -D patch-package postinstall-postinstall

Impact: Low (users will likely use their project's package manager), but consistency with project standards is good.


2. Minor: Trailing Newline Check

Per CLAUDE.md requirements:

ALWAYS ensure files end with a newline character

Verification needed:

# Check if file ends with newline
tail -c 1 docs/migrating/migrating-to-rspack.md | od -An -tx1

Expected: Should show 0a (newline character). If not, the pre-commit hooks should catch this.


3. Optional: Add Version Compatibility Note

Consider adding a compatibility matrix upfront:

## Compatibility Matrix

| Package | Minimum Version | Recommended |
|---------|----------------|-------------|
| Shakapacker | 9.0.0 | 9.3.0+ |
| @rspack/core | 1.0.0 | Latest stable |
| Node.js | 18.x | 22.x |
| React on Rails | 13.0.0 | Latest |

Rationale: Helps users quickly determine if their project is ready for migration.


4. Optional: Add CHANGELOG Entry

Per CLAUDE.md:

Update CHANGELOG.md for user-visible changes only (features, bug fixes, breaking changes, deprecations, performance improvements)

Suggested entry for CHANGELOG.md:

#### Documentation

- [PR 2131](https://github.com/shakacode/react_on_rails/pull/2131) by [justin808](https://github.com/justin808) Add comprehensive Rspack migration guide for Shakapacker 9, covering CSS Modules breaking changes, SSR configuration, and bundler auto-detection patterns.

Impact: Medium - this is a significant documentation addition that helps users, so it deserves a CHANGELOG mention.


🔒 Security Review

No security concerns identified

  • All code examples follow secure patterns
  • No credentials or sensitive data
  • External links are to trusted sources (github.com, rspack.dev)

🧪 Testing Review

Test plan is appropriate

  • Documentation renders correctly
  • Code examples are syntactically valid
  • External links verified

Note: markdown-link-check CI passed successfully.


🎯 Performance Considerations

Performance benefits clearly documented

  • States 2-5x faster development builds
  • States 2-3x faster production builds
  • Sets proper expectations for migration ROI

📊 Overall Assessment

Rating: Excellent (9.5/10)

This documentation will likely prevent hours of debugging for users migrating to Rspack. The guide is thorough, accurate, and based on real-world experience. The minor suggestions above are mostly about consistency with project conventions rather than correctness issues.

Recommended Actions:

  1. Approve and merge - The content is excellent as-is
  2. 🔧 Optional follow-up: Address package manager consistency (yarn → pnpm)
  3. 📝 Optional follow-up: Add CHANGELOG entry for this documentation addition

🙏 Acknowledgment

Excellent work documenting this migration path! This will be an invaluable resource for the community. The level of detail and real-world troubleshooting guidance demonstrates deep understanding of both the tools and the pain points users face.

Closes #1863


Review conducted following React on Rails CLAUDE.md guidelines

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16b3908 and cd1bf8c.

📒 Files selected for processing (2)
  • docs/README.md (1 hunks)
  • docs/migrating/migrating-to-rspack.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

ALWAYS ensure files end with a newline character before committing/pushing

Files:

  • docs/migrating/migrating-to-rspack.md
  • docs/README.md
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T08:05:17.804Z
Learning: Applies to /CHANGELOG.md : Update `/CHANGELOG.md` for user-visible changes (features, bug fixes, breaking changes, deprecations, performance improvements) to the open-source React on Rails gem and npm package
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T08:05:17.804Z
Learning: Applies to /CHANGELOG*.md : Use changelog format: `[PR 1818](https://github.com/shakacode/react_on_rails/pull/1818) by [username](https://github.com/username)` (no hash in PR number)
📚 Learning: 2025-11-25T08:05:17.804Z
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T08:05:17.804Z
Learning: Applies to /CHANGELOG.md : Update `/CHANGELOG.md` for user-visible changes (features, bug fixes, breaking changes, deprecations, performance improvements) to the open-source React on Rails gem and npm package

Applied to files:

  • docs/migrating/migrating-to-rspack.md
  • docs/README.md
📚 Learning: 2025-09-16T08:01:11.146Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1770
File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2
Timestamp: 2025-09-16T08:01:11.146Z
Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules.

Applied to files:

  • docs/migrating/migrating-to-rspack.md
  • docs/README.md
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2
Repo: shakacode/react_on_rails PR: 1732
File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44
Timestamp: 2025-04-26T21:55:55.874Z
Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime.

Applied to files:

  • docs/migrating/migrating-to-rspack.md
  • docs/README.md
📚 Learning: 2025-11-25T08:05:17.804Z
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T08:05:17.804Z
Learning: Applies to lib/react_on_rails/*.rb : Create RBS signature files for new Ruby files in `lib/react_on_rails/` by adding corresponding `.rbs` file in `sig/react_on_rails/`, adding to Steepfile, and validating before committing

Applied to files:

  • docs/migrating/migrating-to-rspack.md
📚 Learning: 2025-02-18T13:08:01.477Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.

Applied to files:

  • docs/migrating/migrating-to-rspack.md
  • docs/README.md
📚 Learning: 2025-11-25T08:05:17.804Z
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T08:05:17.804Z
Learning: The `react_on_rails_pro/` directory has its own Prettier/ESLint configuration and must be linted separately

Applied to files:

  • docs/README.md
🪛 markdownlint-cli2 (0.18.1)
docs/migrating/migrating-to-rspack.md

201-201: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (2)
docs/migrating/migrating-to-rspack.md (1)

377-380: Ensure file ends with newline.

Per coding guidelines, files must end with a newline character. The file currently ends at line 380 without a trailing newline.

docs/README.md (1)

30-30: LGTM!

The new migration guide link is well-placed within the "Migrating from Other Solutions" section and follows the existing formatting conventions. The description clearly indicates the purpose of the guide.

Shakapacker 9.3.1+ supports css_modules_export_mode in shakapacker.yml,
which is simpler than manual webpack configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation: Add guide for migrating to Rspack with Shakapacker 9

2 participants