diff --git a/CHANGELOG.md b/CHANGELOG.md index 671df7adc..5cbdd536a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master +* Only compile components at application initialization if eager loading is enabled. + + *Joel Hawksley* + ## 2.20.0 * Don't add `/test/components/previews` to preview_paths if directory doesn't exist. diff --git a/Gemfile.lock b/Gemfile.lock index 08d98d6ea..bd47fac0b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GIT PATH remote: . specs: - view_component (2.19.1) + view_component (2.20.0) activesupport (>= 5.0.0, < 7.0) GEM diff --git a/lib/view_component/engine.rb b/lib/view_component/engine.rb index dd2d05134..e387f5eed 100644 --- a/lib/view_component/engine.rb +++ b/lib/view_component/engine.rb @@ -44,7 +44,7 @@ class Engine < Rails::Engine # :nodoc: initializer "view_component.eager_load_actions" do ActiveSupport.on_load(:after_initialize) do - ViewComponent::Base.descendants.each(&:compile) + ViewComponent::Base.descendants.each(&:compile) if Rails.application.config.eager_load end end