From 415a17d8de0b98b17096ec7b80dc234aa7648b97 Mon Sep 17 00:00:00 2001 From: Yathi <511386+yuth@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:02:10 -0800 Subject: [PATCH] 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* --- packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts b/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts index ad15896f072b0..99b8ca286a1e2 100644 --- a/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts +++ b/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts @@ -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`);