Skip to content

Commit

Permalink
build: update verify-imports-resolve-same script to ignore module ext…
Browse files Browse the repository at this point in the history
…ensions

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 `.`
  • Loading branch information
yuth committed Feb 22, 2022
1 parent 3fd1511 commit ab908c2
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -84,7 +84,7 @@ async function compileAndResolve(fileName: string, contents: string, symbolName:
}

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

0 comments on commit ab908c2

Please sign in to comment.