-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Do not suggest paths inside node_modules/.pnpm as module specifiers #42095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5abd462
406cb4e
a02a2e7
1780acf
d3e67b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6104,7 +6104,14 @@ namespace ts { | |
getSymlinkedFiles: () => symlinkedFiles, | ||
getSymlinkedDirectories: () => symlinkedDirectories, | ||
setSymlinkedFile: (path, real) => (symlinkedFiles || (symlinkedFiles = new Map())).set(path, real), | ||
setSymlinkedDirectory: (path, directory) => (symlinkedDirectories || (symlinkedDirectories = new Map())).set(path, directory), | ||
setSymlinkedDirectory: (path, directory) => { | ||
// Large, interconnected dependency graphs in pnpm will have a huge number of symlinks | ||
// where both the realpath and the symlink path are inside node_modules/.pnpm. Since | ||
// this path is never a candidate for a module specifier, we can ignore it entirely. | ||
if (!containsIgnoredPath(path)) { | ||
(symlinkedDirectories || (symlinkedDirectories = new Map())).set(path, directory); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
|
@@ -7067,4 +7074,8 @@ namespace ts { | |
return false; | ||
} | ||
} | ||
|
||
export function containsIgnoredPath(path: string) { | ||
return some(ignoredPaths, p => stringContains(path, p)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to look at canonical path? eg. look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did look at that, but I noticed that where this is used, we were already doing a |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @Filename: /tsconfig.json | ||
//// { "compilerOptions": { "module": "commonjs" } } | ||
|
||
// @Filename: /node_modules/.pnpm/[email protected]/node_modules/mobx/package.json | ||
//// { "types": "dist/mobx.d.ts" } | ||
|
||
// @Filename: /node_modules/.pnpm/[email protected]/node_modules/mobx/dist/mobx.d.ts | ||
//// export declare function autorun(): void; | ||
|
||
// @Filename: /index.ts | ||
//// autorun/**/ | ||
|
||
// @Filename: /utils.ts | ||
//// import "mobx"; | ||
|
||
// @link: /node_modules/.pnpm/[email protected]/node_modules/mobx -> /node_modules/mobx | ||
// @link: /node_modules/.pnpm/[email protected]/node_modules/mobx -> /node_modules/.pnpm/[email protected]/node_modules/mobx | ||
|
||
goTo.marker(""); | ||
verify.importFixAtPosition([`import { autorun } from "mobx"; | ||
|
||
autorun`]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be handled when it is used for module specifier resolution instead of in general in my opinion since we still want to resolve the cache for answering if file is from referenced project for project construction ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something inside
node_modules/.pnpm/
should never be a project reference redirect, which seems to be the only reason beside module specifier resolution that this is used (fileOrDirectoryExistsUsingSource
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right because it would resolve completely to actual path even if equivalent of npm link kind of thing is used .