lib/action_view/component/railtie.rb in actionview-component-1.6.1 vs lib/action_view/component/railtie.rb in actionview-component-1.6.2

- old
+ new

@@ -1,8 +1,9 @@ # frozen_string_literal: true require "rails" +require "action_view/component" module ActionView module Component class Railtie < Rails::Railtie # :nodoc: config.action_view_component = ActiveSupport::OrderedOptions.new @@ -23,14 +24,21 @@ initializer "action_view_component.set_autoload_paths" do |app| require "railties/lib/rails/components_controller" require "railties/lib/rails/component_examples_controller" - app.config.eager_load_namespaces << ActionView::Component::Base options = app.config.action_view_component if options.show_previews && options.preview_path ActiveSupport::Dependencies.autoload_paths << options.preview_path + end + end + + initializer "action_view_component.eager_load_actions" do + ActiveSupport.on_load(:after_initialize) do + ActionView::Component::Base.descendants.each do |descendant| + descendant.compile if descendant.has_initializer? && config.eager_load + end end end initializer "action_view_component.compile_config_methods" do ActiveSupport.on_load(:action_view_component) do