Skip to content

Commit 3bdbb18

Browse files
hanslmatsko
authored andcommitted
build: update rollup lint rule from bad merge (angular#20047)
PR Close angular#20047
1 parent 13f8648 commit 3bdbb18

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

tools/tslint/rollupConfigRule.ts

+25-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const sourceFilePathBlacklist = [
3434
// exceptions but we simply ignore those files from this rule.
3535
/[/\\]packages[/\\]language-service[/\\]/,
3636

37+
// Compiler CLI is never part of a browser (there's a browser-rollup but it's managed
38+
// separately.
39+
/[/\\]packages[/\\]compiler-cli[/\\]/,
40+
3741
// service-worker is a special package that has more than one rollup config. It confuses
3842
// this lint rule and we simply ignore those files.
3943
/[/\\]packages[/\\]service-worker[/\\]/,
@@ -61,11 +65,26 @@ function _pathShouldBeLinted(path: string) {
6165
}
6266

6367

68+
/**
69+
* .--. _________________
70+
* {\ / q {\ / globalGlobalMap /
71+
* { `\ \ (-(~` <__________________/
72+
* { '.{`\ \ \ )
73+
* {'-{ ' \ .-""'-. \ \
74+
* {._{'.' \/ '.) \
75+
* {_.{. {` |
76+
* {._{ ' { ;'-=-. |
77+
* {-.{.' { ';-=-.` /
78+
* {._.{.; '-=- .'
79+
* {_.-' `'.__ _,-'
80+
* |||`
81+
* .='==,
82+
*/
6483
interface RollupMatchInfo {
6584
filePath: string;
6685
globals: {[packageName: string]: string};
6786
}
68-
const rollupConfigMap = new Map<string, RollupMatchInfo>();
87+
const globalGlobalRollupMap = new Map<string, RollupMatchInfo>();
6988

7089

7190
export class Rule extends AbstractRule {
@@ -85,22 +104,22 @@ export class Rule extends AbstractRule {
85104
let match: RollupMatchInfo;
86105

87106
while (p.startsWith(process.cwd())) {
88-
if (rollupConfigMap.has(p)) {
107+
if (globalGlobalRollupMap.has(p)) {
89108
// We already resolved for this directory, just return it.
90-
match = rollupConfigMap.get(p);
109+
match = globalGlobalRollupMap.get(p);
91110
break;
92111
}
93112

94113
const allFiles = fs.readdirSync(p);
95114
const maybeRollupPath = allFiles.find(x => _isRollupPath(path.join(p, x)));
96115
if (maybeRollupPath) {
97116
const rollupFilePath = path.join(p, maybeRollupPath);
98-
const rollupConfig = require(rollupFilePath).default;
117+
const rollupConfig = require(rollupFilePath);
99118
match = {filePath: rollupFilePath, globals: rollupConfig && rollupConfig.globals};
100119

101120
// Update all paths that we checked along the way.
102-
checkedPaths.forEach(path => rollupConfigMap.set(path, match));
103-
rollupConfigMap.set(rollupFilePath, match);
121+
checkedPaths.forEach(path => globalGlobalRollupMap.set(path, match));
122+
globalGlobalRollupMap.set(rollupFilePath, match);
104123
break;
105124
}
106125

0 commit comments

Comments
 (0)