Skip to content

Commit 415a17d

Browse files
authored
build: update verify-imports-resolve-same to ignore module extensions (#19096)
verify-imports-resolve-same.ts script validates if the package import for monorepo package imports the same modules, but when validating the imports typescript either would provide .d.ts or .ts or .js file based on how it is imported. Since .ts and .d.ts are typescript artifacts and .js is used at runtime the extension can be safely ignored. The code to ignore the extension was not escaping the `.` char and string replacement was failing because of it. Update the regex to escape `.` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 3fd1511 commit 415a17d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async function compileAndResolve(fileName: string, contents: string, symbolName:
8484
}
8585

8686
// Return the filename
87-
const srcFile = sym.declarations?.[0].getSourceFile().fileName.replace(/.ts|.js|.d.ts/, '');
87+
const srcFile = sym.declarations?.[0].getSourceFile().fileName.replace(/[.](ts|js|d\.ts)$/, '');
8888
if (!srcFile) {
8989
console.log(sym);
9090
throw new Error(`Symbol ${symbolName} in '${contents}' does not resolve to a source location`);

0 commit comments

Comments
 (0)