From 033fdeec0040f59e6d2e4e89c7bf059ce5da0e94 Mon Sep 17 00:00:00 2001 From: Mario Sanchez Prada Date: Fri, 11 Sep 2020 12:39:56 +0200 Subject: [PATCH] Drop support for nonGeneratedFiles from brave_rollup_overrides.js This made sense when Chromium's //c/b/resources/tools/rollup_plugin.js considered that source JS files could come from both the sources and the generated directories, but this is no longer the case as all those JS files are under /ui/webui/resources/webui_preprocessed now, so we need to update Brave's code to adapt to this new scenario. Chromium change: https://chromium.googlesource.com/chromium/src/+/efc282784459e1ec69a524d901d8694cce5230c5 commit efc282784459e1ec69a524d901d8694cce5230c5 Author: rbpotter Date: Tue Sep 1 04:37:15 2020 +0000 Web UI: Add preprocessed resources and use in rollup Preprocess all shared JS module resources into: /ui/webui/resources/webui_preprocessed and read all these resources from this directory when bundling with rollup. Bug: 1071641 --- .../chrome-browser-resources-tools-rollup_plugin.js.patch | 4 ++-- ui/webui/resources/tools/brave_rollup_overrides.js | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/patches/chrome-browser-resources-tools-rollup_plugin.js.patch b/patches/chrome-browser-resources-tools-rollup_plugin.js.patch index 2d3d71c74c3..a2abd33fae4 100644 --- a/patches/chrome-browser-resources-tools-rollup_plugin.js.patch +++ b/patches/chrome-browser-resources-tools-rollup_plugin.js.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/resources/tools/rollup_plugin.js b/chrome/browser/resources/tools/rollup_plugin.js -index b541233a644bc428257dafcea7198d2d4a529d98..2ac54a0c01a953fd8d83a3a7cb94db410ff4899d 100644 +index b541233a644bc428257dafcea7198d2d4a529d98..793639a113a26f5488279f76c748cf197ee88aa2 100644 --- a/chrome/browser/resources/tools/rollup_plugin.js +++ b/chrome/browser/resources/tools/rollup_plugin.js @@ -71,6 +71,8 @@ export default function plugin(srcPath, genPath, rootPath, host, excludes) { return joinPaths(polymerSrcPath, pathFromPolymer); } -+ const resolvedByBrave = require(path.join(__dirname, '..', '..', 'brave_rollup_overrides')).braveResolveId({srcPath, genPath, excludes}, source, origin, relativePath, joinPaths, combinePaths, chromeResourcesUrl, schemeRelativeResourcesUrl, nonGeneratedFiles); if (resolvedByBrave) { return resolvedByBrave; } ++ const resolvedByBrave = require(path.join(__dirname, '..', '..', 'brave_rollup_overrides')).braveResolveId({srcPath, genPath, excludes}, source, origin, relativePath, joinPaths, combinePaths, chromeResourcesUrl, schemeRelativeResourcesUrl); if (resolvedByBrave) { return resolvedByBrave; } + // Get path from ui/webui/resources let pathFromResources = ''; diff --git a/ui/webui/resources/tools/brave_rollup_overrides.js b/ui/webui/resources/tools/brave_rollup_overrides.js index 9af881406d4..9905c36877a 100644 --- a/ui/webui/resources/tools/brave_rollup_overrides.js +++ b/ui/webui/resources/tools/brave_rollup_overrides.js @@ -1,7 +1,7 @@ const path = require('path'); module.exports = { - braveResolveId: function (params, source, origin, relativePath, joinPaths, combinePaths, chromeResourcesUrl, schemeRelativeResourcesUrl, nonGeneratedFiles) { + braveResolveId: function (params, source, origin, relativePath, joinPaths, combinePaths, chromeResourcesUrl, schemeRelativeResourcesUrl) { const {srcPath, genPath, excludes} = params; const resourcesSrcPath = joinPaths(srcPath, 'ui/webui/resources/'); const resourcesGenPath = joinPaths(genPath, 'ui/webui/resources/'); @@ -32,10 +32,6 @@ module.exports = { if (excludes.includes(fullPath)) { return {id: fullPath, external: true}; } - const filename = path.basename(source); - if (nonGeneratedFiles.includes(filename)) { - return joinPaths(resourcesSrcPath, pathFromBraveResources); - } // JS compiled into gen directory if (pathFromBraveResources.endsWith('.js')) { return joinPaths(braveResourcesGenPath, pathFromBraveResources);