diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index beb75fd16d2dc..70e0220bbb39c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5019,7 +5019,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (emitModuleKindIsNonNodeESM(moduleKind) || mode === ModuleKind.ESNext) { - return importSourceWithoutExtension + (tsExtension === Extension.Mts ? ".mjs" : tsExtension === Extension.Cts ? ".cjs" : ".js"); + const preferTs = isDeclarationFileName(moduleReference) && shouldAllowImportingTsExtension(compilerOptions); + const ext = + tsExtension === Extension.Mts || tsExtension === Extension.Dmts ? preferTs ? ".mts" : ".mjs" : + tsExtension === Extension.Cts || tsExtension === Extension.Dmts ? preferTs ? ".cts" : ".cjs" : + preferTs ? ".ts" : ".js"; + return importSourceWithoutExtension + ext; } return importSourceWithoutExtension; } @@ -43963,9 +43968,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } - else if (!(node.flags & NodeFlags.Ambient) && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) { - grammarErrorOnNode(node, Diagnostics.Import_assignment_is_not_allowed_when_moduleResolution_is_set_to_bundler_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); - } } } } @@ -44208,9 +44210,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // system modules does not support export assignment grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } - else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler && !(node.flags & NodeFlags.Ambient)) { - grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_bundler_Consider_using_export_default_or_another_module_format_instead); - } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 267a7e635d251..02620ab7620b1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4265,7 +4265,7 @@ "category": "Error", "code": 5094 }, - "Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later.": { + "Option '{0}' can only be used when 'module' is set to 'es2015' or later.": { "category": "Error", "code": 5095 }, @@ -4281,14 +4281,6 @@ "category": "Error", "code": 5098 }, - "Import assignment is not allowed when 'moduleResolution' is set to 'bundler'. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { - "category": "Error", - "code": 5099 - }, - "Export assignment cannot be used when 'moduleResolution' is set to 'bundler'. Consider using 'export default' or another module format instead.": { - "category": "Error", - "code": 5100 - }, "Flag '{0}' is deprecated and will stop functioning in TypeScript {1}. Specify compilerOption '\"ignoreDeprecations\": \"{2}\"' to silence this error.": { "category": "Error", "code": 5101 diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index f6b15356cdb08..e24f647c99c2f 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -70,6 +70,7 @@ import { ModuleResolutionHost, ModuleResolutionKind, moduleResolutionOptionDeclarations, + moduleResolutionSupportsPackageJsonExportsAndImports, noop, noopPush, normalizePath, @@ -705,11 +706,14 @@ export function getConditions(options: CompilerOptions, esmMode?: boolean) { // conditions are only used by the node16/nodenext/bundler resolvers - there's no priority order in the list, // it's essentially a set (priority is determined by object insertion order in the object we look at). const conditions = esmMode || getEmitModuleResolutionKind(options) === ModuleResolutionKind.Bundler - ? ["node", "import"] - : ["node", "require"]; + ? ["import"] + : ["require"]; if (!options.noDtsResolution) { conditions.push("types"); } + if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Bundler) { + conditions.push("node"); + } return concatenate(conditions, options.customConditions); } @@ -1701,7 +1705,7 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa candidateIsFromPackageJsonField: false, }; - if (traceEnabled && getEmitModuleResolutionKind(compilerOptions) >= ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) <= ModuleResolutionKind.NodeNext) { + if (traceEnabled && moduleResolutionSupportsPackageJsonExportsAndImports(getEmitModuleResolutionKind(compilerOptions))) { trace(host, Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(c => `'${c}'`).join(", ")); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 9fe770a45bd4d..60a8a9c0b6bf6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -69,6 +69,7 @@ import { DirectoryStructureHost, emitFiles, EmitHost, + emitModuleKindIsNonNodeESM, EmitOnly, EmitResult, emptyArray, @@ -4241,11 +4242,11 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } if (options.preserveValueImports && getEmitModuleKind(options) < ModuleKind.ES2015) { - createDiagnosticForOptionName(Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later, "preserveValueImports"); + createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_es2015_or_later, "preserveValueImports"); } + const moduleKind = getEmitModuleKind(options); if (options.verbatimModuleSyntax) { - const moduleKind = getEmitModuleKind(options); if (moduleKind === ModuleKind.AMD || moduleKind === ModuleKind.UMD || moduleKind === ModuleKind.System) { createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax"); } @@ -4266,13 +4267,17 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const moduleResolution = getEmitModuleResolutionKind(options); if (options.resolvePackageJsonExports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { - createOptionValueDiagnostic("resolvePackageJsonExports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "resolvePackageJsonExports"); + createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "resolvePackageJsonExports"); } if (options.resolvePackageJsonImports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { - createOptionValueDiagnostic("resolvePackageJsonImports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "resolvePackageJsonImports"); + createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "resolvePackageJsonImports"); } if (options.customConditions && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { - createOptionValueDiagnostic("customConditions", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "customConditions"); + createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "customConditions"); + } + + if (moduleResolution === ModuleResolutionKind.Bundler && !emitModuleKindIsNonNodeESM(moduleKind)) { + createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_es2015_or_later, "bundler"); } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files diff --git a/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt b/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt index 755f0d6eebda9..e9f61d8d6af18 100644 --- a/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt @@ -1,6 +1,8 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. /c.ts(1,16): error TS2307: Cannot find module './thisfiledoesnotexist.ts' or its corresponding type declarations. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. ==== /ts.ts (0 errors) ==== export {}; diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.errors.txt b/tests/baselines/reference/bundlerConditionsExcludesNode.errors.txt new file mode 100644 index 0000000000000..7a843cb155e70 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode.errors.txt @@ -0,0 +1,44 @@ +error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation + + +!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/conditions/package.json (0 errors) ==== + { + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +==== /node_modules/conditions/index.node.js (0 errors) ==== + export const node = 0; + +==== /node_modules/conditions/index.node.d.ts (0 errors) ==== + export const node: number; + +==== /node_modules/conditions/index.web.js (0 errors) ==== + export const web = 0; + +==== /node_modules/conditions/index.web.d.ts (0 errors) ==== + export const web: number; + +==== /main.ts (0 errors) ==== + import { web } from "conditions"; + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.js b/tests/baselines/reference/bundlerConditionsExcludesNode.js new file mode 100644 index 0000000000000..e6eb1fe883a18 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode.js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// + +//// [package.json] +{ + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +//// [index.node.js] +export const node = 0; + +//// [index.node.d.ts] +export const node: number; + +//// [index.web.js] +export const web = 0; + +//// [index.web.d.ts] +export const web: number; + +//// [main.ts] +import { web } from "conditions"; + + +//// [main.js] +export {}; diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.symbols b/tests/baselines/reference/bundlerConditionsExcludesNode.symbols new file mode 100644 index 0000000000000..53060cf30c368 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode.symbols @@ -0,0 +1,12 @@ +=== /node_modules/conditions/index.node.d.ts === +export const node: number; +>node : Symbol(node, Decl(index.node.d.ts, 0, 12)) + +=== /node_modules/conditions/index.web.d.ts === +export const web: number; +>web : Symbol(web, Decl(index.web.d.ts, 0, 12)) + +=== /main.ts === +import { web } from "conditions"; +>web : Symbol(web, Decl(main.ts, 0, 8)) + diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.trace.json b/tests/baselines/reference/bundlerConditionsExcludesNode.trace.json new file mode 100644 index 0000000000000..6da46a63881e1 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode.trace.json @@ -0,0 +1,20 @@ +[ + "======== Resolving module 'conditions' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'conditions' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Found 'package.json' at '/node_modules/conditions/package.json'.", + "Entering conditional exports.", + "Saw non-matching condition 'node'.", + "Matched 'exports' condition 'default'.", + "Using 'exports' subpath '.' with target './index.web.js'.", + "File name '/node_modules/conditions/index.web.js' has a '.js' extension - stripping it.", + "File '/node_modules/conditions/index.web.ts' does not exist.", + "File '/node_modules/conditions/index.web.tsx' does not exist.", + "File '/node_modules/conditions/index.web.d.ts' exists - use it as a name resolution result.", + "Resolved under condition 'default'.", + "Exiting conditional exports.", + "Resolving real path for '/node_modules/conditions/index.web.d.ts', result '/node_modules/conditions/index.web.d.ts'.", + "======== Module name 'conditions' was successfully resolved to '/node_modules/conditions/index.web.d.ts' with Package ID 'conditions/index.web.d.ts@1.0.0'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.types b/tests/baselines/reference/bundlerConditionsExcludesNode.types new file mode 100644 index 0000000000000..a907f0c67ae9f --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode.types @@ -0,0 +1,12 @@ +=== /node_modules/conditions/index.node.d.ts === +export const node: number; +>node : number + +=== /node_modules/conditions/index.web.d.ts === +export const web: number; +>web : number + +=== /main.ts === +import { web } from "conditions"; +>web : number + diff --git a/tests/baselines/reference/bundlerImportESM.js b/tests/baselines/reference/bundlerImportESM.js index efe3cbd491689..48e483322c215 100644 --- a/tests/baselines/reference/bundlerImportESM.js +++ b/tests/baselines/reference/bundlerImportESM.js @@ -14,13 +14,8 @@ import { esm } from "./esm.mjs"; //// [esm.mjs] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.esm = void 0; -exports.esm = 0; +export var esm = 0; //// [not-actually-cjs.cjs] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [still-not-cjs.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt index e7ee36c69ea8b..b554754ebaba7 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt @@ -5,12 +5,12 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo Root file specified for compilation /project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? /project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. /project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.js' instead? !!! error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. @@ -68,7 +68,7 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo !!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. import {} from "./b.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? import type {} from "./b.d.ts"; import {} from "./c.ts"; @@ -96,5 +96,5 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo import {} from "./a.ts"; import {} from "./a.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.js' instead? import type {} from "./a.d.ts"; \ No newline at end of file diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js index e6f603d88dc3b..e75393966d128 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js @@ -66,17 +66,12 @@ import {} from "./a.d.ts"; import type {} from "./a.d.ts"; //// [a.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [e.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [e.txt.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [main.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json index 07207c5f9d282..2f8361245931c 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json @@ -1,58 +1,68 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exists - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exists - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -64,22 +74,26 @@ "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exists - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/e.txt' has a '.txt' extension - stripping it.", "File '/project/e.d.txt.ts' does not exist.", @@ -90,6 +104,7 @@ "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt index b1e742e1dcba0..a71d312e82938 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt @@ -3,12 +3,12 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo Root file specified for compilation /project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? /project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. /project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.js' instead? !!! error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. @@ -64,7 +64,7 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo !!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. import {} from "./b.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? import type {} from "./b.d.ts"; import {} from "./c.ts"; @@ -92,5 +92,5 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo import {} from "./a.ts"; import {} from "./a.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.js' instead? import type {} from "./a.d.ts"; \ No newline at end of file diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json index 07207c5f9d282..2f8361245931c 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json @@ -1,58 +1,68 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exists - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exists - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -64,22 +74,26 @@ "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exists - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/e.txt' has a '.txt' extension - stripping it.", "File '/project/e.d.txt.ts' does not exist.", @@ -90,6 +104,7 @@ "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt index c6a2bf4156b5e..feed6ec3922f6 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt @@ -4,9 +4,9 @@ error TS5096: Option 'allowImportingTsExtensions' can only be used when either ' error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. The file is in the program because: Root file specified for compilation -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.ts' instead? /project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.ts' instead? !!! error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. @@ -61,7 +61,7 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo import {} from "./b.ts"; import {} from "./b.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.ts' instead? import type {} from "./b.d.ts"; import {} from "./c.ts"; @@ -83,5 +83,5 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo import {} from "./a.ts"; import {} from "./a.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.ts' instead? import type {} from "./a.d.ts"; \ No newline at end of file diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js index e6f603d88dc3b..e75393966d128 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js @@ -66,17 +66,12 @@ import {} from "./a.d.ts"; import type {} from "./a.d.ts"; //// [a.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [e.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [e.txt.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [main.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json index 07207c5f9d282..2f8361245931c 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json @@ -1,58 +1,68 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exists - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exists - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -64,22 +74,26 @@ "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exists - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/e.txt' has a '.txt' extension - stripping it.", "File '/project/e.d.txt.ts' does not exist.", @@ -90,6 +104,7 @@ "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt index f4a3d9beec11e..9b77b7c88309b 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt @@ -1,9 +1,9 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. The file is in the program because: Root file specified for compilation -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.ts' instead? /project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +/project/types.d.ts(2,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.ts' instead? !!! error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. @@ -55,7 +55,7 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo import {} from "./b.ts"; import {} from "./b.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.ts' instead? import type {} from "./b.d.ts"; import {} from "./c.ts"; @@ -77,5 +77,5 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo import {} from "./a.ts"; import {} from "./a.d.ts"; ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a' instead? +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './a.ts' instead? import type {} from "./a.d.ts"; \ No newline at end of file diff --git a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json index 07207c5f9d282..2f8361245931c 100644 --- a/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json @@ -1,58 +1,68 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.ts' exists - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exists - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exists - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -64,22 +74,26 @@ "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exists - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exists - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/e.txt' has a '.txt' extension - stripping it.", "File '/project/e.d.txt.ts' does not exist.", @@ -90,6 +104,7 @@ "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.ts' exists - use it as a name resolution result.", diff --git a/tests/baselines/reference/bundlerNodeModules1.js b/tests/baselines/reference/bundlerNodeModules1.js index 8567c3f9b4561..1272b9f38f865 100644 --- a/tests/baselines/reference/bundlerNodeModules1.js +++ b/tests/baselines/reference/bundlerNodeModules1.js @@ -38,11 +38,8 @@ import { esm, cjs } from "dual"; //// [main.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [main.mjs] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; //// [main.cjs] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; diff --git a/tests/baselines/reference/bundlerNodeModules1.trace.json b/tests/baselines/reference/bundlerNodeModules1.trace.json index 2d60a6f2765f4..b50ff705130ee 100644 --- a/tests/baselines/reference/bundlerNodeModules1.trace.json +++ b/tests/baselines/reference/bundlerNodeModules1.trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module 'dual' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist.", "Loading module 'dual' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/dual/package.json'.", diff --git a/tests/baselines/reference/bundlerOptionsCompat.errors.txt b/tests/baselines/reference/bundlerOptionsCompat.errors.txt new file mode 100644 index 0000000000000..7e765e198c67d --- /dev/null +++ b/tests/baselines/reference/bundlerOptionsCompat.errors.txt @@ -0,0 +1,16 @@ +/tsconfig.json(4,25): error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + + +==== /tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "bundler", + ~~~~~~~~~ +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + "noEmit": true + } + } + +==== /index.ts (0 errors) ==== + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerRelative1.js b/tests/baselines/reference/bundlerRelative1.js index 9238cc0f8ef3b..ffc4d34643a30 100644 --- a/tests/baselines/reference/bundlerRelative1.js +++ b/tests/baselines/reference/bundlerRelative1.js @@ -33,15 +33,8 @@ import * as cjs from "./types/cjs"; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -exports.x = 0; +export var x = 0; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.y = void 0; -exports.y = 0; +export var y = 0; //// [main.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; diff --git a/tests/baselines/reference/bundlerRelative1.trace.json b/tests/baselines/reference/bundlerRelative1.trace.json index e1c26a949edfc..566beeb3481bb 100644 --- a/tests/baselines/reference/bundlerRelative1.trace.json +++ b/tests/baselines/reference/bundlerRelative1.trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module './dir' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/dir', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/dir.ts' does not exist.", "File '/dir.tsx' does not exist.", @@ -12,23 +13,27 @@ "======== Module name './dir' was successfully resolved to '/dir/index.ts'. ========", "======== Resolving module './dir/index' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/dir/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/dir/index.ts' exists - use it as a name resolution result.", "======== Module name './dir/index' was successfully resolved to '/dir/index.ts'. ========", "======== Resolving module './dir/index.js' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/dir/index.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/dir/index.js' has a '.js' extension - stripping it.", "File '/dir/index.ts' exists - use it as a name resolution result.", "======== Module name './dir/index.js' was successfully resolved to '/dir/index.ts'. ========", "======== Resolving module './dir/index.ts' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/dir/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/dir/index.ts' has a '.ts' extension - stripping it.", "File '/dir/index.ts' exists - use it as a name resolution result.", "======== Module name './dir/index.ts' was successfully resolved to '/dir/index.ts'. ========", "======== Resolving module './redirect' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/redirect', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/redirect.ts' does not exist.", "File '/redirect.tsx' does not exist.", @@ -51,6 +56,7 @@ "======== Module name './redirect' was successfully resolved to '/foo/index.ts'. ========", "======== Resolving module './redirect/index' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/redirect/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/redirect/index.ts' does not exist.", "File '/redirect/index.tsx' does not exist.", @@ -61,6 +67,7 @@ "======== Module name './redirect/index' was not resolved. ========", "======== Resolving module './types/esm' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/types/esm', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/types/esm.ts' does not exist.", "File '/types/esm.tsx' does not exist.", @@ -68,6 +75,7 @@ "======== Module name './types/esm' was successfully resolved to '/types/esm.d.ts'. ========", "======== Resolving module './types/cjs' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "Loading module as file / folder, candidate module location '/types/cjs', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/types/cjs.ts' does not exist.", "File '/types/cjs.tsx' does not exist.", diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt index ab6be3b8d8fbd..e2f27150dcca9 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. -/main.ts(2,1): error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'bundler'. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. -/main.ts(3,1): error TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'bundler'. Consider using 'export default' or another module format instead. +/main.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +/main.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. /mainJs.js(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -32,10 +32,10 @@ error TS2468: Cannot find global value 'Promise'. import {} from "./a"; import _ = require("./a"); // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'bundler'. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. export = {}; // Error ~~~~~~~~~~~~ -!!! error TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'bundler'. Consider using 'export default' or another module format instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. export {}; ==== /a.ts (0 errors) ==== diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.js b/tests/baselines/reference/bundlerSyntaxRestrictions.js index 3995bef9e5fb0..a789516ae9a85 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.js +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.js @@ -32,16 +32,11 @@ export const a = "a"; //// [a.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = "a"; +export var a = "a"; //// [mainJs.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(function () { return require("./a"); }); +import("./a"); var _ = require("./a"); // No resolution _.a; // any +export {}; //// [main.js] -"use strict"; -module.exports = {}; +export {}; diff --git a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt new file mode 100644 index 0000000000000..71d5b10190e58 --- /dev/null +++ b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt @@ -0,0 +1,31 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + + +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +==== /node_modules/dep/package.json (0 errors) ==== + // This documents bug https://github.com/microsoft/TypeScript/issues/50762. + + { + "name": "dep", + "version": "1.0.0", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js", + "types": "./dist/index.d.ts", + } + } + } + +==== /node_modules/dep/dist/index.d.ts (0 errors) ==== + export {}; + +==== /node_modules/dep/dist/index.mjs (0 errors) ==== + export {}; + +==== /index.mts (0 errors) ==== + import {} from "dep"; + // Should be an untyped resolution to dep/dist/index.mjs, + // but the first search is only for TS files, and when + // there's no dist/index.d.mts, it continues looking for + // matching conditions and resolves via `types`. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).trace.json b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).trace.json index 4082b9545e345..0c5a1c1956eb1 100644 --- a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).trace.json +++ b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module 'dep' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist.", "Loading module 'dep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/dep/package.json'.", diff --git a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=node16).trace.json b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=node16).trace.json index f99d7a4fa0516..7bf58fae1bad7 100644 --- a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=node16).trace.json +++ b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=node16).trace.json @@ -3,7 +3,7 @@ "Found 'package.json' at '/node_modules/dep/package.json'.", "======== Resolving module 'dep' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist.", "Loading module 'dep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/dep/package.json' exists according to earlier cached lookups.", diff --git a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=nodenext).trace.json b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=nodenext).trace.json index 4c63ea4889b66..1113706fd11e1 100644 --- a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=nodenext).trace.json +++ b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=nodenext).trace.json @@ -3,7 +3,7 @@ "Found 'package.json' at '/node_modules/dep/package.json'.", "======== Resolving module 'dep' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist.", "Loading module 'dep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/dep/package.json' exists according to earlier cached lookups.", diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).errors.txt b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).errors.txt new file mode 100644 index 0000000000000..172906d3dc8d5 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).errors.txt @@ -0,0 +1,31 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + + +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +==== /node_modules/lodash/package.json (0 errors) ==== + { + "name": "lodash", + "version": "1.0.0", + "main": "index.js", + "exports": { + "browser": "./browser.js", + "webpack": "./webpack.js", + "default": "./index.js" + } + } + +==== /node_modules/lodash/index.d.ts (0 errors) ==== + declare const _: "index"; + export = _; + +==== /node_modules/lodash/browser.d.ts (0 errors) ==== + declare const _: "browser"; + export default _; + +==== /node_modules/lodash/webpack.d.ts (0 errors) ==== + declare const _: "webpack"; + export = _; + +==== /index.ts (0 errors) ==== + import _ from "lodash"; + \ No newline at end of file diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json index 18012df5f4b4b..830ca8d8fbe80 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module 'lodash' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types', 'webpack', ' browser'.", "File '/package.json' does not exist.", "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/lodash/package.json'.", diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).errors.txt b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).errors.txt new file mode 100644 index 0000000000000..172906d3dc8d5 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).errors.txt @@ -0,0 +1,31 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + + +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +==== /node_modules/lodash/package.json (0 errors) ==== + { + "name": "lodash", + "version": "1.0.0", + "main": "index.js", + "exports": { + "browser": "./browser.js", + "webpack": "./webpack.js", + "default": "./index.js" + } + } + +==== /node_modules/lodash/index.d.ts (0 errors) ==== + declare const _: "index"; + export = _; + +==== /node_modules/lodash/browser.d.ts (0 errors) ==== + declare const _: "browser"; + export default _; + +==== /node_modules/lodash/webpack.d.ts (0 errors) ==== + declare const _: "webpack"; + export = _; + +==== /index.ts (0 errors) ==== + import _ from "lodash"; + \ No newline at end of file diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json index 48028b7f755d7..a9c90d1eb4809 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module 'lodash' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types', 'webpack', ' browser'.", "File '/package.json' does not exist.", "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/lodash/package.json'.", diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).errors.txt b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).errors.txt new file mode 100644 index 0000000000000..bcb61b45b1213 --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).errors.txt @@ -0,0 +1,20 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + + +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +==== /project/a.js (0 errors) ==== + export default "a.js"; + +==== /project/a.js.js (0 errors) ==== + export default "a.js.js"; + +==== /project/dir/index.ts (0 errors) ==== + export default "dir/index.ts"; + +==== /project/dir.js (0 errors) ==== + export default "dir.js"; + +==== /project/b.ts (0 errors) ==== + import a from "./a.js"; + import dir from "./dir"; + \ No newline at end of file diff --git a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).errors.txt b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).errors.txt new file mode 100644 index 0000000000000..c867a2883059b --- /dev/null +++ b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).errors.txt @@ -0,0 +1,28 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + + +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +==== /node_modules/@restart/hooks/package.json (0 errors) ==== + { + "name": "@restart/hooks", + "version": "0.3.25", + "main": "cjs/index.js", + "types": "cjs/index.d.ts", + "module": "esm/index.js" + } + +==== /node_modules/@restart/hooks/useMergedRefs/package.json (0 errors) ==== + { + "name": "@restart/hooks/useMergedRefs", + "private": true, + "main": "../cjs/useMergedRefs.js", + "module": "../esm/useMergedRefs.js", + "types": "../esm/useMergedRefs.d.ts" + } + +==== /node_modules/@restart/hooks/esm/useMergedRefs.d.ts (0 errors) ==== + export {}; + +==== /main.ts (0 errors) ==== + import {} from "@restart/hooks/useMergedRefs"; + \ No newline at end of file diff --git a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).trace.json b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).trace.json index dbfe06ad51821..aca03363c91ee 100644 --- a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).trace.json +++ b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module '@restart/hooks/useMergedRefs' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist.", "Loading module '@restart/hooks/useMergedRefs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/@restart/hooks/useMergedRefs/package.json'.", diff --git a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=node16).trace.json b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=node16).trace.json index 535ac881f32f1..0f4f04477f875 100644 --- a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=node16).trace.json +++ b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=node16).trace.json @@ -4,7 +4,7 @@ "File '/package.json' does not exist.", "======== Resolving module '@restart/hooks/useMergedRefs' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module '@restart/hooks/useMergedRefs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "Found 'package.json' at '/node_modules/@restart/hooks/useMergedRefs/package.json'.", diff --git a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=nodenext).trace.json b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=nodenext).trace.json index 423fa1a6e9240..71ed347bbbe78 100644 --- a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=nodenext).trace.json +++ b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=nodenext).trace.json @@ -4,7 +4,7 @@ "File '/package.json' does not exist.", "======== Resolving module '@restart/hooks/useMergedRefs' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module '@restart/hooks/useMergedRefs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "Found 'package.json' at '/node_modules/@restart/hooks/useMergedRefs/package.json'.", diff --git a/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json b/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json index 55d99d6040655..56a98461a3ead 100644 --- a/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json +++ b/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json @@ -17,7 +17,7 @@ "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module 'react' from '/packages/a/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/packages/a/package.json' does not exist according to earlier cached lookups.", "File '/packages/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", @@ -41,7 +41,7 @@ "======== Module name 'react' was successfully resolved to '/node_modules/@types/react/index.d.ts'. ========", "======== Resolving module 'redux' from '/packages/a/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/packages/a/package.json' does not exist according to earlier cached lookups.", "File '/packages/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).trace.json b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).trace.json index 2de6e35148566..dfb4c016d26e3 100644 --- a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).trace.json +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).trace.json @@ -5,7 +5,7 @@ "Found 'package.json' at '/node_modules/just-types-versions/package.json'.", "======== Resolving module 'exports-and-types-versions/foo' from '/main.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist.", "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -24,7 +24,7 @@ "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/nope' from '/main.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -35,7 +35,7 @@ "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", "======== Resolving module 'exports-and-types-versions/yep' from '/main.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -49,7 +49,7 @@ "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -63,7 +63,7 @@ "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -80,7 +80,7 @@ "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", "======== Resolving module 'just-types-versions/foo' from '/main.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", @@ -93,7 +93,7 @@ "======== Module name 'just-types-versions/foo' was successfully resolved to '/node_modules/just-types-versions/types/foo.d.ts'. ========", "======== Resolving module 'exports-and-types-versions/foo' from '/main.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -121,7 +121,7 @@ "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/nope' from '/main.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -132,7 +132,7 @@ "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", "======== Resolving module 'exports-and-types-versions/yep' from '/main.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -146,7 +146,7 @@ "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -160,7 +160,7 @@ "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -177,7 +177,7 @@ "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", "======== Resolving module 'just-types-versions/foo' from '/main.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json index 6f42ddd75ee24..a21b098e5f10f 100644 --- a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json @@ -5,7 +5,7 @@ "Found 'package.json' at '/node_modules/just-types-versions/package.json'.", "======== Resolving module 'exports-and-types-versions/foo' from '/main.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist.", "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -24,7 +24,7 @@ "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/nope' from '/main.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -35,7 +35,7 @@ "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", "======== Resolving module 'exports-and-types-versions/yep' from '/main.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -49,7 +49,7 @@ "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -63,7 +63,7 @@ "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -80,7 +80,7 @@ "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", "======== Resolving module 'just-types-versions/foo' from '/main.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", @@ -93,7 +93,7 @@ "======== Module name 'just-types-versions/foo' was successfully resolved to '/node_modules/just-types-versions/types/foo.d.ts'. ========", "======== Resolving module 'exports-and-types-versions/foo' from '/main.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -121,7 +121,7 @@ "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/nope' from '/main.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -132,7 +132,7 @@ "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", "======== Resolving module 'exports-and-types-versions/yep' from '/main.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -146,7 +146,7 @@ "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -160,7 +160,7 @@ "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", @@ -177,7 +177,7 @@ "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", "======== Resolving module 'just-types-versions/foo' from '/main.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node16).trace.json b/tests/baselines/reference/nodeModulesPackageImports(module=node16).trace.json index aef5226d97e13..400f222086187 100644 --- a/tests/baselines/reference/nodeModulesPackageImports(module=node16).trace.json +++ b/tests/baselines/reference/nodeModulesPackageImports(module=node16).trace.json @@ -2,7 +2,7 @@ "Found 'package.json' at 'tests/cases/conformance/node/package.json'.", "======== Resolving module '#cjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/index.cjs' has a '.cjs' extension - stripping it.", @@ -11,7 +11,7 @@ "======== Module name '#cjs' was successfully resolved to 'tests/cases/conformance/node/index.cts'. ========", "======== Resolving module '#mjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/index.mjs' has a '.mjs' extension - stripping it.", @@ -20,7 +20,7 @@ "======== Module name '#mjs' was successfully resolved to 'tests/cases/conformance/node/index.mts'. ========", "======== Resolving module '#type' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#type' with target './index.js'.", "File name 'tests/cases/conformance/node/index.js' has a '.js' extension - stripping it.", @@ -29,7 +29,7 @@ "======== Module name '#type' was successfully resolved to 'tests/cases/conformance/node/index.ts'. ========", "======== Resolving module '#cjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/index.cjs' has a '.cjs' extension - stripping it.", @@ -38,7 +38,7 @@ "======== Module name '#cjs' was successfully resolved to 'tests/cases/conformance/node/index.cts'. ========", "======== Resolving module '#mjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/index.mjs' has a '.mjs' extension - stripping it.", @@ -47,7 +47,7 @@ "======== Module name '#mjs' was successfully resolved to 'tests/cases/conformance/node/index.mts'. ========", "======== Resolving module '#type' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#type' with target './index.js'.", "File name 'tests/cases/conformance/node/index.js' has a '.js' extension - stripping it.", diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json index c2596f45a5579..400ad0b6d60ad 100644 --- a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json +++ b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).trace.json @@ -2,7 +2,7 @@ "Found 'package.json' at 'tests/cases/conformance/node/package.json'.", "======== Resolving module '#cjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/index.cjs' has a '.cjs' extension - stripping it.", @@ -11,7 +11,7 @@ "======== Module name '#cjs' was successfully resolved to 'tests/cases/conformance/node/index.cts'. ========", "======== Resolving module '#mjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/index.mjs' has a '.mjs' extension - stripping it.", @@ -20,7 +20,7 @@ "======== Module name '#mjs' was successfully resolved to 'tests/cases/conformance/node/index.mts'. ========", "======== Resolving module '#type' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#type' with target './index.js'.", "File name 'tests/cases/conformance/node/index.js' has a '.js' extension - stripping it.", @@ -29,7 +29,7 @@ "======== Module name '#type' was successfully resolved to 'tests/cases/conformance/node/index.ts'. ========", "======== Resolving module '#cjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/index.cjs' has a '.cjs' extension - stripping it.", @@ -38,7 +38,7 @@ "======== Module name '#cjs' was successfully resolved to 'tests/cases/conformance/node/index.cts'. ========", "======== Resolving module '#mjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/index.mjs' has a '.mjs' extension - stripping it.", @@ -47,7 +47,7 @@ "======== Module name '#mjs' was successfully resolved to 'tests/cases/conformance/node/index.mts'. ========", "======== Resolving module '#type' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Using 'imports' subpath '#type' with target './index.js'.", "File name 'tests/cases/conformance/node/index.js' has a '.js' extension - stripping it.", diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).trace.json b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).trace.json index 9edd8505e0c40..10fd535459eeb 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).trace.json +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).trace.json @@ -2,7 +2,7 @@ "Found 'package.json' at 'tests/cases/conformance/node/package.json'.", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/cjs/index.cjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "Found 'package.json' at 'tests/cases/conformance/node/node_modules/inner/package.json'.", @@ -14,7 +14,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/mjs/index.mjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -26,7 +26,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/js/index.js' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -39,7 +39,7 @@ "======== Module name 'inner/js/index.js' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.ts'. ========", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './cjs/*.cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.cjs' has a '.cjs' extension - stripping it.", @@ -49,7 +49,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './mjs/*.mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.mjs' has a '.mjs' extension - stripping it.", @@ -59,7 +59,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './js/*.js' with target './index.js'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.js' has a '.js' extension - stripping it.", @@ -70,7 +70,7 @@ "======== Module name 'inner/js/index.js' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.ts'. ========", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './cjs/*.cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.cjs' has a '.cjs' extension - stripping it.", @@ -80,7 +80,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './mjs/*.mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.mjs' has a '.mjs' extension - stripping it.", @@ -90,7 +90,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './js/*.js' with target './index.js'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.js' has a '.js' extension - stripping it.", @@ -120,7 +120,7 @@ "======== Module name 'inner/js/index.js' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.ts'. ========", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/cjs/index.cjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -132,7 +132,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/mjs/index.mjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -144,7 +144,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'Node16'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/js/index.js' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json index 7966c10b39b76..338eb6fb87484 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).trace.json @@ -2,7 +2,7 @@ "Found 'package.json' at 'tests/cases/conformance/node/package.json'.", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/cjs/index.cjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "Found 'package.json' at 'tests/cases/conformance/node/node_modules/inner/package.json'.", @@ -14,7 +14,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/mjs/index.mjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -26,7 +26,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/index.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/js/index.js' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -39,7 +39,7 @@ "======== Module name 'inner/js/index.js' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.ts'. ========", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './cjs/*.cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.cjs' has a '.cjs' extension - stripping it.", @@ -49,7 +49,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './mjs/*.mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.mjs' has a '.mjs' extension - stripping it.", @@ -59,7 +59,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './js/*.js' with target './index.js'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.js' has a '.js' extension - stripping it.", @@ -70,7 +70,7 @@ "======== Module name 'inner/js/index.js' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.ts'. ========", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './cjs/*.cjs' with target './index.cjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.cjs' has a '.cjs' extension - stripping it.", @@ -80,7 +80,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './mjs/*.mjs' with target './index.mjs'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.mjs' has a '.mjs' extension - stripping it.", @@ -90,7 +90,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", "Using 'exports' subpath './js/*.js' with target './index.js'.", "File name 'tests/cases/conformance/node/node_modules/inner/index.js' has a '.js' extension - stripping it.", @@ -120,7 +120,7 @@ "======== Module name 'inner/js/index.js' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.ts'. ========", "======== Resolving module 'inner/cjs/index.cjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/cjs/index.cjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -132,7 +132,7 @@ "======== Module name 'inner/cjs/index.cjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.cts'. ========", "======== Resolving module 'inner/mjs/index.mjs' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/mjs/index.mjs' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", @@ -144,7 +144,7 @@ "======== Module name 'inner/mjs/index.mjs' was successfully resolved to 'tests/cases/conformance/node/node_modules/inner/index.d.mts'. ========", "======== Resolving module 'inner/js/index.js' from 'tests/cases/conformance/node/index.cts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/conformance/node/package.json' exists according to earlier cached lookups.", "Loading module 'inner/js/index.js' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/conformance/node/node_modules/inner/package.json' exists according to earlier cached lookups.", diff --git a/tests/baselines/reference/packageJsonExportsOptionsCompat.errors.txt b/tests/baselines/reference/packageJsonExportsOptionsCompat.errors.txt new file mode 100644 index 0000000000000..435349fe337d7 --- /dev/null +++ b/tests/baselines/reference/packageJsonExportsOptionsCompat.errors.txt @@ -0,0 +1,24 @@ +/tsconfig.json(4,5): error TS5098: Option 'customConditions' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. +/tsconfig.json(5,5): error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. +/tsconfig.json(6,5): error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. + + +==== /tsconfig.json (3 errors) ==== + { + "compilerOptions": { + "moduleResolution": "classic", + "customConditions": ["webpack", "browser"], + ~~~~~~~~~~~~~~~~~~ +!!! error TS5098: Option 'customConditions' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. + "resolvePackageJsonExports": true, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. + "resolvePackageJsonImports": true, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. + "noEmit": true + } + } + +==== /index.ts (0 errors) ==== + \ No newline at end of file diff --git a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=bundler).errors.txt b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=bundler).errors.txt new file mode 100644 index 0000000000000..2be32719473d8 --- /dev/null +++ b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=bundler).errors.txt @@ -0,0 +1,6 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. + + +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +==== tests/cases/conformance/moduleResolution/index.ts (0 errors) ==== + \ No newline at end of file diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json b/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json index 275766d2d511f..99a96723e294a 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json @@ -6,7 +6,7 @@ "File '/package.json' does not exist.", "======== Resolving module 'react/jsx-runtime' from 'tests/cases/compiler/file.tsx'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "File 'tests/cases/compiler/package.json' does not exist according to earlier cached lookups.", "File 'tests/cases/package.json' does not exist according to earlier cached lookups.", "File 'tests/package.json' does not exist according to earlier cached lookups.", @@ -21,7 +21,7 @@ "File 'tests/cases/compiler/node_modules/@types/react/package.json' exists according to earlier cached lookups.", "======== Resolving module './' from 'tests/cases/compiler/node_modules/@types/react/jsx-runtime.d.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "Loading module as file / folder, candidate module location 'tests/cases/compiler/node_modules/@types/react/', target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/compiler/node_modules/@types/react/package.json' exists according to earlier cached lookups.", "'package.json' does not have a 'typings' field.", diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json index a15bee50d9227..e76cf02cadd78 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json @@ -2,7 +2,7 @@ "Found 'package.json' at 'tests/cases/compiler/package.json'.", "======== Resolving module 'react/jsx-runtime' from 'tests/cases/compiler/file.tsx'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File 'tests/cases/compiler/package.json' exists according to earlier cached lookups.", "Loading module 'react/jsx-runtime' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "Found 'package.json' at 'tests/cases/compiler/node_modules/@types/react/package.json'.", @@ -14,7 +14,7 @@ "File 'tests/cases/compiler/node_modules/@types/react/package.json' exists according to earlier cached lookups.", "======== Resolving module './' from 'tests/cases/compiler/node_modules/@types/react/jsx-runtime.d.ts'. ========", "Module resolution kind is not specified, using 'NodeNext'.", - "Resolving in CJS mode with conditions 'node', 'require', 'types'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", "Loading module as file / folder, candidate module location 'tests/cases/compiler/node_modules/@types/react/', target file types: TypeScript, JavaScript, Declaration.", "File 'tests/cases/compiler/node_modules/@types/react/package.json' exists according to earlier cached lookups.", "'package.json' does not have a 'typesVersions' field.", diff --git a/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt b/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt index ef3ffa721e4ea..f2da136f21d13 100644 --- a/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt @@ -1,6 +1,8 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. tests/cases/compiler/test.ts(1,19): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. ==== tests/cases/compiler/tsconfig.json (0 errors) ==== { "compilerOptions": { diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt index fe904ca69530b..0668d695d63e3 100644 --- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt @@ -1,3 +1,4 @@ +error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? The file is in the program because: Root file specified for compilation @@ -16,6 +17,7 @@ error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you m There are types at '/node_modules/@types/bar/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@types/bar' library may need to update its package.json or typings. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. !!! error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? !!! error TS6504: The file is in the program because: !!! error TS6504: Root file specified for compilation diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json index 2a50df0adeead..008a09f076eb4 100644 --- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json +++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module 'foo' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist.", "Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/foo/package.json'.", @@ -37,6 +38,7 @@ "======== Module name 'foo' was successfully resolved to '/node_modules/foo/index.mjs' with Package ID 'foo/index.mjs@1.0.0'. ========", "======== Resolving module 'bar' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'bar' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/bar/package.json'.", diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json index 9c99e7dbe3ac8..5b9abf1482a53 100644 --- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json +++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json @@ -3,7 +3,7 @@ "Found 'package.json' at '/node_modules/@types/bar/package.json'.", "======== Resolving module 'foo' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist.", "Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "File '/node_modules/foo/package.json' exists according to earlier cached lookups.", @@ -36,7 +36,7 @@ "======== Module name 'foo' was successfully resolved to '/node_modules/foo/index.mjs' with Package ID 'foo/index.mjs@1.0.0'. ========", "======== Resolving module 'bar' from '/index.mts'. ========", "Explicitly specified module resolution kind: 'Node16'.", - "Resolving in ESM mode with conditions 'node', 'import', 'types'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", "File '/package.json' does not exist according to earlier cached lookups.", "Loading module 'bar' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", "Found 'package.json' at '/node_modules/bar/package.json'.", diff --git a/tests/baselines/reference/selfNameModuleAugmentation.trace.json b/tests/baselines/reference/selfNameModuleAugmentation.trace.json index fa0232b7c6ebf..affd825963080 100644 --- a/tests/baselines/reference/selfNameModuleAugmentation.trace.json +++ b/tests/baselines/reference/selfNameModuleAugmentation.trace.json @@ -1,6 +1,7 @@ [ "======== Resolving module 'acorn-walk' from '/node_modules/acorn-walk/dist/walk.d.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "File '/node_modules/acorn-walk/dist/package.json' does not exist.", "Found 'package.json' at '/node_modules/acorn-walk/package.json'.", "Entering conditional exports.", @@ -23,6 +24,7 @@ "======== Module name 'acorn-walk' was successfully resolved to '/node_modules/acorn-walk/dist/walk.d.ts' with Package ID 'acorn-walk/dist/walk.d.ts@8.2.0'. ========", "======== Resolving module 'acorn-walk' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist.", "Loading module 'acorn-walk' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/node_modules/acorn-walk/package.json' exists according to earlier cached lookups.", diff --git a/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js b/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js index 461771b69e505..b7a051721de1d 100644 --- a/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js +++ b/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js @@ -85,7 +85,7 @@ File '/src/projects/b/src/package.json' does not exist. Found 'package.json' at '/src/projects/b/package.json'. ======== Resolving module 'pg' from '/src/projects/b/src/index.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/src/projects/b/src/package.json' does not exist according to earlier cached lookups. File '/src/projects/b/package.json' exists according to earlier cached lookups. Loading module 'pg' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration. diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index c519f8e24b03b..7ccc0d3ab61c3 100644 --- a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -52,7 +52,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/packages/pkg2/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/const.cts' exists - use it as a name resolution result. @@ -67,7 +67,7 @@ File '/package.json' does not exist. Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -91,7 +91,7 @@ File '/user/username/projects/myproject/packages/pkg2/package.json' exists accor ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -302,7 +302,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -329,7 +329,7 @@ Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -416,7 +416,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -440,7 +440,7 @@ Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -522,7 +522,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -549,7 +549,7 @@ Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -639,7 +639,7 @@ Output:: ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.cts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/packages/pkg2/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/const.cts' exists - use it as a name resolution result. @@ -654,7 +654,7 @@ File '/package.json' does not exist. Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -678,7 +678,7 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/bui ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.cts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/package-json-is-looked-up-for-file.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/package-json-is-looked-up-for-file.js index c888e2b10d375..61a9ffde6ab07 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/package-json-is-looked-up-for-file.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/package-json-is-looked-up-for-file.js @@ -38,7 +38,7 @@ File '/Users/name/projects/lib-boilerplate/test/package.json' does not exist. File '/Users/name/projects/lib-boilerplate/package.json' exists according to earlier cached lookups. ======== Resolving module 'lib-boilerplate' from '/Users/name/projects/lib-boilerplate/test/basic.spec.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/Users/name/projects/lib-boilerplate/test/package.json' does not exist according to earlier cached lookups. File '/Users/name/projects/lib-boilerplate/package.json' exists according to earlier cached lookups. Using 'exports' subpath '.' with target './src/index.ts'. diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/self-name-package-reference.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/self-name-package-reference.js index bce0742487757..04432a0b6ba77 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/self-name-package-reference.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/self-name-package-reference.js @@ -33,7 +33,7 @@ Output:: Found 'package.json' at '/Users/name/projects/web/package.json'. ======== Resolving module '@this/package' from '/Users/name/projects/web/index.ts'. ======== Module resolution kind is not specified, using 'NodeNext'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/Users/name/projects/web/package.json' exists according to earlier cached lookups. Using 'exports' subpath '.' with target './dist/index.js'. File '/Users/name/projects/web/index.ts' exists - use it as a name resolution result. diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js index 20deca3dbd2fb..137a35ebe3860 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js @@ -41,7 +41,7 @@ File '/Users/package.json' does not exist. File '/package.json' does not exist. ======== Resolving module 'yargs' from '/Users/name/projects/web/src/bin.ts'. ======== Explicitly specified module resolution kind: 'NodeNext'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. File '/Users/name/projects/web/src/package.json' does not exist according to earlier cached lookups. File '/Users/name/projects/web/package.json' does not exist according to earlier cached lookups. File '/Users/name/projects/package.json' does not exist according to earlier cached lookups. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js index 28a6ab7fd28d4..4f7cca08a5e0b 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js @@ -37,7 +37,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/package.json'. ======== Resolving module '@this/package' from '/user/username/projects/myproject/index.ts'. ======== Explicitly specified module resolution kind: 'NodeNext'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. Entering conditional exports. Matched 'exports' condition 'default'. @@ -143,7 +143,7 @@ Reusing resolution of module '@this/package' from '/user/username/projects/mypro File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. ======== Resolving module './index.js' from '/user/username/projects/myproject/index2.ts'. ======== Explicitly specified module resolution kind: 'NodeNext'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/index.js', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/index.ts' exists - use it as a name resolution result. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js b/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js index 7bc2102e1680d..d7ee7b750b746 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js @@ -58,7 +58,7 @@ File '/user/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. ======== Resolving module 'pkg' from '/user/username/projects/myproject/index.ts'. ======== Explicitly specified module resolution kind: 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. File '/user/username/projects/package.json' does not exist according to earlier cached lookups. File '/user/username/package.json' does not exist according to earlier cached lookups. @@ -79,7 +79,7 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg/impo ======== Module name 'pkg' was successfully resolved to '/user/username/projects/myproject/node_modules/pkg/import.d.ts' with Package ID 'pkg/import.d.ts@0.0.1'. ======== ======== Resolving module 'pkg1' from '/user/username/projects/myproject/index.ts'. ======== Explicitly specified module resolution kind: 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. File '/user/username/projects/package.json' does not exist according to earlier cached lookups. File '/user/username/package.json' does not exist according to earlier cached lookups. @@ -119,7 +119,7 @@ Directory '/node_modules' does not exist, skipping all lookups in it. ======== Module name 'pkg1' was not resolved. ======== ======== Resolving module './a' from '/user/username/projects/myproject/index.ts'. ======== Explicitly specified module resolution kind: 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/a', target file types: TypeScript, JavaScript, Declaration. File '/user/username/projects/myproject/a.ts' exists - use it as a name resolution result. ======== Module name './a' was successfully resolved to '/user/username/projects/myproject/a.ts'. ======== @@ -237,7 +237,7 @@ File '/user/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. ======== Resolving module 'pkg' from '/user/username/projects/myproject/a.ts'. ======== Explicitly specified module resolution kind: 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. File '/user/username/projects/package.json' does not exist according to earlier cached lookups. File '/user/username/package.json' does not exist according to earlier cached lookups. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js index 3d8b1ff5b569d..b2bdbd7b204fd 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js @@ -44,7 +44,7 @@ Found 'package.json' at '/user/username/projects/myproject/package.json'. FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileA.ts 250 undefined Source file ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. @@ -154,7 +154,7 @@ File '/user/username/projects/myproject/src/package.json' does not exist accordi File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. @@ -262,7 +262,7 @@ File '/user/username/projects/myproject/src/package.json' does not exist accordi File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. @@ -367,7 +367,7 @@ File '/user/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js index 688ac828dc9f7..7479a557aa393 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js @@ -44,7 +44,7 @@ Found 'package.json' at '/user/username/projects/myproject/package.json'. FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileA.ts 250 undefined Source file ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. @@ -165,7 +165,7 @@ File '/user/username/projects/myproject/src/package.json' does not exist accordi File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. @@ -264,7 +264,7 @@ File '/user/username/projects/myproject/src/package.json' does not exist accordi File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. @@ -464,7 +464,7 @@ File '/user/username/projects/myproject/src/package.json' does not exist accordi File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in ESM mode with conditions 'node', 'import', 'types'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. @@ -570,7 +570,7 @@ File '/user/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Module resolution kind is not specified, using 'Node16'. -Resolving in CJS mode with conditions 'node', 'require', 'types'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js index 768e7249e3318..8ce23c3f190d6 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js @@ -72,7 +72,7 @@ Info 12 [00:00:39.000] File '/user/username/projects/myproject/src/package.jso Info 13 [00:00:40.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. Info 14 [00:00:41.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Info 15 [00:00:42.000] Module resolution kind is not specified, using 'Node16'. -Info 16 [00:00:43.000] Resolving in ESM mode with conditions 'node', 'import', 'types'. +Info 16 [00:00:43.000] Resolving in ESM mode with conditions 'import', 'types', 'node'. Info 17 [00:00:44.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. Info 18 [00:00:45.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. Info 19 [00:00:46.000] File '/user/username/projects/myproject/src/fileB.mts' exists - use it as a name resolution result. @@ -242,7 +242,7 @@ Info 56 [00:01:32.000] File '/user/username/projects/myproject/src/package.jso Info 57 [00:01:33.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. Info 58 [00:01:34.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Info 59 [00:01:35.000] Module resolution kind is not specified, using 'Node16'. -Info 60 [00:01:36.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. +Info 60 [00:01:36.000] Resolving in CJS mode with conditions 'require', 'types', 'node'. Info 61 [00:01:37.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. Info 62 [00:01:38.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. Info 63 [00:01:39.000] File '/user/username/projects/myproject/src/fileB.mts' exists - use it as a name resolution result. @@ -607,7 +607,7 @@ Info 97 [00:02:28.000] File '/user/username/projects/myproject/src/package.jso Info 98 [00:02:29.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. Info 99 [00:02:30.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Info 100 [00:02:31.000] Module resolution kind is not specified, using 'Node16'. -Info 101 [00:02:32.000] Resolving in ESM mode with conditions 'node', 'import', 'types'. +Info 101 [00:02:32.000] Resolving in ESM mode with conditions 'import', 'types', 'node'. Info 102 [00:02:33.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. Info 103 [00:02:34.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. Info 104 [00:02:35.000] File '/user/username/projects/myproject/src/fileB.mts' exists - use it as a name resolution result. @@ -1360,7 +1360,7 @@ Info 180 [00:04:18.000] File '/user/username/projects/myproject/src/package.jso Info 181 [00:04:19.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. Info 182 [00:04:20.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Info 183 [00:04:21.000] Module resolution kind is not specified, using 'Node16'. -Info 184 [00:04:22.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. +Info 184 [00:04:22.000] Resolving in CJS mode with conditions 'require', 'types', 'node'. Info 185 [00:04:23.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. Info 186 [00:04:24.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. Info 187 [00:04:25.000] File '/user/username/projects/myproject/src/fileB.mts' exists - use it as a name resolution result. diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js index e18134d999b25..cf2646cca128b 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js @@ -72,7 +72,7 @@ Info 12 [00:00:39.000] File '/user/username/projects/myproject/src/package.jso Info 13 [00:00:40.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. Info 14 [00:00:41.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Info 15 [00:00:42.000] Module resolution kind is not specified, using 'Node16'. -Info 16 [00:00:43.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. +Info 16 [00:00:43.000] Resolving in CJS mode with conditions 'require', 'types', 'node'. Info 17 [00:00:44.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. Info 18 [00:00:45.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. Info 19 [00:00:46.000] File '/user/username/projects/myproject/src/fileB.mts' exists - use it as a name resolution result. @@ -242,7 +242,7 @@ Info 56 [00:01:32.000] File '/user/username/projects/myproject/src/package.jso Info 57 [00:01:33.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. Info 58 [00:01:34.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Info 59 [00:01:35.000] Module resolution kind is not specified, using 'Node16'. -Info 60 [00:01:36.000] Resolving in ESM mode with conditions 'node', 'import', 'types'. +Info 60 [00:01:36.000] Resolving in ESM mode with conditions 'import', 'types', 'node'. Info 61 [00:01:37.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. Info 62 [00:01:38.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. Info 63 [00:01:39.000] File '/user/username/projects/myproject/src/fileB.mts' exists - use it as a name resolution result. @@ -607,7 +607,7 @@ Info 97 [00:02:28.000] File '/user/username/projects/myproject/src/package.jso Info 98 [00:02:29.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. Info 99 [00:02:30.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== Info 100 [00:02:31.000] Module resolution kind is not specified, using 'Node16'. -Info 101 [00:02:32.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. +Info 101 [00:02:32.000] Resolving in CJS mode with conditions 'require', 'types', 'node'. Info 102 [00:02:33.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file types: TypeScript, JavaScript, Declaration. Info 103 [00:02:34.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. Info 104 [00:02:35.000] File '/user/username/projects/myproject/src/fileB.mts' exists - use it as a name resolution result. diff --git a/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js b/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js index 27ced28860c73..7382a77537341 100644 --- a/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js +++ b/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js @@ -1310,8 +1310,6 @@ Info 32 [00:01:13.000] response: "5096", "5097", "5098", - "5099", - "5100", "5101", "5102", "5103", diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts new file mode 100644 index 0000000000000..3ab230e98dd81 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts @@ -0,0 +1,33 @@ +// @moduleResolution: bundler +// @module: esnext +// @traceResolution: true + +// @Filename: /node_modules/conditions/package.json +{ + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +// @Filename: /node_modules/conditions/index.node.js +export const node = 0; + +// @Filename: /node_modules/conditions/index.node.d.ts +export const node: number; + +// @Filename: /node_modules/conditions/index.web.js +export const web = 0; + +// @Filename: /node_modules/conditions/index.web.d.ts +export const web: number; + +// @Filename: /main.ts +import { web } from "conditions"; diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts index 86107d98fbcab..7fbcd0f6f7a85 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts @@ -1,4 +1,5 @@ // @moduleResolution: bundler +// @module: esnext // @Filename: /esm.mts export const esm = 0; diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts index 8ba4b62b7116b..a4e6cfec09916 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts @@ -1,4 +1,5 @@ // @moduleResolution: bundler +// @module: esnext // @outDir: dist // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts index ffa7242ff3c09..2c71e97c08fdc 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts @@ -1,4 +1,5 @@ // @moduleResolution: bundler +// @module: esnext // @traceResolution: true // @Filename: /node_modules/dual/package.json diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerOptionsCompat.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerOptionsCompat.ts new file mode 100644 index 0000000000000..e5ca3dd376b12 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerOptionsCompat.ts @@ -0,0 +1,12 @@ +// @noTypesAndSymbols: true + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "bundler", + "noEmit": true + } +} + +// @Filename: /index.ts diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts index d23292176f8d4..667fe14366d11 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts @@ -1,4 +1,5 @@ // @moduleResolution: bundler +// @module: esnext // @traceResolution: true // @Filename: /dir/index.ts diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts index 5bdd94d1beffb..e71313bca4cf9 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts @@ -1,4 +1,5 @@ // @moduleResolution: bundler +// @module: esnext // @checkJs: true // @allowJs: true // @outDir: out diff --git a/tests/cases/conformance/moduleResolution/packageJsonExportsOptionsCompat.ts b/tests/cases/conformance/moduleResolution/packageJsonExportsOptionsCompat.ts new file mode 100644 index 0000000000000..a742230c86e7a --- /dev/null +++ b/tests/cases/conformance/moduleResolution/packageJsonExportsOptionsCompat.ts @@ -0,0 +1,14 @@ +// @noTypesAndSymbols: true + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "moduleResolution": "classic", + "customConditions": ["webpack", "browser"], + "resolvePackageJsonExports": true, + "resolvePackageJsonImports": true, + "noEmit": true + } +} + +// @Filename: /index.ts \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/selfNameModuleAugmentation.ts b/tests/cases/conformance/moduleResolution/selfNameModuleAugmentation.ts index 191d71cb0a5d0..a602cb2e284ba 100644 --- a/tests/cases/conformance/moduleResolution/selfNameModuleAugmentation.ts +++ b/tests/cases/conformance/moduleResolution/selfNameModuleAugmentation.ts @@ -1,4 +1,5 @@ // @moduleResolution: bundler +// @module: esnext // @allowJs: true // @noEmit: true // @traceResolution: true