Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ GEM
matrix (0.4.3)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (6.0.4)
minitest (6.0.5)
drb (~> 2.0)
prism (~> 1.5)
minitest-mock (5.27.0)
Expand Down Expand Up @@ -525,7 +525,7 @@ CHECKSUMS
matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b
method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef
minitest (6.0.4) sha256=df1304664589d40f46089247fdc451f866b0ce0d7cae1457a15fc1eb7d48dca1
minitest (6.0.5) sha256=f007d7246bf4feea549502842cd7c6aba8851cdc9c90ba06de9c476c0d01155c
minitest-mock (5.27.0) sha256=7040ed7185417a966920987eaa6eaf1be4ea1fc5b25bb03ff4703f98564a55b0
net-imap (0.6.2) sha256=08caacad486853c61676cca0c0c47df93db02abc4a8239a8b67eb0981428acc6
net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3
Expand Down
6 changes: 5 additions & 1 deletion lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ class Engine < Rails::Engine # :nodoc:
ActiveSupport.on_load(:after_initialize) do
if Rails.application.config.eager_load
ActiveSupport::Notifications.instrument("compile.view_component") do
ViewComponent::Base.descendants.each(&:__vc_compile)
ViewComponent::Base.descendants.each do |component|
next if component.anonymous?

component.__vc_compile
end
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion test/sandbox/test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def test_inherited_component_with_call_method_does_not_recompile_superclass
assert_select "div", "hello world"
assert_response :success

compile_method_lines = UncompilableComponent.method(:__vc_compile).source.split("\n")
original_method = UncompilableComponent.method(:__vc_compile)
compile_method_lines = original_method.source.split("\n")
compile_method_lines.insert(1, 'raise "this should not happen" if self.name == "UncompilableComponent"')
UncompilableComponent.instance_eval compile_method_lines.join("\n")

Expand All @@ -123,6 +124,9 @@ def test_inherited_component_with_call_method_does_not_recompile_superclass
get "/inherited_from_uncompilable_component"
assert_select "div", "hello world"
assert_response :success
ensure
UncompilableComponent.singleton_class.silence_redefinition_of_method(:__vc_compile)
UncompilableComponent.define_singleton_method(:__vc_compile, original_method)
end
end

Expand Down
Loading