Commit 614ef82b authored by Rémy Coutable's avatar Rémy Coutable

Eager-load CE files first

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 3383cf0a
......@@ -59,10 +59,4 @@ module Issuable
end
end
# In the case we are eager-loading, `ee/app/services/ee/issuable/clone/base_service.rb`
# is loaded first, and explicitely requires this file to avoid a
# "TypeError: superclass must be a Class (Module given)" error.
# That also means that we cannot perform the prepending in this file otherwise
# we'd get a circular dependency error, thus we perform the prepending in
# `ee/app/services/ee/issuable/clone/base_service.rb` in that case.
Issuable::Clone::BaseService.prepend(EE::Issuable::Clone::BaseService) unless Rails.configuration.eager_load
Issuable::Clone::BaseService.prepend(EE::Issuable::Clone::BaseService)
......@@ -54,11 +54,14 @@ module Gitlab
ee_path = config.root.join('ee', Pathname.new(path).relative_path_from(config.root))
memo << ee_path.to_s if ee_path.exist?
end
config.eager_load_paths.unshift(*ee_paths)
# Eager load should load CE first
config.eager_load_paths.push(*ee_paths)
config.helpers_paths.push "#{config.root}/ee/app/helpers"
# Other than Ruby modules we load EE first
config.paths['lib/tasks'].unshift "#{config.root}/ee/lib/tasks"
config.paths['app/views'].unshift "#{config.root}/ee/app/views"
config.helpers_paths.unshift "#{config.root}/ee/app/helpers"
## EE-specific paths config END
# Rake tasks ignore the eager loading settings, so we need to set the
......
# frozen_string_literal: true
# When this file is eager-loaded **before `issuable/clone/base_service.rb`**, the
# `Issuable::Clone::BaseService` constant is defined (in this file) as a module,
# making subsequent inheritance from `::Issuable::Clone::BaseService` (e.g. in
# `EE::IssuePromoteService`) failing with a "TypeError: superclass must be a
# Class (Module given)" error.
# Explicitely requiring `issuable/clone/base_service.rb` makes sure that the
# correct `::Issuable::Clone::BaseService` constant is defined first.
require_dependency 'issuable/clone/base_service' if Rails.configuration.eager_load
module EE
module Issuable
module Clone
......@@ -29,10 +20,3 @@ module EE
end
end
end
# When this file is eager-loaded, since we explicitely require
# `issuable/clone/base_service.rb` above, we cannot perform the prepend in
# `issuable/clone/base_service.rb` otherwise we'd get a circular dependency
# error. Thus we perform the prepend in this file, after
# `Issuable::Clone::BaseService` and `EE::Issuable::Clone::BaseService` are defined.
Issuable::Clone::BaseService.prepend(EE::Issuable::Clone::BaseService) if Rails.configuration.eager_load
......@@ -18,5 +18,3 @@ module EE
end
end
end
ExpirePipelineCacheWorker.prepend(EE::ExpirePipelineCacheWorker)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment