Skip to content

Commit

Permalink
fix prod
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellhenke committed Jan 4, 2024
1 parent ba7e2db commit 9f746c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/view_component/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,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
Expand Down
8 changes: 6 additions & 2 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9f746c2

Please sign in to comment.