Generate --rspack configs under config/rspack#2417
Conversation
WalkthroughAdds rspack-aware path resolution and main-config helpers to the generator, routes environment-specific config templates to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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 |
Greptile SummaryChanges rspack config generation to write files to
The implementation is clean and well-tested with comprehensive spec coverage. Confidence Score: 5/5
Important Files Changed
Flowchartflowchart 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
Last reviewed commit: 5fd6c80 |
There was a problem hiding this comment.
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 forshakapacker_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.jsalone also returnstrue, 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
Summary
--rspack, generate bundler config files underconfig/rspack/instead ofconfig/webpack/config/rspack/rspack.config.jsto match Shakapacker's primary lookup pathInstallGenerator#shakapacker_configured?to recognize both webpack and rspack config file locationsCloses #2410
Test plan
bundle exec rspec react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb2.6.10) vs project requirement (>= 3.0.0)Summary by CodeRabbit
New Features
Tests