Uh oh!
There was an error while loading. Please reload this page.
Skip resolving files directly inside node_modules - #52809
Conversation
or in @types. Although the node module resolution algorithm looks for .js files there, they would never be there in correctly configured node_modules. So it should be safe to skip *.ts, *.js, *.tsx, etc. Also skips looking for files directly in node_modules/@types. Fixesmicrosoft#52695
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Andrew Branch (andrewbranch)
commented
Feb 16, 2023
It would also be good to add a test that uses tsconfig |
| function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, moduleName: string, nodeModulesDirectory: string, nodeModulesDirectoryExists: boolean, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): Resolved | undefined { | ||
| const candidate = normalizePath(combinePaths(nodeModulesDirectory, moduleName)); | ||
| if (moduleName.indexOf(":") > -1) { | ||
| if (state.traceEnabled) { |
There was a problem hiding this comment.
I think you want this if nodeModulesDirectoryExists
There was a problem hiding this comment.
Or skip if onlyRecordFailures
TypeScript Bot (@typescript-bot) test this |
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the diff-based user code test suite on this PR at b279732. You can monitor the build here. Update: The results are in! |
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the extended test suite on this PR at b279732. You can monitor the build here. |
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the abridged perf test suite on this PR at b279732. You can monitor the build here. Update: The results are in! |
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the diff-based top-repos suite on this PR at b279732. You can monitor the build here. Update: The results are in! |
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the parallelized Definitely Typed test suite on this PR at b279732. You can monitor the build here. |
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the diff-based user code test suite (tsserver) on this PR at b279732. You can monitor the build here. Update: The results are in! |
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here are the results of running the user test suite comparing Something interesting changed - please have a look. Detailswebpack
|
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here are the results of running the user test suite comparing Everything looks good! |
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Heya Daniel Rosenwasser (@DanielRosenwasser), I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here they are:Comparison Report - main..52809
System
Hosts
Scenarios
Developer Information: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here are the results of running the top-repos suite comparing Everything looks good! |
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here are the results of running the top-repos suite comparing Something interesting changed - please have a look. Detailsangular/angular-cli
|
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here are some more interesting changes from running the top-repos suite Detailshasura/graphql-engine
|
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here are some more interesting changes from running the top-repos suite Detailsnuxt/nuxt
|
TypeScript Bot (typescript-bot)
commented
Feb 16, 2023
Daniel Rosenwasser (@DanielRosenwasser) Here are some more interesting changes from running the top-repos suite Detailsslidevjs/slidev
|
Based on PR feedbac
Andrew Branch (@andrewbranch) I moved the node:stuff skip to tryResolve, although you should take another look because I'm not sure I put it in the right place there. |
Andrew Branch (andrewbranch)
left a comment
There was a problem hiding this comment.
Looks good, but since I didn’t understand Sheetal Nandi (@sheetalkamat)’s response to my suggestion that you’ve implemented, you might want to wait for a review from her in case I missed something.
Wesley Wigham (weswigham)
commented
Feb 17, 2023
You're absolutely right that npm will never install anything that puts loose files in the |
Like, it's not frequent, but you can definitelyfindprojects that make use of this old cjs resolution pattern on github (usually on the older side, ofc). (Though you have to be sneaky about how you find 'em, like looking for config files that include them - you can't use |
Andrew Branch (andrewbranch)
commented
Feb 17, 2023
It doesn’t feel outlandish for us to say that this pattern is not recommended, but if you rely on it, simply add an entry to |
I'm not opposed to that - but also
I thought we already did this. #35286 |
Wesley Wigham (weswigham)
commented
Feb 17, 2023
Daniel Rosenwasser (@DanielRosenwasser) that just made our directory iterator much more efficient (so it didn't use any extra stat calls) - it didn't swap us to using that directory iterator to prefill file existence cache entries in the module name resolver. |
We cache |
Heya Gabriela Araujo Britto (@gabritto), I've started to run the parallelized Definitely Typed test suite on this PR at 6bf4384. You can monitor the build here. |
Sheetal Nandi (sheetalkamat)
left a comment
There was a problem hiding this comment.
I think we should add test where "node_modules/a.d,ts" can be resolved with path mapping so we know what to suggest to user as a work aorund
Uh oh!
There was an error while loading. Please reload this page.
| @@ -1,26 +0,0 @@ | |||
| // @module: commonjs | |||
There was a problem hiding this comment.
Why are we deleting this test case
There was a problem hiding this comment.
I think I deleted it by mistake instead of fixing the direct node_modules path. I restored it, although github now thinks every line changed -- maybe line endings?
First test shows that no files are resolved in node_modules itself. Second test shows that a successful resolution skips node_modules but successfully resolves anyway.
Uh oh!
There was an error while loading. Please reload this page.
Although the node module resolution algorithm looks for .js files there, they would never be there in correctly configured node_modules. So it should be safe to skip *.ts, *.js, *.tsx, etc.
Fixes#52695