Skip to content

Commit dd6811f

Browse files
authored
Stop looking for the default configured project at node_modules (#35011)
* Optionally stop looking for the default configured project at node_modules * Make stopping at node_modules non-optional * Generalize and simplify the change - node_modules files don't have default configured projects
1 parent 3b996de commit dd6811f

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/compiler/path.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,4 +852,8 @@ namespace ts {
852852
directory = parentPath;
853853
}
854854
}
855+
856+
export function isNodeModulesDirectory(dirPath: Path) {
857+
return endsWith(dirPath, "/node_modules");
858+
}
855859
}

src/compiler/resolutionCache.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,6 @@ namespace ts {
428428
return cache && cache.get(moduleName);
429429
}
430430

431-
function isNodeModulesDirectory(dirPath: Path) {
432-
return endsWith(dirPath, "/node_modules");
433-
}
434-
435431
function isNodeModulesAtTypesDirectory(dirPath: Path) {
436432
return endsWith(dirPath, "/node_modules/@types");
437433
}

src/server/editorServices.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,13 @@ namespace ts.server {
16641664
const jsconfigFileName = asNormalizedPath(combinePaths(searchPath, "jsconfig.json"));
16651665
result = action(jsconfigFileName, combinePaths(canonicalSearchPath, "jsconfig.json"));
16661666
if (result) return jsconfigFileName;
1667+
1668+
// If we started within node_modules, don't look outside node_modules.
1669+
// Otherwise, we might pick up a very large project and pull in the world,
1670+
// causing an editor delay.
1671+
if (isNodeModulesDirectory(canonicalSearchPath)) {
1672+
break;
1673+
}
16671674
}
16681675

16691676
const parentPath = asNormalizedPath(getDirectoryPath(searchPath));

0 commit comments

Comments
 (0)