Skip to content

Commit

Permalink
Fixes issue when importer and importee are the same package
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis committed Jul 21, 2020
1 parent 7f42747 commit 6ce39c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ namespace ts.moduleSpecifiers {
const locator = pnpApi.findPackageLocator(moduleFileName);
// eslint-disable-next-line no-null/no-null
if (locator !== null) {
const sourceLocator = pnpApi.findPackageLocator(`${sourceDirectory}/`);
// Don't use the package name when the imported file is inside
// the source directory (prefer a relative path instead)
if (locator === sourceLocator) {
return undefined;
}
const information = pnpApi.getPackageInformation(locator);
packageName = locator.name;
parts = {
Expand Down

0 comments on commit 6ce39c2

Please sign in to comment.