diff options
author | Andrew Kress <andrew.kress@gmail.com> | 2019-07-25 16:10:59 -0500 |
---|---|---|
committer | Rafael França <rafael@franca.dev> | 2019-07-25 17:10:59 -0400 |
commit | 7f21e04e618513aff1674ed767294a94a903dd51 (patch) | |
tree | 27312a00d0fd9d4e5e84d9ae2a3dbf894f5ca130 /railties | |
parent | bd5edc29709116104345cf09c17f1db89428753e (diff) | |
download | rails-7f21e04e618513aff1674ed767294a94a903dd51.tar.gz rails-7f21e04e618513aff1674ed767294a94a903dd51.tar.bz2 rails-7f21e04e618513aff1674ed767294a94a903dd51.zip |
read configuration to determine excluded eager loaded directory (#36354)
* read config/webpacker.yml to determine which path to exclude for zeitwerk:check
* fix test errors
* more changes to fix test errors
* refactor webpacker_path
[Andrew Kress + Rafael Mendonça França]
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/engine/configuration.rb | 11 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 4143b3c881..612bd170c6 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "rails/railtie/configuration" +require "yaml" module Rails class Engine @@ -40,7 +41,7 @@ module Rails paths.add "app", eager_load: true, glob: "{*,*/concerns}", - exclude: %w(assets javascript) + exclude: ["assets", webpacker_path] paths.add "app/assets", glob: "*" paths.add "app/controllers", eager_load: true paths.add "app/channels", eager_load: true, glob: "**/*_channel.rb" @@ -85,6 +86,14 @@ module Rails def autoload_paths @autoload_paths ||= paths.autoload_paths end + + def webpacker_path + if File.file?("#{Rails.root}/config/webpacker.yml") + YAML.load_file("#{Rails.root}/config/webpacker.yml")[Rails.env]["source_path"]&.gsub("app/", "") + else + "javascript" + end + end end end end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 96678c395c..38dda20bec 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1708,7 +1708,7 @@ module ApplicationTests app "development" ActiveSupport::Dependencies.autoload_paths.each do |path| assert_not_operator path, :ends_with?, "app/assets" - assert_not_operator path, :ends_with?, "app/javascript" + assert_not_operator path, :ends_with?, "app/#{Rails.configuration.webpacker_path}" end end |