-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Tweak module resolution failed lookup watching #53591
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
Conversation
6e32417
to
0e3a48d
Compare
9d88990
to
73ddbad
Compare
…g "/" even from os root directory
…ive of allowJs files
73ddbad
to
71ff774
Compare
@@ -205,6 +206,30 @@ export function removeIgnoredPath(path: Path): Path | undefined { | |||
path; | |||
} | |||
|
|||
function perceivedOsRootLengthForWatching(pathComponents: Readonly<PathPathComponents>, length: number) { |
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 logic is same as before except it returns number of components that are roots for watching. Like c:\users\someUserName
or in case of linux /anything/anything
etc. So we would never watch anything in those directories.
if (length === undefined) length = pathComponents.length; | ||
// Ignore "/", "c:/" | ||
// ignore "/user", "c:/users" or "c:/folderAtRoot" | ||
if (length <= 2) return false; |
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 is just fast fail as root would alreast be 1
dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator), | ||
dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator) as Path | ||
}; | ||
return getDirectoryOfFailedLookupWatch(failedLookupComponents, failedLookupPathComponents, Math.max(rootPathComponents.length + 1, perceivedOsRootLength + 1)); |
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 helps with not watching "/users" when "/" is root directory (math.max part)
Truthfully I'm a little out of my element in trying to review this; is this something I could just build locally and try the |
Yes . This should fix npm ci on our repo |
@typescript-bot pack this |
Heya @sheetalkamat, I've started to run the tarball bundle task on this PR at 5b0cbcc. You can monitor the build here. |
Hey @sheetalkamat, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
It seems like it works, but, testing TS at nightly and stable, I can't actually get the bad behavior on |
If we don't have a repro for Typescript itself, is this still needed? From the description it sounds like the new way is strictly better even if it doesn't unblock us personally. |
Oh, I don't have a problem with taking this of course, I'm just annoyed that I seemingly forgot what it was I was doing that this fixed |
@jakebailey i think it will repro if you host typescript at |
Oh, huh. I've never checked out TS at that level before, so, would this not apply to the issue that I was having with But, trying it out at that level, and it definitely breaks before and works afterward. So, it's definitely an improvement! |
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.
Behavior wise this seems good to me; I gave the code a few looks over and didn't see anything particularly off but I'm also not an expert so I'm letting tests guide me 😄
Andrew may have a better idea about this bit.
@andrewbranch do you mind taking a look at this so i can get this in. |
Merging for now and will fix feedback from @andrewbranch in another PR so its in nightly and can make it into beta. |
This simplifies unnecessary extension watching from long ago when we had different resolutions based on .ts and .js files
Before we would never watch directories like
c:/typescript/node_modules
or/user/username/typescript/node_modules
because we didnt watch folders likec:/typescript
or/user/username/typescript
. Now changed to watch node_modules in root folder. (We wont watch it at root unless tsconfig is at the root)This should help with some of the npm ci issues in repo encountered if typescript repo was at root or in another folder .