lib/blacklight/engine.rb in blacklight-7.40.0 vs lib/blacklight/engine.rb in blacklight-8.0.0.beta1

- old
+ new

@@ -1,32 +1,13 @@ # frozen_string_literal: true -require 'blacklight/deprecations/engine_configuration' + require 'view_component' module Blacklight class Engine < Rails::Engine engine_name "blacklight" - config.before_configuration do - # see https://github.com/fxn/zeitwerk#for_gem - # Blacklight puts a generator into LOCAL APP lib/generators, so tell - # zeitwerk to ignore the whole directory? If we're using zeitwerk - # - # https://github.com/cbeer/engine_cart/issues/117 - if Rails.try(:autoloaders).try(:main).respond_to?(:ignore) - Rails.autoloaders.main.ignore(Rails.root.join('lib/generators')) - end - end - - # BlacklightHelper is needed by all helpers, so we inject it - # into action view base here. - initializer 'blacklight.helpers' do - config.after_initialize do - ActionView::Base.include BlacklightHelper - end - end - config.after_initialize do Blacklight::Configuration.initialize_default_configuration end # This makes our rake tasks visible. @@ -37,18 +18,24 @@ end end end initializer "blacklight.assets.precompile" do - PRECOMPILE_ASSETS = %w(favicon.ico blacklight/blacklight.js blacklight/blacklight.js.map).freeze + # rubocop:disable Lint/ConstantDefinitionInBlock + PRECOMPILE_ASSETS = %w(favicon.ico blacklight/blacklight.js blacklight/blacklight.js.map blacklight/blacklight.esm.js blacklight/blacklight.esm.js.map).freeze + # rubocop:enable Lint/ConstantDefinitionInBlock # When Rails has been generated in API mode, it does not have sprockets available if Rails.application.config.respond_to?(:assets) Rails.application.config.assets.precompile += PRECOMPILE_ASSETS end end + initializer "blacklight.importmap", before: "importmap" do |app| + app.config.importmap.paths << Engine.root.join("config/importmap.rb") if app.config.respond_to?(:importmap) + end + bl_global_config = OpenStructWithHashAccess.new bl_global_config.sms_mappings = { 'Virgin' => 'vmobl.com', 'AT&T' => 'txt.att.net', @@ -78,12 +65,9 @@ # Anything that goes into Blacklight::Engine.config is stored as a class # variable on Railtie::Configuration. we're going to encapsulate all the # Blacklight specific stuff in this single struct: Blacklight::Engine.config.blacklight = bl_global_config - - # Deprecate top-level access to legacy engine configuration - Blacklight::Deprecations::EngineConfiguration.deprecate_in(Blacklight::Engine.config) config.action_dispatch.rescue_responses["Blacklight::Exceptions::RecordNotFound"] = :not_found end end