Skip to content

Generate --rspack configs under config/rspack#2417

Open
justin808 wants to merge 3 commits intomasterfrom
codex/fix-2410-rspack-config-path
Open

Generate --rspack configs under config/rspack#2417
justin808 wants to merge 3 commits intomasterfrom
codex/fix-2410-rspack-config-path

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Feb 15, 2026

Summary

  • For --rspack, generate bundler config files under config/rspack/ instead of config/webpack/
  • Write the main bundler entrypoint as config/rspack/rspack.config.js to match Shakapacker's primary lookup path
  • Update InstallGenerator#shakapacker_configured? to recognize both webpack and rspack config file locations
  • Add generator specs for rspack output paths and rspack config detection

Closes #2410

Test plan

  • Proposed fix (UNTESTED in this environment)
  • Intended: bundle exec rspec react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
  • Blocked by local Ruby version (2.6.10) vs project requirement (>= 3.0.0)

Summary by CodeRabbit

  • New Features

    • Added support for Rspack bundler option and improved bundler-aware config handling and messages.
    • Enhanced detection to recognize multiple bundler config file locations.
  • Tests

    • Expanded test coverage for Rspack setup, config outputs, and bundler-detection scenarios.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

Walkthrough

Adds rspack-aware path resolution and main-config helpers to the generator, routes environment-specific config templates to config/rspack/ when rspack is enabled, and broadens Shakapacker config detection to check both rspack and webpack config file locations.

Changes

Cohort / File(s) Summary
Config Path Resolution
react_on_rails/lib/generators/react_on_rails/base_generator.rb
Adds destination_config_path and bundler_main_config_path helpers; updates webpack/rspack config copy methods and messaging to use these helpers and reflect bundler type.
Config Detection
react_on_rails/lib/generators/react_on_rails/install_generator.rb
Adds shakapacker_config_file_exists? to check multiple Shakapacker config locations (config/webpack/..., config/rspack/...) and replaces prior hard-coded existence checks.
Tests / Spec Updates
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
Updates expectations to assert rspack files are written under config/rspack/, expands tests for shakapacker detection, rspack-specific outputs, and preserved YAML structure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰
A hop, a tweak, a clearer track,
Configs find home — no fallback back.
Rspack in place, paths tidy and bright,
The generator hums through day and night.
🥕✨

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'Generate --rspack configs under config/rspack' directly and clearly summarizes the main change: moving rspack configuration generation to the correct directory structure.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #2410: generates rspack configs in config/rspack/, uses config/rspack/rspack.config.js as main entrypoint, and updates shakapacker_configured? to recognize rspack config paths.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing rspack config path resolution and detection. Changes in base_generator.rb add destination and bundler-aware path helpers; install_generator.rb adds shakapacker config detection; specs validate rspack output paths.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-2410-rspack-config-path

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
react_on_rails/lib/generators/react_on_rails/base_generator.rb (2)

159-183: Variable name webpack_config_path is misleading when rspack is active.

webpack_config_path now holds "config/rspack/rspack.config.js" when --rspack is passed. Consider renaming to something bundler-neutral like main_config_path or bundler_config_path for readability.

Proposed rename
   def copy_webpack_main_config(base_path, config)
-    webpack_config_path = bundler_main_config_path
+    main_config_path = bundler_main_config_path

-    if File.exist?(webpack_config_path)
-      existing_content = File.read(webpack_config_path)
+    if File.exist?(main_config_path)
+      existing_content = File.read(main_config_path)

       if standard_shakapacker_config?(existing_content)
-        remove_file(webpack_config_path, verbose: false)
-        puts "   #{set_color('replace', :green)}  #{webpack_config_path} " \
+        remove_file(main_config_path, verbose: false)
+        puts "   #{set_color('replace', :green)}  #{main_config_path} " \
              "(auto-upgrading from standard Shakapacker to React on Rails config)"
-        template("#{base_path}/config/webpack/webpack.config.js.tt", webpack_config_path, config)
+        template("#{base_path}/config/webpack/webpack.config.js.tt", main_config_path, config)
       elsif react_on_rails_config?(existing_content)
-        puts "   #{set_color('identical', :blue)}  #{webpack_config_path} " \
+        puts "   #{set_color('identical', :blue)}  #{main_config_path} " \
              "(already React on Rails compatible)"
       else
-        handle_custom_webpack_config(base_path, config, webpack_config_path)
+        handle_custom_webpack_config(base_path, config, main_config_path)
       end
     else
