From 038e77fff1a9f830c64382fcf3c6186e03e7e8ee Mon Sep 17 00:00:00 2001 From: Mitchell Henke Date: Sat, 11 Nov 2023 16:04:42 -0600 Subject: [PATCH] fix prod --- lib/view_component/base.rb | 2 +- lib/view_component/engine.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index 4e5a251dd..c7c137da9 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -509,7 +509,7 @@ def short_identifier def inherited(child) # Compile so child will inherit compiled `call_*` template methods that # `compile` defines - compile + compile(frozen_string_literal: ViewComponent::Base.config.frozen_string_literal) # Give the child its own personal #render_template_for to protect against the case when # eager loading is disabled and the parent component is rendered before the child. In diff --git a/lib/view_component/engine.rb b/lib/view_component/engine.rb index efbd63852..7653624b8 100644 --- a/lib/view_component/engine.rb +++ b/lib/view_component/engine.rb @@ -74,9 +74,13 @@ class Engine < Rails::Engine # :nodoc: end end - initializer "view_component.eager_load_actions" do + initializer "view_component.eager_load_actions" do |app| ActiveSupport.on_load(:after_initialize) do - ViewComponent::Base.descendants.each(&:compile) if Rails.application.config.eager_load + if Rails.application.config.eager_load + ViewComponent::Base.descendants.each do |descendant| + descendant.compile(frozen_string_literal: app.config.view_component.frozen_string_literal) + end + end end end