Skip to content

Commit f023328

Browse files
devversionjelbourn
authored andcommitted
build: resolve module names in circular deps test (#18957)
Currently the circular dependencies test only resolves relative imports. It does not resolve module names to packages/entry-points which are part of the Angular Components repository. To ensure that such repo-specific module names are resolved, we add a custom module resolver. This helps us making the circular deps test future-proof in case an entry-point uses module names. Within an entry-point circular dependencies could be also created with module name imports. (cherry picked from commit 2fce0c6)
1 parent 0a8aee8 commit f023328

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/circular-deps-test.conf.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,27 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8+
9+
const path = require('path');
10+
811
module.exports = {
912
baseDir: '../',
1013
goldenFile: '../goldens/ts-circular-deps.json',
11-
// The test should not capture deprecated packages such as `http`, or the `webworker` platform.
1214
glob: `./**/*.ts`,
1315
// Command that will be displayed if the golden needs to be updated.
1416
approveCommand: 'yarn ts-circular-deps:approve',
15-
resolveModule: () => {}
17+
resolveModule,
1618
};
19+
20+
/**
21+
* Custom module resolver that maps specifiers starting with `@angular/` to the
22+
* local packages folder. This ensures that imports using the module name can be
23+
* resolved. Cross entry-point/package circular dependencies are already be detected
24+
* by Bazel, but in rare cases, the module name is used for imports within entry-points.
25+
*/
26+
function resolveModule(specifier) {
27+
if (specifier.startsWith('@angular/')) {
28+
return path.join(__dirname, specifier.substr('@angular/'.length));
29+
}
30+
return null;
31+
}

0 commit comments

Comments
 (0)