Skip to content

Commit d4985b5

Browse files
justin808claude
andcommitted
Use default loading strategy based on Shakapacker version
The previous fix explicitly set generated_component_packs_loading_strategy to :async, which broke CI for minimum dependencies (Shakapacker 6.0). Root cause: - Commit ee80bc2 changed main bundle to use async: true - Original config had :defer explicitly set, causing race condition - Setting :async explicitly breaks Shakapacker < 8.2.0 Solution: - Remove explicit configuration setting - Let it default based on Shakapacker version: - Shakapacker >= 8.2.0: defaults to :async (optimal) - Shakapacker < 8.2.0: defaults to :sync (compatible) - Update test to check for version-appropriate default This fixes both the original race condition AND maintains compatibility with minimum supported dependencies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent be61ade commit d4985b5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

spec/dummy/config/initializers/react_on_rails.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ def self.adjust_props_for_client_side_hydration(component_name, props)
4242
config.components_subdirectory = "startup"
4343
config.auto_load_bundle = true
4444
config.immediate_hydration = false
45-
config.generated_component_packs_loading_strategy = :async
45+
# Don't explicitly set generated_component_packs_loading_strategy - let it default based on Shakapacker version
46+
# - Shakapacker >= 8.2.0: defaults to :async (optimal performance)
47+
# - Shakapacker < 8.2.0: defaults to :sync (compatibility)
4648
end

spec/dummy/spec/helpers/react_on_rails_helper_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ def self.pro_attribution_comment
7777
allow(helper).to receive(:append_stylesheet_pack_tag)
7878
expect { helper.load_pack_for_generated_component("component_name", render_options) }.not_to raise_error
7979

80-
expect(helper).to have_received(:append_javascript_pack_tag).with("generated/component_name", { defer: true })
80+
# Expect the default loading strategy based on Shakapacker version
81+
if ReactOnRails::PackerUtils.supports_async_loading?
82+
expect(helper).to have_received(:append_javascript_pack_tag).with("generated/component_name",
83+
{ defer: false, async: true })
84+
else
85+
# When async is not supported, defaults to :sync which means { defer: false }
86+
expect(helper).to have_received(:append_javascript_pack_tag).with("generated/component_name", { defer: false })
87+
end
8188
expect(helper).to have_received(:append_stylesheet_pack_tag).with("generated/component_name")
8289
end
8390

0 commit comments

Comments
 (0)