Do not clear deprecated initializer dependencies if using classic autoloader
`Rails::Application::Finisher` defines a `:let_zeitwerk_take_over` initializer. This initializer is always run but it's statements are wrapped in a guard: `config.autoloader == :zeitwerk`. `Finisher` also defines a `initializer :warn_if_autoloaded` initializer with a `before: :let_zeitwerk_take_over` option which also always runs. This initializer unloads any constants autoloaded during initialization and displays a deprecation warning. This initializer does not account for `config.autoloader` being set to `:classic`. The problem is that this initializer changes the behavior of the classic autoloader. Constant autoloading from initializers is deprecated but the deprecation should not break existing applications which currently depend on autoloaded constants in initializers. This commit prevents the dependencies from being unloaded if the autoloader is not Zeitwerk. It also updates the deprecation warning, if the classic autoloader is enabled, to indicate that the constants would have been unloaded if Zeitwerk had been used.
Showing
想要评论请 注册 或 登录