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
This commit is contained in:
Andrew Casey
2020-03-02 16:52:03 -08:00
committed by GitHub
parent 3b996ded9c
commit dd6811fbe3
3 changed files with 11 additions and 4 deletions

View File

@@ -852,4 +852,8 @@ namespace ts {
directory = parentPath;
}
}
export function isNodeModulesDirectory(dirPath: Path) {
return endsWith(dirPath, "/node_modules");
}
}

View File

@@ -428,10 +428,6 @@ namespace ts {
return cache && cache.get(moduleName);
}
function isNodeModulesDirectory(dirPath: Path) {
return endsWith(dirPath, "/node_modules");
}
function isNodeModulesAtTypesDirectory(dirPath: Path) {
return endsWith(dirPath, "/node_modules/@types");
}

View File

@@ -1664,6 +1664,13 @@ namespace ts.server {
const jsconfigFileName = asNormalizedPath(combinePaths(searchPath, "jsconfig.json"));
result = action(jsconfigFileName, combinePaths(canonicalSearchPath, "jsconfig.json"));
if (result) return jsconfigFileName;
// If we started within node_modules, don't look outside node_modules.
// Otherwise, we might pick up a very large project and pull in the world,
// causing an editor delay.
if (isNodeModulesDirectory(canonicalSearchPath)) {
break;
}
}
const parentPath = asNormalizedPath(getDirectoryPath(searchPath));