Skip to content

Commit aafba36

Browse files
Andy HansonRyanCavanaugh
Andy Hanson
authored andcommitted
Avoid recalculating versionPaths in loadNodeModuleFromDirectory (microsoft#27537)
* Avoid recalculating versionPaths in loadNodeModuleFromDirectory * Update baselines
1 parent 6e4c150 commit aafba36

6 files changed

+1
-11
lines changed

src/compiler/moduleNameResolver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ namespace ts {
11061106
const packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
11071107
const packageId = packageInfo && packageInfo.packageId;
11081108
const packageJsonContent = packageInfo && packageInfo.packageJsonContent;
1109-
const versionPaths = packageJsonContent && readPackageJsonTypesVersionPaths(packageJsonContent, state);
1109+
const versionPaths = packageInfo && packageInfo.versionPaths;
11101110
return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
11111111
}
11121112

tests/baselines/reference/library-reference-10.trace.json

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
55
"'package.json' does not have a 'typesVersions' field.",
66
"Found 'package.json' at './types/jquery/package.json'.",
7-
"'package.json' does not have a 'typesVersions' field.",
87
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
98
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
109
"Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'.",
@@ -14,7 +13,6 @@
1413
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
1514
"'package.json' does not have a 'typesVersions' field.",
1615
"Found 'package.json' at './types/jquery/package.json'.",
17-
"'package.json' does not have a 'typesVersions' field.",
1816
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
1917
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
2018
"Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'.",

tests/baselines/reference/library-reference-2.trace.json

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
66
"'package.json' does not have a 'typesVersions' field.",
77
"Found 'package.json' at '/types/jquery/package.json'.",
8-
"'package.json' does not have a 'typesVersions' field.",
98
"'package.json' does not have a 'typings' field.",
109
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
1110
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
@@ -17,7 +16,6 @@
1716
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
1817
"'package.json' does not have a 'typesVersions' field.",
1918
"Found 'package.json' at '/types/jquery/package.json'.",
20-
"'package.json' does not have a 'typesVersions' field.",
2119
"'package.json' does not have a 'typings' field.",
2220
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
2321
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",

tests/baselines/reference/typesVersions.justIndex.trace.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"'package.json' does not have a 'main' field.",
1313
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
1414
"Found 'package.json' at '/a/package.json'.",
15-
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
1615
"'package.json' does not have a 'typings' field.",
1716
"'package.json' does not have a 'types' field.",
1817
"'package.json' does not have a 'main' field.",

tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.",
77
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
88
"Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'. Package ID is 'ext/ndex/index.d.ts@1.0.0'.",
9-
"'package.json' has a 'typesVersions' field with version-specific path mappings.",
109
"'package.json' does not have a 'typings' field.",
1110
"'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.",
1211
"'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'.",

tests/baselines/reference/typingsLookup4.trace.json

-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.",
7373
"'package.json' does not have a 'typesVersions' field.",
7474
"Found 'package.json' at '/node_modules/@types/jquery/package.json'.",
75-
"'package.json' does not have a 'typesVersions' field.",
7675
"'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.",
7776
"File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
7877
"Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'.",
@@ -82,7 +81,6 @@
8281
"'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.",
8382
"'package.json' does not have a 'typesVersions' field.",
8483
"Found 'package.json' at '/node_modules/@types/kquery/package.json'.",
85-
"'package.json' does not have a 'typesVersions' field.",
8684
"'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.",
8785
"File '/node_modules/@types/kquery/kquery' does not exist.",
8886
"Loading module as file / folder, candidate module location '/node_modules/@types/kquery/kquery', target file type 'TypeScript'.",
@@ -96,7 +94,6 @@
9694
"'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.",
9795
"'package.json' does not have a 'typesVersions' field.",
9896
"Found 'package.json' at '/node_modules/@types/lquery/package.json'.",
99-
"'package.json' does not have a 'typesVersions' field.",
10097
"'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.",
10198
"File '/node_modules/@types/lquery/lquery' does not exist.",
10299
"Loading module as file / folder, candidate module location '/node_modules/@types/lquery/lquery', target file type 'TypeScript'.",
@@ -108,7 +105,6 @@
108105
"'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.",
109106
"'package.json' does not have a 'typesVersions' field.",
110107
"Found 'package.json' at '/node_modules/@types/mquery/package.json'.",
111-
"'package.json' does not have a 'typesVersions' field.",
112108
"'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.",
113109
"File '/node_modules/@types/mquery/mquery' does not exist.",
114110
"Loading module as file / folder, candidate module location '/node_modules/@types/mquery/mquery', target file type 'TypeScript'.",

0 commit comments

Comments
 (0)