Skip to content

Commit

Permalink
fix: handle missing pnpapi
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Nov 29, 2021
1 parent 88a1059 commit 20ffca2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@ namespace ts.moduleSpecifiers {
if (!parts && typeof process.versions.pnp !== "undefined") {
const {findPnpApi} = require("module");
const pnpApi = findPnpApi(path);
const locator = pnpApi.findPackageLocator(path);
const locator = pnpApi?.findPackageLocator(path);
// eslint-disable-next-line no-null/no-null
if (locator !== 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)
Expand Down

0 comments on commit 20ffca2

Please sign in to comment.