Skip to content

Commit

Permalink
Merge pull request #509 from github/eager-load-compile
Browse files Browse the repository at this point in the history
Eager load compile
  • Loading branch information
joelhawksley authored Oct 23, 2020
2 parents 57dc526 + bd128b6 commit 0fb9daa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0fb9daa

Please sign in to comment.