Skip to content

Commit 3af06df

Browse files
committed
Fixes issue when importer and importee are the same package
1 parent 0b42da4 commit 3af06df

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compiler/moduleSpecifiers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ namespace ts.moduleSpecifiers {
332332
const locator = pnpApi.findPackageLocator(moduleFileName);
333333
// eslint-disable-next-line no-null/no-null
334334
if (locator !== null) {
335+
const sourceLocator = pnpApi.findPackageLocator(`${sourceDirectory}/`);
336+
// Don't use the package name when the imported file is inside
337+
// the source directory (prefer a relative path instead)
338+
if (locator === sourceLocator) {
339+
return undefined;
340+
}
335341
const information = pnpApi.getPackageInformation(locator);
336342
packageName = locator.name;
337343
parts = {

0 commit comments

Comments
 (0)