Skip to content

Commit 602b098

Browse files
TypeScript Botandrewbranch
TypeScript Bot
andauthored
🤖 Pick PR #58831 (Disable #57896 (Respect package.jso...) into release-5.5 (#58848)
Co-authored-by: Andrew Branch <[email protected]> Co-authored-by: Andrew Branch <[email protected]>
1 parent f7bf3b2 commit 602b098

File tree

1,454 files changed

+15125
-78889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,454 files changed

+15125
-78889
lines changed

Diff for: ‎src/compiler/program.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -1389,10 +1389,16 @@ export function getImpliedNodeFormatForFileWorker(
13891389
host: ModuleResolutionHost,
13901390
options: CompilerOptions,
13911391
) {
1392-
return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
1393-
fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
1394-
fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
1395-
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
1392+
switch (getEmitModuleResolutionKind(options)) {
1393+
case ModuleResolutionKind.Node16:
1394+
case ModuleResolutionKind.NodeNext:
1395+
return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
1396+
fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
1397+
fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
1398+
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
1399+
default:
1400+
return undefined;
1401+
}
13961402

13971403
function lookupFromPackageJson(): Partial<CreateSourceFileOptions> {
13981404
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);

Diff for: ‎src/testRunner/unittests/tscWatch/incremental.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,19 @@ describe("unittests:: tsc-watch:: emit file --incremental", () => {
178178
version: system.createHash(libFile.content),
179179
signature: system.createHash(libFile.content),
180180
affectsGlobalScope: true,
181-
impliedFormat: ts.ModuleKind.CommonJS,
181+
impliedFormat: undefined,
182182
});
183183
assert.deepEqual(state.fileInfos.get(file1.path as ts.Path), {
184184
version: system.createHash(file1.content),
185185
signature: system.createHash(file1.content),
186186
affectsGlobalScope: undefined,
187-
impliedFormat: ts.ModuleKind.CommonJS,
187+
impliedFormat: undefined,
188188
});
189189
assert.deepEqual(state.fileInfos.get(file2.path as ts.Path), {
190190
version: system.createHash(fileModified.content),
191191
signature: system.createHash(fileModified.content),
192192
affectsGlobalScope: undefined,
193-
impliedFormat: ts.ModuleKind.CommonJS,
193+
impliedFormat: undefined,
194194
});
195195

196196
assert.deepEqual(state.compilerOptions, {

Diff for: ‎tests/baselines/reference/allowJsCrossMonorepoPackage.trace.json

+3-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
[
2-
"Found 'package.json' at '/packages/main/package.json'.",
32
"======== Resolving module 'shared' from '/packages/main/index.ts'. ========",
43
"Explicitly specified module resolution kind: 'Bundler'.",
54
"Resolving in CJS mode with conditions 'import', 'types'.",
6-
"File '/packages/main/package.json' exists according to earlier cached lookups.",
5+
"Found 'package.json' at '/packages/main/package.json'.",
76
"Loading module 'shared' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.",
87
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
98
"Found 'package.json' at '/packages/main/node_modules/shared/package.json'.",
@@ -47,7 +46,6 @@
4746
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
4847
"Resolving real path for '/packages/main/node_modules/shared/index.js', result '/packages/shared/index.js'.",
4948
"======== Module name 'shared' was successfully resolved to '/packages/shared/index.js' with Package ID 'shared/[email protected]'. ========",
50-
"Found 'package.json' at '/packages/shared/package.json'.",
5149
"======== Resolving module './utils.js' from '/packages/shared/index.js'. ========",
5250
"Explicitly specified module resolution kind: 'Bundler'.",
5351
"Resolving in CJS mode with conditions 'import', 'types'.",
@@ -58,11 +56,10 @@
5856
"File '/packages/shared/utils.d.ts' does not exist.",
5957
"File '/packages/shared/utils.js' exists - use it as a name resolution result.",
6058
"======== Module name './utils.js' was successfully resolved to '/packages/shared/utils.js'. ========",
61-
"File '/packages/shared/package.json' exists according to earlier cached lookups.",
6259
"======== Resolving module 'pkg' from '/packages/shared/utils.js'. ========",
6360
"Explicitly specified module resolution kind: 'Bundler'.",
6461
"Resolving in CJS mode with conditions 'import', 'types'.",
65-
"File '/packages/shared/package.json' exists according to earlier cached lookups.",
62+
"Found 'package.json' at '/packages/shared/package.json'.",
6663
"Loading module 'pkg' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.",
6764
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
6865
"Directory '/packages/shared/node_modules' does not exist, skipping all lookups in it.",
@@ -76,11 +73,6 @@
7673
"File '/node_modules/pkg/index.d.ts' exists - use it as a name resolution result.",
7774
"Resolving real path for '/node_modules/pkg/index.d.ts', result '/node_modules/pkg/index.d.ts'.",
7875
"======== Module name 'pkg' was successfully resolved to '/node_modules/pkg/index.d.ts'. ========",
79-
"File '/node_modules/pkg/package.json' does not exist according to earlier cached lookups.",
80-
"File '/node_modules/package.json' does not exist.",
81-
"File '/package.json' does not exist.",
82-
"File '/.ts/package.json' does not exist.",
83-
"File '/package.json' does not exist according to earlier cached lookups.",
8476
"======== Resolving module '@typescript/lib-es5' from '/packages/main/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",
8577
"Explicitly specified module resolution kind: 'Node10'.",
8678
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -95,8 +87,6 @@
9587
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
9688
"Directory '/packages/node_modules' does not exist, skipping all lookups in it.",
9789
"======== Module name '@typescript/lib-es5' was not resolved. ========",
98-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
99-
"File '/package.json' does not exist according to earlier cached lookups.",
10090
"======== Resolving module '@typescript/lib-decorators' from '/packages/main/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========",
10191
"Explicitly specified module resolution kind: 'Node10'.",
10292
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -111,8 +101,6 @@
111101
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
112102
"Directory '/packages/node_modules' does not exist, skipping all lookups in it.",
113103
"======== Module name '@typescript/lib-decorators' was not resolved. ========",
114-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
115-
"File '/package.json' does not exist according to earlier cached lookups.",
116104
"======== Resolving module '@typescript/lib-decorators/legacy' from '/packages/main/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========",
117105
"Explicitly specified module resolution kind: 'Node10'.",
118106
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -127,8 +115,6 @@
127115
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
128116
"Directory '/packages/node_modules' does not exist, skipping all lookups in it.",
129117
"======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========",
130-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
131-
"File '/package.json' does not exist according to earlier cached lookups.",
132118
"======== Resolving module '@typescript/lib-dom' from '/packages/main/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========",
133119
"Explicitly specified module resolution kind: 'Node10'.",
134120
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -143,8 +129,6 @@
143129
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
144130
"Directory '/packages/node_modules' does not exist, skipping all lookups in it.",
145131
"======== Module name '@typescript/lib-dom' was not resolved. ========",
146-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
147-
"File '/package.json' does not exist according to earlier cached lookups.",
148132
"======== Resolving module '@typescript/lib-webworker/importscripts' from '/packages/main/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========",
149133
"Explicitly specified module resolution kind: 'Node10'.",
150134
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -159,8 +143,6 @@
159143
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
160144
"Directory '/packages/node_modules' does not exist, skipping all lookups in it.",
161145
"======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========",
162-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
163-
"File '/package.json' does not exist according to earlier cached lookups.",
164146
"======== Resolving module '@typescript/lib-scripthost' from '/packages/main/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========",
165147
"Explicitly specified module resolution kind: 'Node10'.",
166148
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -174,7 +156,5 @@
174156
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.",
175157
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
176158
"Directory '/packages/node_modules' does not exist, skipping all lookups in it.",
177-
"======== Module name '@typescript/lib-scripthost' was not resolved. ========",
178-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
179-
"File '/package.json' does not exist according to earlier cached lookups."
159+
"======== Module name '@typescript/lib-scripthost' was not resolved. ========"
180160
]

Diff for: ‎tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).trace.json

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
[
2-
"Found 'package.json' at '/node_modules/conditions/package.json'.",
3-
"File '/node_modules/conditions/package.json' exists according to earlier cached lookups.",
4-
"File '/package.json' does not exist.",
52
"======== Resolving module 'conditions' from '/main.ts'. ========",
63
"Explicitly specified module resolution kind: 'Bundler'.",
74
"Resolving in CJS mode with conditions 'import', 'types'.",
8-
"File '/package.json' does not exist according to earlier cached lookups.",
5+
"File '/package.json' does not exist.",
96
"Loading module 'conditions' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.",
107
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
11-
"File '/node_modules/conditions/package.json' exists according to earlier cached lookups.",
8+
"Found 'package.json' at '/node_modules/conditions/package.json'.",
129
"Entering conditional exports.",
1310
"Saw non-matching condition 'node'.",
1411
"Matched 'exports' condition 'default'.",
@@ -22,8 +19,6 @@
2219
"Exiting conditional exports.",
2320
"Resolving real path for '/node_modules/conditions/index.web.d.ts', result '/node_modules/conditions/index.web.d.ts'.",
2421
"======== Module name 'conditions' was successfully resolved to '/node_modules/conditions/index.web.d.ts' with Package ID 'conditions/[email protected]'. ========",
25-
"File '/.ts/package.json' does not exist.",
26-
"File '/package.json' does not exist according to earlier cached lookups.",
2722
"======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",
2823
"Explicitly specified module resolution kind: 'Node10'.",
2924
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -36,8 +31,6 @@
3631
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
3732
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
3833
"======== Module name '@typescript/lib-es5' was not resolved. ========",
39-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
40-
"File '/package.json' does not exist according to earlier cached lookups.",
4134
"======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========",
4235
"Explicitly specified module resolution kind: 'Node10'.",
4336
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -50,8 +43,6 @@
5043
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
5144
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
5245
"======== Module name '@typescript/lib-decorators' was not resolved. ========",
53-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
54-
"File '/package.json' does not exist according to earlier cached lookups.",
5546
"======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========",
5647
"Explicitly specified module resolution kind: 'Node10'.",
5748
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -64,8 +55,6 @@
6455
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
6556
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
6657
"======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========",
67-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
68-
"File '/package.json' does not exist according to earlier cached lookups.",
6958
"======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========",
7059
"Explicitly specified module resolution kind: 'Node10'.",
7160
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -78,8 +67,6 @@
7867
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
7968
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
8069
"======== Module name '@typescript/lib-dom' was not resolved. ========",
81-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
82-
"File '/package.json' does not exist according to earlier cached lookups.",
8370
"======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========",
8471
"Explicitly specified module resolution kind: 'Node10'.",
8572
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -92,8 +79,6 @@
9279
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
9380
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
9481
"======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========",
95-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
96-
"File '/package.json' does not exist according to earlier cached lookups.",
9782
"======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========",
9883
"Explicitly specified module resolution kind: 'Node10'.",
9984
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.",
@@ -105,7 +90,5 @@
10590
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.",
10691
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
10792
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
108-
"======== Module name '@typescript/lib-scripthost' was not resolved. ========",
109-
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
110-
"File '/package.json' does not exist according to earlier cached lookups."
93+
"======== Module name '@typescript/lib-scripthost' was not resolved. ========"
11194
]

0 commit comments

Comments
 (0)