Skip to content

Commit

Permalink
Avoid recalculating versionPaths in loadNodeModuleFromDirectory (#27537)
Browse files Browse the repository at this point in the history
* Avoid recalculating versionPaths in loadNodeModuleFromDirectory

* Update baselines
  • Loading branch information
Andy Hanson authored and RyanCavanaugh committed Apr 25, 2019
1 parent 6e4c150 commit aafba36
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion src/compiler/moduleNameResolver.ts
Expand Up @@ -1106,7 +1106,7 @@ namespace ts {
const packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
const packageId = packageInfo && packageInfo.packageId;
const packageJsonContent = packageInfo && packageInfo.packageJsonContent;
const versionPaths = packageJsonContent && readPackageJsonTypesVersionPaths(packageJsonContent, state);
const versionPaths = packageInfo && packageInfo.versionPaths;
return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
}

Expand Down
2 changes: 0 additions & 2 deletions tests/baselines/reference/library-reference-10.trace.json
Expand Up @@ -4,7 +4,6 @@
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at './types/jquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'.",
Expand All @@ -14,7 +13,6 @@
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at './types/jquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'.",
Expand Down
2 changes: 0 additions & 2 deletions tests/baselines/reference/library-reference-2.trace.json
Expand Up @@ -5,7 +5,6 @@
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' does not have a 'typings' field.",
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
Expand All @@ -17,7 +16,6 @@
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' does not have a 'typings' field.",
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
Expand Down
Expand Up @@ -12,7 +12,6 @@
"'package.json' does not have a 'main' field.",
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
"Found 'package.json' at '/a/package.json'.",
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
"'package.json' does not have a 'typings' field.",
"'package.json' does not have a 'types' field.",
"'package.json' does not have a 'main' field.",
Expand Down
Expand Up @@ -6,7 +6,6 @@
"'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.",
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
"Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'. Package ID is 'ext/ndex/index.d.ts@1.0.0'.",
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
"'package.json' does not have a 'typings' field.",
"'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.",
"'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.",
Expand Down
4 changes: 0 additions & 4 deletions tests/baselines/reference/typingsLookup4.trace.json
Expand Up @@ -72,7 +72,6 @@
"'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at '/node_modules/@types/jquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.",
"File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'.",
Expand All @@ -82,7 +81,6 @@
"'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at '/node_modules/@types/kquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.",
"File '/node_modules/@types/kquery/kquery' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/@types/kquery/kquery', target file type 'TypeScript'.",
Expand All @@ -96,7 +94,6 @@
"'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at '/node_modules/@types/lquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.",
"File '/node_modules/@types/lquery/lquery' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/@types/lquery/lquery', target file type 'TypeScript'.",
Expand All @@ -108,7 +105,6 @@
"'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.",
"'package.json' does not have a 'typesVersions' field.",
"Found 'package.json' at '/node_modules/@types/mquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.",
"File '/node_modules/@types/mquery/mquery' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/@types/mquery/mquery', target file type 'TypeScript'.",
Expand Down

0 comments on commit aafba36

Please sign in to comment.