Skip to content

Commit 6ce39c2

Browse files
committed
Fixes issue when importer and importee are the same package
1 parent 7f42747 commit 6ce39c2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compiler/moduleSpecifiers.ts

+6
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ namespace ts.moduleSpecifiers {
307307
const locator = pnpApi.findPackageLocator(moduleFileName);
308308
// eslint-disable-next-line no-null/no-null
309309
if (locator !== null) {
310+
const sourceLocator = pnpApi.findPackageLocator(`${sourceDirectory}/`);
311+
// Don't use the package name when the imported file is inside
312+
// the source directory (prefer a relative path instead)
313+
if (locator === sourceLocator) {
314+
return undefined;
315+
}
310316
const information = pnpApi.getPackageInformation(locator);
311317
packageName = locator.name;
312318
parts = {

0 commit comments

Comments
 (0)