Skip to content

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

Merged
merged 5 commits into from
Jan 12, 2021

Conversation

andrewbranch
Copy link
Member

Fixes the superfluous import fix suggestions in #40584 and improves the performance of the fixes by ~60%. Additional work is still necessary to improve perf further, but this is a first step that stands on its own.

@@ -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) => {
Copy link
Member

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 ?

Copy link
Member Author

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).

Copy link
Member

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 .

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion: rather than making this pnpm specific, can we ignore any folder starting with .? This way other caches (and .git!) also get skipped?

@andrewbranch
Copy link
Member Author

@weswigham it seems plausible for there to be a user-created hidden directory that should work as expected, but I think anything starting with . inside node_modules/ would be reasonable to ignore. That doesn’t cover .git, though.

@sheetalkamat
Copy link
Member

@andrewbranch we have ignoredPaths that we normally ignore for watching may be that makes good set of paths to ignore

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Jan 5, 2021

@zkochan might want to weigh in here.

@zkochan
Copy link

zkochan commented Jan 5, 2021

LGTM

@weswigham
Copy link
Member

weswigham commented Jan 6, 2021

@weswigham it seems plausible for there to be a user-created hidden directory that should work as expected, but I think anything starting with . inside node_modules/ would be reasonable to ignore. That doesn’t cover .git, though.

I mean, it does if you do git init within your node_modules folder. 😄 But yeah, that's what I meant.

@andrewbranch andrewbranch merged commit 33046e3 into microsoft:master Jan 12, 2021
@andrewbranch andrewbranch deleted the bug/40584 branch January 12, 2021 22:04
@@ -7067,4 +7074,8 @@ namespace ts {
return false;
}
}

export function containsIgnoredPath(path: string) {
return some(ignoredPaths, p => stringContains(path, p));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to look at canonical path? eg. look at isIgnoredPath and isInPath in sys.ts

Copy link
Member Author

Choose a reason for hiding this comment

The 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 containsNodeModulesPathPart check without calling getCanonicalFileName or anything.

Zzzen pushed a commit to Zzzen/TypeScript that referenced this pull request Jan 16, 2021
…icrosoft#42095)

* Create symlink cache when a pnpm module is found

* Keep pnpm-internal symlinks out of the symlink cache

* Filter out  pnpm path from realpath module specifier too

* Use ignoredPaths instead of pnpm-specific path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants