Skip to content

Commit 02a81b7

Browse files
committed
Cancels the isExternalLibraryImport changes - side effects on emits
1 parent 16e6ce0 commit 02a81b7

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

src/compiler/moduleNameResolver.ts

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,19 +1005,13 @@ namespace ts {
10051005
}
10061006

10071007
let resolvedValue = resolved.value;
1008-
1009-
const isExternalLibraryImport = resolvedValue && isPnpAvailable()
1010-
? checkPnpExternalLibraryImport(resolvedValue)
1011-
: true;
1012-
1013-
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
10141008
if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
10151009
const path = realPath(resolvedValue.path, host, traceEnabled);
10161010
const originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
10171011
resolvedValue = { ...resolvedValue, path, originalPath };
10181012
}
1019-
1020-
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport } };
1013+
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
1014+
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
10211015
}
10221016
else {
10231017
const { path: candidate, parts } = normalizePathAndParts(combinePaths(containingDirectory, moduleName));
@@ -1596,13 +1590,7 @@ namespace ts {
15961590
}
15971591

15981592
function getPnpApi() {
1599-
return require("pnpapi") as {
1600-
findPackageLocator: (path: string) => ({name: string, reference: string}) | null,
1601-
resolveToUnqualified: (request: string, issuer: string, opts: {considerBuiltins: boolean}) => string,
1602-
getLocator: (name: string, reference: string) => ({name: string, reference: string}),
1603-
getPackageInformation: (locator: {name: string, reference: string}) => any,
1604-
getDependencyTreeRoots: () => any[],
1605-
};
1593+
return require("pnpapi");
16061594
}
16071595

16081596
function loadPnpPackageResolution(packageName: string, containingDirectory: string) {
@@ -1643,22 +1631,8 @@ namespace ts {
16431631
}
16441632
}
16451633

1646-
return toSearchResult(resolved);
1647-
}
1648-
1649-
function checkPnpExternalLibraryImport(resolvedValue: Resolved) {
1650-
const pnpApi = getPnpApi();
1651-
1652-
const ownerPackage = pnpApi.findPackageLocator(resolvedValue.path);
1653-
if (!ownerPackage) {
1654-
return true;
1634+
if (resolved) {
1635+
return toSearchResult(resolved);
16551636
}
1656-
1657-
const rootLocators = pnpApi.getDependencyTreeRoots();
1658-
1659-
// External if none of the root locators owns the file
1660-
return !rootLocators.some(root => {
1661-
return root.name === ownerPackage.name && root.reference === ownerPackage.reference;
1662-
});
16631637
}
16641638
}

0 commit comments

Comments
 (0)