Summary
When running rails generate react_on_rails:install --rspack, the generator creates all config files under config/webpack/. However, Shakapacker 9.x expects rspack configs in config/rspack/ and prints a deprecation warning on every build when it falls back to config/webpack/.
Steps to Reproduce
rails new test_app --skip-javascript
cd test_app
# Add react_on_rails and shakapacker to Gemfile
bundle install
git init && git add -A && git commit -m "initial"
rails generate react_on_rails:install --rspack
bin/shakapacker # trigger a build
Expected Behavior
- Generator creates rspack config files in
config/rspack/ (Shakapacker 9.x standard location)
- Builds run cleanly without deprecation warnings
Actual Behavior
Generator creates all configs in config/webpack/. Every build prints:
[Shakapacker] Looking for Rspack config in: config/rspack/rspack.config.ts, config/rspack/rspack.config.js
[Shakapacker] Rspack config not found, checking for webpack config fallback...
[Shakapacker] Checking config/webpack/ for backward compatibility...
⚠️ DEPRECATION WARNING: Found webpack config in config/webpack/ but assets_bundler is set to 'rspack'.
For rspack, configs should be in config/rspack/ directory.
The build succeeds via backward-compat fallback, but the warning appears on every single build.
Root Cause
React on Rails PR #1852 introduced --rspack with a "unified config" approach — all config files go in config/webpack/ regardless of bundler. Meanwhile, Shakapacker moved rspack to a separate directory:
- Shakapacker PR #590 (Sep 2025): Implemented dual bundler architecture with
config/rspack/ as the rspack config location
- Shakapacker PR #594 (Sep 2025): Standardized rspack config to
config/rspack/rspack.config.js
- Shakapacker PR #734 (Oct 2025): Added
config/webpack/ as a deprecated fallback for rspack, with deprecation warning
Shakapacker's configuration.rb explicitly returns different paths per bundler:
# lib/shakapacker/configuration.rb:373-378
def assets_bundler_config_path
custom_path = fetch(:assets_bundler_config_path)
return custom_path if custom_path
rspack? ? "config/rspack" : "config/webpack"
end
Additional Impact
This also affects shakapacker_configured? in install_generator.rb (line 251-255), which hardcodes config/webpack/webpack.config.js:
def shakapacker_configured?
shakapacker_binaries_exist? &&
File.exist?("config/shakapacker.yml") &&
File.exist?("config/webpack/webpack.config.js")
end
If a user installs Shakapacker with rspack before running the React on Rails generator, shakapacker_configured? returns false (because rspack creates config/rspack/rspack.config.js, not config/webpack/webpack.config.js), triggering an unnecessary full Shakapacker reinstall.
Suggested Fix
- When
--rspack is passed, create config files in config/rspack/ instead of config/webpack/
- Update
shakapacker_configured? to check the correct config path based on the bundler setting in config/shakapacker.yml
Environment
- React on Rails: master (16.4.0.rc.1)
- Shakapacker: 9.4.0
- Rails: 8.1.2
Found while investigating #2289.
Summary
When running
rails generate react_on_rails:install --rspack, the generator creates all config files underconfig/webpack/. However, Shakapacker 9.x expects rspack configs inconfig/rspack/and prints a deprecation warning on every build when it falls back toconfig/webpack/.Steps to Reproduce
Expected Behavior
config/rspack/(Shakapacker 9.x standard location)Actual Behavior
Generator creates all configs in
config/webpack/. Every build prints:The build succeeds via backward-compat fallback, but the warning appears on every single build.
Root Cause
React on Rails PR #1852 introduced
--rspackwith a "unified config" approach — all config files go inconfig/webpack/regardless of bundler. Meanwhile, Shakapacker moved rspack to a separate directory:config/rspack/as the rspack config locationconfig/rspack/rspack.config.jsconfig/webpack/as a deprecated fallback for rspack, with deprecation warningShakapacker's
configuration.rbexplicitly returns different paths per bundler:Additional Impact
This also affects
shakapacker_configured?ininstall_generator.rb(line 251-255), which hardcodesconfig/webpack/webpack.config.js:If a user installs Shakapacker with rspack before running the React on Rails generator,
shakapacker_configured?returnsfalse(because rspack createsconfig/rspack/rspack.config.js, notconfig/webpack/webpack.config.js), triggering an unnecessary full Shakapacker reinstall.Suggested Fix
--rspackis passed, create config files inconfig/rspack/instead ofconfig/webpack/shakapacker_configured?to check the correct config path based on the bundler setting inconfig/shakapacker.ymlEnvironment
Found while investigating #2289.