Skip to content

Commit 5c1fb74

Browse files
committed
Add detailed explanation of React on Rails 16 breaking change
Clarifies that this configuration is a workaround for a regression introduced in React on Rails v16 where the error handling fallback mechanism was removed. In v14.2.1, when server bundle lookup failed, it would gracefully fallback to the Shakapacker output path. This robust error handling was removed in v16.0.1.rc.2 causing the test environment to look in the wrong directory. The configuration explicitly tells React on Rails where to find bundles in test environment since the automatic fallback no longer exists.
1 parent ff96f20 commit 5c1fb74

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

config/initializers/react_on_rails.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
# not affect performance.
1515
config.server_bundle_js_file = "server-bundle.js"
1616

17-
# React on Rails 16 compatibility: Override generated_assets_dir for test environment
18-
# This ensures React on Rails looks in the correct Shakapacker output directory
17+
# React on Rails 16 compatibility: Workaround for removed error handling
18+
#
19+
# BREAKING CHANGE in v16: React on Rails 14.2.1 had robust error handling that would
20+
# fallback to the Shakapacker output path when bundle lookup failed. This was removed
21+
# in v16.0.1.rc.2, causing it to look in the wrong directory during tests.
22+
#
23+
# This configuration tells React on Rails where to find bundles in test environment.
24+
# Without this, it defaults to public/webpack/test/ instead of public/packs/
1925
if Rails.env.test?
2026
config.generated_assets_dir = File.join(Rails.root, "public", "packs")
2127
end

0 commit comments

Comments
 (0)