From 3bdbb18c8bb897cb135a807d21c50ccee67dd40a Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Mon, 30 Oct 2017 20:42:20 -0700 Subject: [PATCH] build: update rollup lint rule from bad merge (#20047) PR Close #20047 --- tools/tslint/rollupConfigRule.ts | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tools/tslint/rollupConfigRule.ts b/tools/tslint/rollupConfigRule.ts index 46d279b1bc..19157b2a1f 100644 --- a/tools/tslint/rollupConfigRule.ts +++ b/tools/tslint/rollupConfigRule.ts @@ -34,6 +34,10 @@ const sourceFilePathBlacklist = [ // exceptions but we simply ignore those files from this rule. /[/\\]packages[/\\]language-service[/\\]/, + // Compiler CLI is never part of a browser (there's a browser-rollup but it's managed + // separately. + /[/\\]packages[/\\]compiler-cli[/\\]/, + // service-worker is a special package that has more than one rollup config. It confuses // this lint rule and we simply ignore those files. /[/\\]packages[/\\]service-worker[/\\]/, @@ -61,11 +65,26 @@ function _pathShouldBeLinted(path: string) { } +/** + * .--. _________________ + * {\ / q {\ / globalGlobalMap / + * { `\ \ (-(~` <__________________/ + * { '.{`\ \ \ ) + * {'-{ ' \ .-""'-. \ \ + * {._{'.' \/ '.) \ + * {_.{. {` | + * {._{ ' { ;'-=-. | + * {-.{.' { ';-=-.` / + * {._.{.; '-=- .' + * {_.-' `'.__ _,-' + * |||` + * .='==, + */ interface RollupMatchInfo { filePath: string; globals: {[packageName: string]: string}; } -const rollupConfigMap = new Map(); +const globalGlobalRollupMap = new Map(); export class Rule extends AbstractRule { @@ -85,9 +104,9 @@ export class Rule extends AbstractRule { let match: RollupMatchInfo; while (p.startsWith(process.cwd())) { - if (rollupConfigMap.has(p)) { + if (globalGlobalRollupMap.has(p)) { // We already resolved for this directory, just return it. - match = rollupConfigMap.get(p); + match = globalGlobalRollupMap.get(p); break; } @@ -95,12 +114,12 @@ export class Rule extends AbstractRule { const maybeRollupPath = allFiles.find(x => _isRollupPath(path.join(p, x))); if (maybeRollupPath) { const rollupFilePath = path.join(p, maybeRollupPath); - const rollupConfig = require(rollupFilePath).default; + const rollupConfig = require(rollupFilePath); match = {filePath: rollupFilePath, globals: rollupConfig && rollupConfig.globals}; // Update all paths that we checked along the way. - checkedPaths.forEach(path => rollupConfigMap.set(path, match)); - rollupConfigMap.set(rollupFilePath, match); + checkedPaths.forEach(path => globalGlobalRollupMap.set(path, match)); + globalGlobalRollupMap.set(rollupFilePath, match); break; }