diff --git a/lib/react_on_rails/helper.rb b/lib/react_on_rails/helper.rb index 3a6245fdc8..f3876445c2 100644 --- a/lib/react_on_rails/helper.rb +++ b/lib/react_on_rails/helper.rb @@ -93,27 +93,6 @@ def react_component(component_name, options = {}) end end - def load_pack_for_component(component_name) - is_component_pack_present = File.exist?(generated_components_pack_path(component_name)) - is_development = ENV["RAILS_ENV"] == "development" - - if is_development && !is_component_pack_present - ReactOnRails::PacksGenerator.generate - raise_missing_pack_error(component_name) - end - - ReactOnRails::PacksGenerator.raise_nested_entries_disabled unless ReactOnRails::WebpackerUtils.nested_entries? - - append_javascript_pack_tag "generated/#{component_name}" - append_stylesheet_pack_tag "generated/#{component_name}" - end - - def generated_components_pack_path(component_name) - extension = PacksGenerator::GENERATED_PACK_EXTENSION - - "#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}.#{extension}" - end - # react_component_hash is used to return multiple HTML strings for server rendering, such as for # adding meta-tags to a page. # It is exactly like react_component except for the following: @@ -340,6 +319,27 @@ def rails_context(server_side: true) private + def load_pack_for_component(component_name) + is_component_pack_present = File.exist?(generated_components_pack_path(component_name)) + is_development = ENV["RAILS_ENV"] == "development" + + if is_development && !is_component_pack_present + ReactOnRails::PacksGenerator.generate + raise_missing_pack_error(component_name) + end + + ReactOnRails::PacksGenerator.raise_nested_entries_disabled unless ReactOnRails::WebpackerUtils.nested_entries? + + append_javascript_pack_tag "generated/#{component_name}" + append_stylesheet_pack_tag "generated/#{component_name}" + end + + def generated_components_pack_path(component_name) + extension = PacksGenerator::GENERATED_PACK_EXTENSION + + "#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}.#{extension}" + end + def build_react_component_result_for_server_rendered_string( server_rendered_html: required("server_rendered_html"), component_specification_tag: required("component_specification_tag"),