Skip to content

Commit faabbf8

Browse files
committed
Adds proper package name inference
1 parent a890fa0 commit faabbf8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/moduleSpecifiers.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ namespace ts.moduleSpecifiers {
321321
// Get a path that's relative to node_modules or the importing file's path
322322
// if node_modules folder is in this folder or any of its parent folders, no need to keep it.
323323
const pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
324-
if (!(startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
324+
// If PnP is enabled the node_modules entries we'll get will always be relevant even if they
325+
// are located in a weird path apparently outside of the source directory
326+
if (!process.versions.pnp && !(startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
325327
return undefined;
326328
}
327329

0 commit comments

Comments
 (0)