ensure parent entrypoint is loaded if direct one is unavailable

This commit is contained in:
Mike Greiling 2018-04-27 17:09:05 -05:00
parent f9e33f43c0
commit b2d90ea1fb
No known key found for this signature in database
GPG key ID: 0303DF507FA67596

View file

@ -15,12 +15,18 @@ module WebpackHelper
end
route = [*controller.controller_path.split('/'), action].compact
entrypoint = "pages.#{route.join('.')}"
begin
chunks = entrypoint_paths(entrypoint, extension: 'js')
rescue Gitlab::Webpack::Manifest::AssetMissingError
# no bundle exists for this path
until chunks.any? || route.empty?
entrypoint = "pages.#{route.join('.')}"
begin
chunks = entrypoint_paths(entrypoint, extension: 'js')
rescue Gitlab::Webpack::Manifest::AssetMissingError
# no bundle exists for this path
end
route.pop
end
if chunks.empty?
chunks = entrypoint_paths("default", extension: 'js')
end