Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions bazel/ts_project/strict_deps/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ function checkPathsForMatch(moduleSpecifier: string, paths?: ts.MapLike<string[]
return false;
}

/** The list of known package names that end with extensions and need to be special cased. */
const knownModuleSpecifiersWithExtensions = new Set(['highlight.js', 'zone.js']);

for (const fileExecPath of manifest.testFiles) {
const content = await fs.readFile(fileExecPath, 'utf8');
const sf = ts.createSourceFile(fileExecPath, content, ts.ScriptTarget.ESNext, true);
const imports = getImportsInSourceFile(sf);

for (const i of imports) {
const moduleSpecifier =
i.moduleSpecifier === 'zone.js'
? 'zone.js'
: i.moduleSpecifier.replace(extensionRemoveRegex, '');
const moduleSpecifier = knownModuleSpecifiersWithExtensions.has(i.moduleSpecifier)
? i.moduleSpecifier
: i.moduleSpecifier.replace(extensionRemoveRegex, '');
// When the module specified is the file itself this is always a valid dep.
if (i.moduleSpecifier === '') {
continue;
Expand Down