-      template("#{base_path}/config/webpack/webpack.config.js.tt", webpack_config_path, config)
+      template("#{base_path}/config/webpack/webpack.config.js.tt", main_config_path, config)
     end
   end

89-91: Nit: stale comment references "webpack.config.js" unconditionally.

When rspack is active, this comment is inaccurate.

Suggested fix
-      # Handle webpack.config.js separately with smart replacement
+      # Handle main bundler config separately with smart replacement
       copy_webpack_main_config(base_path, config)

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.

@greptile-apps
Copy link

greptile-apps bot commented Feb 15, 2026

Greptile Summary

Changes rspack config generation to write files to config/rspack/ instead of config/webpack/, with the main config at config/rspack/rspack.config.js to match Shakapacker's lookup path.

  • Updated base_generator.rb to add helper methods that route rspack configs to the correct directory structure
  • Modified install_generator.rb to recognize both webpack and rspack config file locations when checking if Shakapacker is configured
  • Updated test specs to verify the new output paths and detection logic

The implementation is clean and well-tested with comprehensive spec coverage.

Confidence Score: 5/5

  • Safe to merge - clean implementation with comprehensive test coverage
  • All changes are well-structured, maintain backward compatibility with webpack configs, and include thorough test coverage that validates both the new rspack paths and the config detection logic
  • No files require special attention

Important Files Changed

Filename Overview
react_on_rails/lib/generators/react_on_rails/base_generator.rb Adds destination_config_path and bundler_main_config_path helper methods to dynamically route rspack configs to config/rspack/ directory structure
react_on_rails/lib/generators/react_on_rails/install_generator.rb Adds shakapacker_config_file_exists? method to recognize rspack config file locations in addition to webpack configs
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb Updates test expectations to verify rspack configs are generated in config/rspack/ and adds specs for shakapacker_configured? detection logic

Flowchart

flowchart TD
    A[Generator invoked with --rspack] --> B{options.rspack?}
    B -->|true| C[destination_config_path]
    B -->|false| D[Use original path]
    C --> E[Replace config/webpack/ with config/rspack/]
    E --> F[Generate configs in config/rspack/]
    D --> G[Generate configs in config/webpack/]
    
    F --> H[bundler_main_config_path]
    G --> I[bundler_main_config_path]
    
    H --> J[Returns config/rspack/rspack.config.js]
    I --> K[Returns config/webpack/webpack.config.js]
    
    L[shakapacker_configured? check] --> M[shakapacker_config_file_exists?]
    M --> N{Check multiple paths}
    N --> O[config/webpack/webpack.config.js]
    N --> P[config/rspack/rspack.config.js]
    N --> Q[config/rspack/rspack.config.ts]
    
    O -->|exists| R[Return true]
    P -->|exists| R
    Q -->|exists| R
Loading

Last reviewed commit: 5fd6c80

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

🤖 Fix all issues with AI agents
In `@react_on_rails/lib/generators/react_on_rails/base_generator.rb`:
- Around line 203-206: The warning message currently hardcodes "webpack config"
even when the generator was invoked with --rspack; change the string to use the
active bundler name instead (e.g. determine a bundler_label = options[:rspack] ?
'rspack' : 'webpack' or use the existing bundler option helper if present) and
interpolate that label into the process output where webpack_config_path and the
set_color call are used (update the second puts that contains "without the
environment-specific webpack config"). Ensure you reference the generator option
(--rspack) and the existing symbols webpack_config_path and set_color when
making the change.
🧹 Nitpick comments (1)
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb (1)

507-531: Solid unit tests for shakapacker_configured? detection.

The two scenarios (rspack config present → true, no config → false) correctly verify the new multi-path detection logic. Consider adding a third case verifying config/webpack/webpack.config.js alone also returns true, to ensure the webpack fallback path isn't regressed.

Optional: add webpack-only detection test
it "returns true when only webpack config exists in config/webpack" do
  allow(File).to receive(:exist?).with("config/webpack/webpack.config.js").and_return(true)
  allow(File).to receive(:exist?).with("config/rspack/rspack.config.js").and_return(false)
  allow(File).to receive(:exist?).with("config/rspack/rspack.config.ts").and_return(false)

  expect(install_generator.send(:shakapacker_configured?)).to be true
end

@justin808 justin808 added codex PRs created from codex-named branches release:16.4.0-must-have Must-have for 16.4.0: critical bug/perf/usability labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex PRs created from codex-named branches release:16.4.0-must-have Must-have for 16.4.0: critical bug/perf/usability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator creates rspack configs in deprecated config/webpack/ instead of config/rspack/

1 participant