|
2 | 2 |
|
3 | 3 | require "active_support/core_ext/string/inflections" |
4 | 4 | require "active_support/core_ext/array/conversions" |
| 5 | +require "zeitwerk" |
5 | 6 |
|
6 | 7 | module Rails |
7 | 8 | class Application |
@@ -39,14 +40,10 @@ module Finisher |
39 | 40 | example = autoloaded.first |
40 | 41 | example_klass = example.constantize.class |
41 | 42 |
|
42 | | - if config.autoloader == :zeitwerk |
43 | | - ActiveSupport::DescendantsTracker.clear |
44 | | - ActiveSupport::Dependencies.clear |
| 43 | + ActiveSupport::DescendantsTracker.clear |
| 44 | + ActiveSupport::Dependencies.clear |
45 | 45 |
|
46 | | - unload_message = "#{these} autoloaded #{constants} #{have} been unloaded." |
47 | | - else |
48 | | - unload_message = "`config.autoloader` is set to `#{config.autoloader}`. #{these} autoloaded #{constants} would have been unloaded if `config.autoloader` had been set to `:zeitwerk`." |
49 | | - end |
| 46 | + unload_message = "#{these} autoloaded #{constants} #{have} been unloaded." |
50 | 47 |
|
51 | 48 | ActiveSupport::Deprecation.warn(<<~WARNING) |
52 | 49 | Initialization autoloaded the #{constants} #{enum}. |
@@ -76,10 +73,8 @@ module Finisher |
76 | 73 | end |
77 | 74 |
|
78 | 75 | initializer :let_zeitwerk_take_over do |
79 | | - if config.autoloader == :zeitwerk |
80 | | - require "active_support/dependencies/zeitwerk_integration" |
81 | | - ActiveSupport::Dependencies::ZeitwerkIntegration.take_over(enable_reloading: !config.cache_classes) |
82 | | - end |
| 76 | + require "active_support/dependencies/zeitwerk_integration" |
| 77 | + ActiveSupport::Dependencies::ZeitwerkIntegration.take_over(enable_reloading: !config.cache_classes) |
83 | 78 | end |
84 | 79 |
|
85 | 80 | # Setup default session store if not already set in config/application.rb |
@@ -113,10 +108,7 @@ module Finisher |
113 | 108 | initializer :eager_load! do |
114 | 109 | if config.eager_load |
115 | 110 | ActiveSupport.run_load_hooks(:before_eager_load, self) |
116 | | - # Checks defined?(Zeitwerk) instead of zeitwerk_enabled? because we |
117 | | - # want to eager load any dependency managed by Zeitwerk regardless of |
118 | | - # the autoloading mode of the application. |
119 | | - Zeitwerk::Loader.eager_load_all if defined?(Zeitwerk) |
| 111 | + Zeitwerk::Loader.eager_load_all |
120 | 112 | config.eager_load_namespaces.each(&:eager_load!) |
121 | 113 | end |
122 | 114 | end |
|
0 commit comments