diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts
index 9087823617bca..d26da9bcbf082 100644
--- a/src/compiler/binder.ts
+++ b/src/compiler/binder.ts
@@ -2374,7 +2374,7 @@ namespace ts {
 
         function checkStrictModeLabeledStatement(node: LabeledStatement) {
             // Grammar checking for labeledStatement
-            if (inStrictMode && options.target! >= ScriptTarget.ES2015) {
+            if (inStrictMode && getEmitScriptTarget(options) >= ScriptTarget.ES2015) {
                 if (isDeclarationStatement(node.statement) || isVariableStatement(node.statement)) {
                     errorOnFirstToken(node.label, Diagnostics.A_label_is_not_allowed_here);
                 }
diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts
index 2b578cecfc035..aec8cae3cea12 100644
--- a/src/compiler/builder.ts
+++ b/src/compiler/builder.ts
@@ -258,6 +258,14 @@ namespace ts {
             Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
             state.seenAffectedFiles = state.seenAffectedFiles || new Set();
         }
+        if (useOldState) {
+            // Any time the interpretation of a source file changes, mark it as changed
+            forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => {
+                if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath)!.impliedFormat !== info.impliedFormat) {
+                    state.changedFilesSet.add(sourceFilePath);
+                }
+            });
+        }
 
         state.buildInfoEmitPending = !!state.changedFilesSet.size;
         return state;
@@ -744,13 +752,13 @@ namespace ts {
             const actualSignature = signature ?? value.signature;
             return value.version === actualSignature ?
                 value.affectsGlobalScope ?
-                    { version: value.version, signature: undefined, affectsGlobalScope: true } :
+                    { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
                     value.version :
                 actualSignature !== undefined ?
                     signature === undefined ?
                         value :
-                        { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope } :
-                    { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope };
+                        { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
+                    { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
         });
 
         let referencedMap: ProgramBuildInfoReferencedMap | undefined;
@@ -1243,10 +1251,10 @@ namespace ts {
 
     export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): BuilderState.FileInfo {
         return isString(fileInfo) ?
-            { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } :
+            { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } :
             isString(fileInfo.signature) ?
                 fileInfo as BuilderState.FileInfo :
-                { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope };
+                { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
     }
 
     export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo, buildInfoPath: string, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram {
diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts
index 6578962ebf0c8..a64a6c13ed1e8 100644
--- a/src/compiler/builderState.ts
+++ b/src/compiler/builderState.ts
@@ -82,6 +82,7 @@ namespace ts {
             readonly version: string;
             signature: string | undefined;
             affectsGlobalScope: boolean | undefined;
+            impliedFormat: number | undefined;
         }
 
         export interface ReadonlyManyToManyPathMap {
@@ -332,7 +333,7 @@ namespace ts {
                         }
                     }
                 }
-                fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined });
+                fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
             }
 
             return {
@@ -433,7 +434,7 @@ namespace ts {
                 );
                 const firstDts = firstOrUndefined(emitOutput.outputFiles);
                 if (firstDts) {
-                    Debug.assert(fileExtensionIs(firstDts.name, Extension.Dts), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`);
+                    Debug.assert(fileExtensionIsOneOf(firstDts.name, [Extension.Dts, Extension.Dmts, Extension.Dcts]), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`);
                     latestSignature = (computeHash || generateDjb2Hash)(firstDts.text);
                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
                         updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 6858fdabc8a1f..a6717262817b3 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -303,7 +303,7 @@ namespace ts {
             host.getSourceFiles().forEach(sf => {
                 if (!sf.resolvedModules) return;
 
-                forEachEntry(sf.resolvedModules, r => {
+                sf.resolvedModules.forEach(r => {
                     if (r && r.packageId) map.set(r.packageId.name, r.extension === Extension.Dts || !!map.get(r.packageId.name));
                 });
             });
@@ -1523,7 +1523,7 @@ namespace ts {
                 }
                 else if (isParameterPropertyDeclaration(declaration, declaration.parent)) {
                     // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property
-                    return !(compilerOptions.target === ScriptTarget.ESNext && useDefineForClassFields
+                    return !(getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && useDefineForClassFields
                              && getContainingClass(declaration) === getContainingClass(usage)
                              && isUsedInFunctionOrInstanceProperty(usage, declaration));
                 }
@@ -1554,7 +1554,7 @@ namespace ts {
                 return true;
             }
             if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
-                if (compilerOptions.target === ScriptTarget.ESNext && useDefineForClassFields
+                if (getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && useDefineForClassFields
                     && getContainingClass(declaration)
                     && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
@@ -1832,7 +1832,7 @@ namespace ts {
                         isInExternalModule = true;
                         // falls through
                     case SyntaxKind.ModuleDeclaration:
-                        const moduleExports = getSymbolOfNode(location as SourceFile | ModuleDeclaration).exports || emptySymbols;
+                        const moduleExports = getSymbolOfNode(location as SourceFile | ModuleDeclaration)?.exports || emptySymbols;
                         if (location.kind === SyntaxKind.SourceFile || (isModuleDeclaration(location) && location.flags & NodeFlags.Ambient && !isGlobalScopeAugmentation(location))) {
 
                             // It's an external module. First see if the module has an export default and if the local
@@ -1875,7 +1875,7 @@ namespace ts {
                         }
                         break;
                     case SyntaxKind.EnumDeclaration:
-                        if (result = lookup(getSymbolOfNode(location)!.exports!, name, meaning & SymbolFlags.EnumMember)) {
+                        if (result = lookup(getSymbolOfNode(location)?.exports || emptySymbols, name, meaning & SymbolFlags.EnumMember)) {
                             break loop;
                         }
                         break;
@@ -1958,7 +1958,7 @@ namespace ts {
                     case SyntaxKind.ArrowFunction:
                         // when targeting ES6 or higher there is no 'arguments' in an arrow function
                         // for lower compile targets the resolved symbol is used to emit an error
-                        if (compilerOptions.target! >= ScriptTarget.ES2015) {
+                        if (getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015) {
                             break;
                         }
                         // falls through
@@ -2138,7 +2138,7 @@ namespace ts {
 
             // Perform extra checks only if error reporting was requested
             if (nameNotFoundMessage) {
-                if (propertyWithInvalidInitializer && !(compilerOptions.target === ScriptTarget.ESNext && useDefineForClassFields)) {
+                if (propertyWithInvalidInitializer && !(getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && useDefineForClassFields)) {
                     // We have a match, but the reference occurred within a property initializer and the identifier also binds
                     // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
                     // with ESNext+useDefineForClassFields because the scope semantics are different.
@@ -2787,7 +2787,7 @@ namespace ts {
             if (!isIdentifier(name)) {
                 return undefined;
             }
-            const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop);
+            const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
             const targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError);
             if (targetSymbol) {
                 if (name.escapedText) {
@@ -2876,18 +2876,18 @@ namespace ts {
 
         function reportInvalidImportEqualsExportMember(node: ImportDeclaration | ExportDeclaration | VariableDeclaration, name: Identifier, declarationName: string, moduleName: string) {
             if (moduleKind >= ModuleKind.ES2015) {
-                const message = compilerOptions.esModuleInterop ? Diagnostics._0_can_only_be_imported_by_using_a_default_import :
+                const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_a_default_import :
                     Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
                 error(name, message, declarationName);
             }
             else {
                 if (isInJSFile(node)) {
-                    const message = compilerOptions.esModuleInterop ? Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
+                    const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
                         Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
                     error(name, message, declarationName);
                 }
                 else {
-                    const message = compilerOptions.esModuleInterop ? Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
+                    const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
                         Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
                     error(name, message, declarationName, declarationName, moduleName);
                 }
@@ -3377,7 +3377,15 @@ namespace ts {
                 return ambientModule;
             }
             const currentSourceFile = getSourceFileOfNode(location);
-            const resolvedModule = getResolvedModule(currentSourceFile, moduleReference)!; // TODO: GH#18217
+            const contextSpecifier = isStringLiteralLike(location)
+                ? location
+                :   findAncestor(location, isImportCall)?.arguments[0] ||
+                    findAncestor(location, isImportDeclaration)?.moduleSpecifier ||
+                    findAncestor(location, isExternalModuleImportEqualsDeclaration)?.moduleReference.expression ||
+                    findAncestor(location, isExportDeclaration)?.moduleSpecifier ||
+                    (isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)?.name ||
+                    (isLiteralImportTypeNode(location) ? location : undefined)?.argument.literal;
+            const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined)!; // TODO: GH#18217
             const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule);
             const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
             if (sourceFile) {
@@ -3385,6 +3393,12 @@ namespace ts {
                     if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
                         errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
                     }
+                    if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) {
+                        const isSyncImport = (currentSourceFile.impliedNodeFormat === ModuleKind.CommonJS && !findAncestor(location, isImportCall)) || !!findAncestor(location, isImportEqualsDeclaration);
+                        if (isSyncImport && sourceFile.impliedNodeFormat === ModuleKind.ESNext) {
+                            error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference);
+                        }
+                    }
                     // merged symbol is module declaration symbol combined with all augmentations
                     return getMergedSymbol(sourceFile.symbol);
                 }
@@ -3446,15 +3460,14 @@ namespace ts {
                          * Direct users to import source with .js extension if outputting an ES module.
                          * @see https://github.com/microsoft/TypeScript/issues/42151
                          */
-                        const moduleKind = getEmitModuleKind(compilerOptions);
                         if (moduleKind >= ModuleKind.ES2015) {
-                            replacedImportSource += ".js";
+                            replacedImportSource += tsExtension === Extension.Mts ? ".mjs" : tsExtension === Extension.Cts ? ".cjs" : ".js";
                         }
                         error(errorNode, diag, tsExtension, replacedImportSource);
                     }
                     else if (!compilerOptions.resolveJsonModule &&
                         fileExtensionIs(moduleReference, Extension.Json) &&
-                        getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs &&
+                        getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic &&
                         hasJsonModuleEmitEnabled(compilerOptions)) {
                         error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
                     }
@@ -3547,7 +3560,7 @@ namespace ts {
                     return symbol;
                 }
 
-                if (compilerOptions.esModuleInterop) {
+                if (getESModuleInterop(compilerOptions)) {
                     const referenceParent = referencingLocation.parent;
                     if (
                         (isImportDeclaration(referenceParent) && getNamespaceDeclarationNode(referenceParent)) ||
@@ -4598,6 +4611,7 @@ namespace ts {
                         isSourceOfProjectReferenceRedirect: fileName => host.isSourceOfProjectReferenceRedirect(fileName),
                         fileExists: fileName => host.fileExists(fileName),
                         getFileIncludeReasons: () => host.getFileIncludeReasons(),
+                        readFile: host.readFile ? (fileName => host.readFile!(fileName)) : undefined,
                     } : undefined },
                     encounteredError: false,
                     reportedDiagnostic: false,
@@ -5865,7 +5879,7 @@ namespace ts {
                     const nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
                     const typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
                     const specifier = getSpecifierForModuleSymbol(chain[0], context);
-                    if (!(context.flags & NodeBuilderFlags.AllowNodeModulesRelativePaths) && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) {
+                    if (!(context.flags & NodeBuilderFlags.AllowNodeModulesRelativePaths) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
                         // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error
                         // since declaration files with these kinds of references are liable to fail when published :(
                         context.encounteredError = true;
@@ -6114,7 +6128,7 @@ namespace ts {
                 if (nameType) {
                     if (nameType.flags & TypeFlags.StringOrNumberLiteral) {
                         const name = "" + (nameType as StringLiteralType | NumberLiteralType).value;
-                        if (!isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
+                        if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
                             return factory.createStringLiteral(name, !!singleQuote);
                         }
                         if (isNumericLiteralName(name) && startsWith(name, "-")) {
@@ -6129,7 +6143,7 @@ namespace ts {
             }
 
             function createPropertyNameNodeForIdentifierOrLiteral(name: string, stringNamed?: boolean, singleQuote?: boolean) {
-                return isIdentifierText(name, compilerOptions.target) ? factory.createIdentifier(name) :
+                return isIdentifierText(name, getEmitScriptTarget(compilerOptions)) ? factory.createIdentifier(name) :
                     !stringNamed && isNumericLiteralName(name) && +name >= 0 ? factory.createNumericLiteral(+name) :
                     factory.createStringLiteral(name, !!singleQuote);
             }
@@ -7232,6 +7246,28 @@ namespace ts {
                     ), symbol.declarations && filter(symbol.declarations, d => isClassDeclaration(d) || isClassExpression(d))[0]), modifierFlags);
                 }
 
+                function getSomeTargetNameFromDeclarations(declarations: Declaration[] | undefined) {
+                    return firstDefined(declarations, d => {
+                        if (isImportSpecifier(d) || isExportSpecifier(d)) {
+                            return idText(d.propertyName || d.name);
+                        }
+                        if (isBinaryExpression(d) || isExportAssignment(d)) {
+                            const expression = isExportAssignment(d) ? d.expression : d.right;
+                            if (isPropertyAccessExpression(expression)) {
+                                return idText(expression.name);
+                            }
+                        }
+                        if (isAliasSymbolDeclaration(d)) {
+                            // This is... heuristic, at best. But it's probably better than always printing the name of the shorthand ambient module.
+                            const name = getNameOfDeclaration(d);
+                            if (name && isIdentifier(name)) {
+                                return idText(name);
+                            }
+                        }
+                        return undefined;
+                    });
+                }
+
                 function serializeAsAlias(symbol: Symbol, localName: string, modifierFlags: ModifierFlags) {
                     // synthesize an alias, eg `export { symbolName as Name }`
                     // need to mark the alias `symbol` points at
@@ -7242,8 +7278,10 @@ namespace ts {
                     if (!target) {
                         return;
                     }
-                    let verbatimTargetName = unescapeLeadingUnderscores(target.escapedName);
-                    if (verbatimTargetName === InternalSymbolName.ExportEquals && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) {
+                    // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol
+                    // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that
+                    let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
+                    if (verbatimTargetName === InternalSymbolName.ExportEquals && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
                         // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match
                         verbatimTargetName = InternalSymbolName.Default;
                     }
@@ -7932,7 +7970,7 @@ namespace ts {
             if (nameType) {
                 if (nameType.flags & TypeFlags.StringOrNumberLiteral) {
                     const name = "" + (nameType as StringLiteralType | NumberLiteralType).value;
-                    if (!isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
+                    if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
                         return `"${escapeString(name, CharacterCodes.doubleQuote)}"`;
                     }
                     if (isNumericLiteralName(name) && startsWith(name, "-")) {
@@ -17703,7 +17741,7 @@ namespace ts {
                                 path = `${str}`;
                             }
                             // Otherwise write a dotted name if possible
-                            else if (isIdentifierText(str, compilerOptions.target)) {
+                            else if (isIdentifierText(str, getEmitScriptTarget(compilerOptions))) {
                                 path = `${path}.${str}`;
                             }
                             // Failing that, check if the name is already a computed name
@@ -27818,7 +27856,7 @@ namespace ts {
                     grammarErrorOnNode(right, Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, idText(right));
                 }
 
-                if (lexicallyScopedSymbol?.valueDeclaration && (compilerOptions.target === ScriptTarget.ESNext && !useDefineForClassFields)) {
+                if (lexicallyScopedSymbol?.valueDeclaration && (getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && !useDefineForClassFields)) {
                     const lexicalClass = getContainingClass(lexicallyScopedSymbol.valueDeclaration);
                     const parentStaticFieldInitializer = findAncestor(node, (n) => {
                         if (n === lexicalClass) return "quit";
@@ -30716,6 +30754,12 @@ namespace ts {
         }
 
         function checkAssertion(node: AssertionExpression) {
+            if (node.kind === SyntaxKind.TypeAssertionExpression) {
+                const file = getSourceFileOfNode(node);
+                if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) {
+                    grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
+                }
+            }
             return checkAssertionWorker(node, node.type, node.expression);
         }
 
@@ -30828,7 +30872,14 @@ namespace ts {
 
         function checkImportMetaProperty(node: MetaProperty) {
             if (moduleKind !== ModuleKind.ES2020 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System) {
-                error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system);
+                if (moduleKind === ModuleKind.Node12 || moduleKind === ModuleKind.NodeNext) {
+                    if (getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.ESNext) {
+                        error(node, Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
+                    }
+                }
+                else {
+                    error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
+                }
             }
             const file = getSourceFileOfNode(node);
             Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag.");
@@ -31849,10 +31900,10 @@ namespace ts {
                                     Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
                                 diagnostics.add(diagnostic);
                             }
-                            if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System) || languageVersion < ScriptTarget.ES2017) {
+                            if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
                                 span = getSpanOfTokenAtPosition(sourceFile, node.pos);
                                 const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length,
-                                    Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher);
+                                    Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
                                 diagnostics.add(diagnostic);
                             }
                         }
@@ -34100,7 +34151,7 @@ namespace ts {
                     // - The constructor declares parameter properties
                     //   or the containing class declares instance member variables with initializers.
                     const superCallShouldBeFirst =
-                        (compilerOptions.target !== ScriptTarget.ESNext || !useDefineForClassFields) &&
+                        (getEmitScriptTarget(compilerOptions) !== ScriptTarget.ESNext || !useDefineForClassFields) &&
                         (some((node.parent as ClassDeclaration).members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
                          some(node.parameters, p => hasSyntacticModifier(p, ModifierFlags.ParameterPropertyModifier)));
 
@@ -36042,7 +36093,7 @@ namespace ts {
 
         function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier | undefined) {
             // No need to check for require or exports for ES6 modules and later
-            if (moduleKind >= ModuleKind.ES2015) {
+            if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node12 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) {
                 return;
             }
 
@@ -37786,8 +37837,8 @@ namespace ts {
          * The name cannot be used as 'Object' of user defined types with special target.
          */
         function checkClassNameCollisionWithObject(name: Identifier): void {
-            if (languageVersion === ScriptTarget.ES5 && name.escapedText === "Object"
-                && moduleKind < ModuleKind.ES2015) {
+            if (languageVersion >= ScriptTarget.ES5 && name.escapedText === "Object"
+                && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(name).impliedNodeFormat === ModuleKind.CommonJS)) {
                 error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
             }
         }
@@ -39054,8 +39105,8 @@ namespace ts {
             checkAliasSymbol(node);
             if (node.kind === SyntaxKind.ImportSpecifier &&
                 idText(node.propertyName || node.name) === "default" &&
-                compilerOptions.esModuleInterop &&
-                moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
+                getESModuleInterop(compilerOptions) &&
+                moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) {
                 checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
             }
         }
@@ -39089,7 +39140,7 @@ namespace ts {
                     if (importClause.namedBindings) {
                         if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
                             checkImportBinding(importClause.namedBindings);
-                            if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015 && compilerOptions.esModuleInterop) {
+                            if (moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) && getESModuleInterop(compilerOptions)) {
                                 // import * as ns from "foo";
                                 checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportStar);
                             }
@@ -39137,7 +39188,7 @@ namespace ts {
                     }
                 }
                 else {
-                    if (moduleKind >= ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) {
+                    if (moduleKind >= ModuleKind.ES2015 && getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) {
                         // 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);
                     }
@@ -39182,12 +39233,12 @@ namespace ts {
                     else if (node.exportClause) {
                         checkAliasSymbol(node.exportClause);
                     }
-                    if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
+                    if (moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) {
                         if (node.exportClause) {
                             // export * as ns from "foo";
                             // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper.
                             // We only use the helper here when in esModuleInterop
-                            if (compilerOptions.esModuleInterop) {
+                            if (getESModuleInterop(compilerOptions)) {
                                 checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportStar);
                             }
                         }
@@ -39279,9 +39330,9 @@ namespace ts {
                 }
             }
             else {
-                if (compilerOptions.esModuleInterop &&
+                if (getESModuleInterop(compilerOptions) &&
                     moduleKind !== ModuleKind.System &&
-                    moduleKind < ModuleKind.ES2015 &&
+                    (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) &&
                     idText(node.propertyName || node.name) === "default") {
                     checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
                 }
@@ -39349,7 +39400,7 @@ namespace ts {
             }
 
             if (node.isExportEquals && !(node.flags & NodeFlags.Ambient)) {
-                if (moduleKind >= ModuleKind.ES2015) {
+                if (moduleKind >= ModuleKind.ES2015 && getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.CommonJS) {
                     // export assignment is not supported in es6 modules
                     grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
                 }
@@ -42105,6 +42156,12 @@ namespace ts {
                 return false;
             }
 
+            if (node.typeParameters && !(length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) {
+                if (file && fileExtensionIsOneOf(file.fileName, [Extension.Mts, Extension.Cts])) {
+                    grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint);
+                }
+            }
+
             const { equalsGreaterThanToken } = node;
             const startLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
             const endLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
@@ -42475,9 +42532,9 @@ namespace ts {
                                 diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier,
                                     Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module));
                             }
-                            if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System) || languageVersion < ScriptTarget.ES2017) {
+                            if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
                                 diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier,
-                                    Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher));
+                                    Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
                             }
                         }
                     }
@@ -42856,8 +42913,7 @@ namespace ts {
                 return grammarErrorOnNode(node.exclamationToken, message);
             }
 
-            const moduleKind = getEmitModuleKind(compilerOptions);
-            if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System &&
+            if ((moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) && moduleKind !== ModuleKind.System &&
                 !(node.parent.parent.flags & NodeFlags.Ambient) && hasSyntacticModifier(node.parent.parent, ModifierFlags.Export)) {
                 checkESModuleMarker(node.name);
             }
@@ -43227,7 +43283,7 @@ namespace ts {
 
         function checkGrammarImportCallExpression(node: ImportCall): boolean {
             if (moduleKind === ModuleKind.ES2015) {
-                return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
+                return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_umd_node12_or_nodenext);
             }
 
             if (node.typeArguments) {
diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index b76e6f72268bb..db4a7563eca0c 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -394,7 +394,9 @@ namespace ts {
                 es6: ModuleKind.ES2015,
                 es2015: ModuleKind.ES2015,
                 es2020: ModuleKind.ES2020,
-                esnext: ModuleKind.ESNext
+                esnext: ModuleKind.ESNext,
+                node12: ModuleKind.Node12,
+                nodenext: ModuleKind.NodeNext,
             })),
             affectsModuleResolution: true,
             affectsEmit: true,
@@ -3216,7 +3218,7 @@ namespace ts {
         // Rather than re-query this for each file and filespec, we query the supported extensions
         // once and store it on the expansion context.
         const supportedExtensions = getSupportedExtensions(options, extraFileExtensions);
-        const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
+        const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
 
         // Literal files are always included verbatim. An "include" or "exclude" specification cannot
         // remove a literal file.
@@ -3229,7 +3231,7 @@ namespace ts {
 
         let jsonOnlyIncludeRegexes: readonly RegExp[] | undefined;
         if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
-            for (const file of host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) {
+            for (const file of host.readDirectory(basePath, flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) {
                 if (fileExtensionIs(file, Extension.Json)) {
                     // Valid only if *.json specified
                     if (!jsonOnlyIncludeRegexes) {
@@ -3454,16 +3456,24 @@ namespace ts {
      * extension priority.
      *
      * @param file The path to the file.
-     * @param extensionPriority The priority of the extension.
-     * @param context The expansion context.
      */
-    function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap<string, string>, wildcardFiles: ESMap<string, string>, extensions: readonly string[], keyMapper: (value: string) => string) {
-        const extensionPriority = getExtensionPriority(file, extensions);
-        const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions);
-        for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) {
-            const higherPriorityExtension = extensions[i];
-            const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension));
+    function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap<string, string>, wildcardFiles: ESMap<string, string>, extensions: readonly string[][], keyMapper: (value: string) => string) {
+        const extensionGroup = forEach(extensions, group => fileExtensionIsOneOf(file, group) ? group : undefined);
+        if (!extensionGroup) {
+            return false;
+        }
+        for (const ext of extensionGroup) {
+            if (fileExtensionIs(file, ext)) {
+                return false;
+            }
+            const higherPriorityPath = keyMapper(changeExtension(file, ext));
             if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
+                if (ext === Extension.Dts && (fileExtensionIs(file, Extension.Js) || fileExtensionIs(file, Extension.Jsx))) {
+                    // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration
+                    // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to
+                    // prevent breakage.
+                    continue;
+                }
                 return true;
             }
         }
@@ -3476,15 +3486,18 @@ namespace ts {
      * already been included.
      *
      * @param file The path to the file.
-     * @param extensionPriority The priority of the extension.
-     * @param context The expansion context.
      */
-    function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap<string, string>, extensions: readonly string[], keyMapper: (value: string) => string) {
-        const extensionPriority = getExtensionPriority(file, extensions);
-        const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions);
-        for (let i = nextExtensionPriority; i < extensions.length; i++) {
-            const lowerPriorityExtension = extensions[i];
-            const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension));
+    function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap<string, string>, extensions: readonly string[][], keyMapper: (value: string) => string) {
+        const extensionGroup = forEach(extensions, group => fileExtensionIsOneOf(file, group) ? group : undefined);
+        if (!extensionGroup) {
+            return;
+        }
+        for (let i = extensionGroup.length - 1; i >= 0; i--) {
+            const ext = extensionGroup[i];
+            if (fileExtensionIs(file, ext)) {
+                return;
+            }
+            const lowerPriorityPath = keyMapper(changeExtension(file, ext));
             wildcardFiles.delete(lowerPriorityPath);
         }
     }
diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json
index c2778dd5da9fa..5a4cd1e09dd6f 100644
--- a/src/compiler/diagnosticMessages.json
+++ b/src/compiler/diagnosticMessages.json
@@ -920,7 +920,7 @@
         "category": "Error",
         "code": 1322
     },
-    "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": {
+    "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.": {
         "category": "Error",
         "code": 1323
     },
@@ -992,7 +992,7 @@
         "category": "Error",
         "code": 1342
     },
-    "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.": {
+    "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.": {
         "category": "Error",
         "code": 1343
     },
@@ -1116,7 +1116,7 @@
         "category": "Message",
         "code": 1377
     },
-    "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.": {
+    "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
         "category": "Error",
         "code": 1378
     },
@@ -1324,7 +1324,7 @@
         "category": "Error",
         "code": 1431
     },
-    "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.": {
+    "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
         "category": "Error",
         "code": 1432
     },
@@ -1393,6 +1393,15 @@
         "code": 1450
     },
 
+    "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.": {
+        "category": "Error",
+        "code": 1470
+    },
+    "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.": {
+        "category": "Error",
+        "code": 1471
+    },
+
     "The types of '{0}' are incompatible between these types.": {
         "category": "Error",
         "code": 2200
@@ -4886,6 +4895,35 @@
         "code": 6258
     },
 
+    "Directory '{0}' has no containing package.json scope. Imports will not resolve.": {
+        "category": "Message",
+        "code": 6270
+    },
+    "Import specifier '{0}' does not exist in package.json scope at path '{1}'.": {
+        "category": "Message",
+        "code": 6271
+    },
+    "Invalid import specifier '{0}' has no possible resolutions.": {
+        "category": "Message",
+        "code": 6272
+    },
+    "package.json scope '{0}' has no imports defined.": {
+        "category": "Message",
+        "code": 6273
+    },
+    "package.json scope '{0}' explicitly maps specifier '{1}' to null.": {
+        "category": "Message",
+        "code": 6274
+    },
+    "package.json scope '{0}' has invalid type for target of specifier '{1}'": {
+        "category": "Message",
+        "code": 6275
+    },
+    "Export specifier '{0}' does not exist in package.json scope at path '{1}'.": {
+        "category": "Message",
+        "code": 6276
+    },
+
     "Enable project compilation": {
         "category": "Message",
         "code": 6302
@@ -5931,6 +5969,14 @@
         "category": "Error",
         "code": 7058
     },
+    "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.": {
+        "category": "Error",
+        "code": 7059
+    },
+    "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.": {
+        "category": "Error",
+        "code": 7060
+    },
 
 
     "You cannot rename this element.": {
diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts
index 23cdda71a2ac1..795239e13d6ec 100644
--- a/src/compiler/emitter.ts
+++ b/src/compiler/emitter.ts
@@ -89,7 +89,7 @@ namespace ts {
             return getOutputPathsForBundle(options, forceDtsPaths);
         }
         else {
-            const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
+            const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options));
             const isJsonFile = isJsonSourceFile(sourceFile);
             // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
             const isJsonEmittedToSameLocation = isJsonFile &&
@@ -106,27 +106,13 @@ namespace ts {
         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
     }
 
-    // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
-    // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
-    // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
     /* @internal */
-    export function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): Extension {
-        if (isJsonSourceFile(sourceFile)) {
-            return Extension.Json;
-        }
-
-        if (options.jsx === JsxEmit.Preserve) {
-            if (isSourceFileJS(sourceFile)) {
-                if (fileExtensionIs(sourceFile.fileName, Extension.Jsx)) {
-                    return Extension.Jsx;
-                }
-            }
-            else if (sourceFile.languageVariant === LanguageVariant.JSX) {
-                // TypeScript source file preserving JSX syntax
-                return Extension.Jsx;
-            }
-        }
-        return Extension.Js;
+    export function getOutputExtension(fileName: string, options: CompilerOptions): Extension {
+        return fileExtensionIs(fileName, Extension.Json) ? Extension.Json :
+        options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx :
+        fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs :
+        fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs :
+        Extension.Js;
     }
 
     function getOutputPathWithoutChangingExt(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, outputDir: string | undefined, getCommonSourceDirectory?: () => string) {
@@ -140,10 +126,9 @@ namespace ts {
 
     /* @internal */
     export function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, getCommonSourceDirectory?: () => string) {
-        Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts) && !fileExtensionIs(inputFileName, Extension.Json));
         return changeExtension(
             getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory),
-            Extension.Dts
+            getDeclarationEmitExtensionForPath(inputFileName)
         );
     }
 
@@ -152,11 +137,7 @@ namespace ts {
         const isJsonFile = fileExtensionIs(inputFileName, Extension.Json);
         const outputFileName = changeExtension(
             getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory),
-            isJsonFile ?
-                Extension.Json :
-                configFile.options.jsx === JsxEmit.Preserve && (fileExtensionIs(inputFileName, Extension.Tsx) || fileExtensionIs(inputFileName, Extension.Jsx)) ?
-                    Extension.Jsx :
-                    Extension.Js
+            getOutputExtension(inputFileName, configFile.options)
         );
         return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== Comparison.EqualTo ?
             outputFileName :
@@ -238,7 +219,7 @@ namespace ts {
     export function getCommonSourceDirectoryOfConfig({ options, fileNames }: ParsedCommandLine, ignoreCase: boolean): string {
         return getCommonSourceDirectory(
             options,
-            () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensions)) && !fileExtensionIs(file, Extension.Dts)),
+            () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensionsFlat)) && !fileExtensionIs(file, Extension.Dts)),
             getDirectoryPath(normalizeSlashes(Debug.checkDefined(options.configFilePath))),
             createGetCanonicalFileName(!ignoreCase)
         );
diff --git a/src/compiler/factory/emitHelpers.ts b/src/compiler/factory/emitHelpers.ts
index 85b00a5ef3e35..d0fd5e63dc51e 100644
--- a/src/compiler/factory/emitHelpers.ts
+++ b/src/compiler/factory/emitHelpers.ts
@@ -136,7 +136,7 @@ namespace ts {
         // ES2018 Helpers
 
         function createAssignHelper(attributesSegments: Expression[]) {
-            if (context.getCompilerOptions().target! >= ScriptTarget.ES2015) {
+            if (getEmitScriptTarget(context.getCompilerOptions()) >= ScriptTarget.ES2015) {
                 return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"),
                                   /*typeArguments*/ undefined,
                                   attributesSegments);
diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts
index 975e0934c9320..379c0d0929280 100644
--- a/src/compiler/factory/nodeFactory.ts
+++ b/src/compiler/factory/nodeFactory.ts
@@ -5175,6 +5175,7 @@ namespace ts {
             node.transformFlags =
                 propagateChildrenFlags(node.statements) |
                 propagateChildFlags(node.endOfFileToken);
+            node.impliedNodeFormat = source.impliedNodeFormat;
             return node;
         }
 
diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts
index 93851ccbba011..bfcaddba23fbe 100644
--- a/src/compiler/factory/utilities.ts
+++ b/src/compiler/factory/utilities.ts
@@ -481,7 +481,7 @@ namespace ts {
         if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
             let namedBindings: NamedImportBindings | undefined;
             const moduleKind = getEmitModuleKind(compilerOptions);
-            if (moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) {
+            if ((moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ModuleKind.ESNext) {
                 // use named imports
                 const helpers = getEmitHelpers(sourceFile);
                 if (helpers) {
@@ -539,9 +539,9 @@ namespace ts {
             }
 
             const moduleKind = getEmitModuleKind(compilerOptions);
-            let create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
+            let create = (hasExportStarsToExportValues || (getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault))
                 && moduleKind !== ModuleKind.System
-                && moduleKind < ModuleKind.ES2015;
+                && (moduleKind < ModuleKind.ES2015 || node.impliedNodeFormat === ModuleKind.CommonJS);
             if (!create) {
                 const helpers = getEmitHelpers(node);
                 if (helpers) {
diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts
index b5f83ae0b7109..6d45b769dd69b 100644
--- a/src/compiler/moduleNameResolver.ts
+++ b/src/compiler/moduleNameResolver.ts
@@ -96,6 +96,7 @@ namespace ts {
         };
     }
 
+    /*@internal*/
     interface ModuleResolutionState {
         host: ModuleResolutionHost;
         compilerOptions: CompilerOptions;
@@ -103,6 +104,8 @@ namespace ts {
         failedLookupLocations: Push<string>;
         resultFromCache?: ResolvedModuleWithFailedLookupLocations;
         packageJsonInfoCache: PackageJsonInfoCache | undefined;
+        features: NodeResolutionFeatures;
+        conditions: string[];
     }
 
     /** Just the fields that we use for module resolution. */
@@ -113,6 +116,10 @@ namespace ts {
         typesVersions?: MapLike<MapLike<string[]>>;
         main?: string;
         tsconfig?: string;
+        type?: string;
+        imports?: object;
+        exports?: object;
+        name?: string;
     }
 
     interface PackageJson extends PackageJsonPathFields {
@@ -298,7 +305,7 @@ namespace ts {
 
         const containingDirectory = containingFile ? getDirectoryPath(containingFile) : undefined;
         const perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
-        let result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName);
+        let result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined);
         if (result) {
             if (traceEnabled) {
                 trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -333,7 +340,7 @@ namespace ts {
         }
 
         const failedLookupLocations: string[] = [];
-        const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache };
+        const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
         let resolved = primaryLookup();
         let primary = true;
         if (!resolved) {
@@ -354,7 +361,7 @@ namespace ts {
             };
         }
         result = { resolvedTypeReferenceDirective, failedLookupLocations };
-        perFolderCache?.set(typeReferenceDirectiveName, result);
+        perFolderCache?.set(typeReferenceDirectiveName, /*mode*/ undefined, result);
         if (traceEnabled) traceResult(result);
         return result;
 
@@ -470,12 +477,21 @@ namespace ts {
     export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
     }
 
+    export interface ModeAwareCache<T> {
+        get(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): T | undefined;
+        set(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, value: T): this;
+        delete(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): this;
+        has(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): boolean;
+        forEach(cb: (elem: T, key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined) => void): void;
+        size(): number;
+    }
+
     /**
      * Cached resolutions per containing directory.
      * This assumes that any module id will have the same resolution for sibling files located in the same folder.
      */
     export interface PerDirectoryResolutionCache<T> {
-        getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map<T>;
+        getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): ModeAwareCache<T>;
         clear(): void;
         /**
          *  Updates with the current compilerOptions the cache will operate with.
@@ -493,7 +509,7 @@ namespace ts {
      * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive.
      */
     export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache {
-        getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
+        getOrCreateCacheForModuleName(nonRelativeModuleName: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
     }
 
     export interface PackageJsonInfoCache {
@@ -593,7 +609,7 @@ namespace ts {
 
     function updateRedirectsMap<T>(
         options: CompilerOptions,
-        directoryToModuleNameMap: CacheWithRedirects<ESMap<string, T>>,
+        directoryToModuleNameMap: CacheWithRedirects<ModeAwareCache<T>>,
         moduleNameToDirectoryMap?: CacheWithRedirects<PerModuleNameCache>
     ) {
         if (!options.configFile) return;
@@ -619,7 +635,7 @@ namespace ts {
         moduleNameToDirectoryMap?.setOwnOptions(options);
     }
 
-    function createPerDirectoryResolutionCache<T>(currentDirectory: string, getCanonicalFileName: GetCanonicalFileName, directoryToModuleNameMap: CacheWithRedirects<ESMap<string, T>>): PerDirectoryResolutionCache<T> {
+    function createPerDirectoryResolutionCache<T>(currentDirectory: string, getCanonicalFileName: GetCanonicalFileName, directoryToModuleNameMap: CacheWithRedirects<ModeAwareCache<T>>): PerDirectoryResolutionCache<T> {
         return {
             getOrCreateCacheForDirectory,
             clear,
@@ -636,8 +652,57 @@ namespace ts {
 
         function getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference) {
             const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
-            return getOrCreateCache<ESMap<string, T>>(directoryToModuleNameMap, redirectedReference, path, () => new Map());
+            return getOrCreateCache<ModeAwareCache<T>>(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
+        }
+    }
+
+    /* @internal */
+    export function createModeAwareCache<T>(): ModeAwareCache<T> {
+        const underlying = new Map<string, T>();
+        const memoizedReverseKeys = new Map<string, [specifier: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined]>();
+
+        const cache: ModeAwareCache<T> = {
+            get(specifier, mode) {
+                return underlying.get(getUnderlyingCacheKey(specifier, mode));
+            },
+            set(specifier, mode, value) {
+                underlying.set(getUnderlyingCacheKey(specifier, mode), value);
+                return cache;
+            },
+            delete(specifier, mode) {
+                underlying.delete(getUnderlyingCacheKey(specifier, mode));
+                return cache;
+            },
+            has(specifier, mode) {
+                return underlying.has(getUnderlyingCacheKey(specifier, mode));
+            },
+            forEach(cb) {
+                return underlying.forEach((elem, key) => {
+                    const [specifier, mode] = memoizedReverseKeys.get(key)!;
+                    return cb(elem, specifier, mode);
+                });
+            },
+            size() {
+                return underlying.size;
+            }
+        };
+        return cache;
+
+        function getUnderlyingCacheKey(specifier: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined) {
+            const result = mode === undefined ? specifier : `${mode}|${specifier}`;
+            memoizedReverseKeys.set(result, [specifier, mode]);
+            return result;
+        }
+    }
+
+    /* @internal */
+    export function zipToModeAwareCache<V>(file: SourceFile, keys: readonly string[], values: readonly V[]): ModeAwareCache<V> {
+        Debug.assert(keys.length === values.length);
+        const map = createModeAwareCache<V>();
+        for (let i = 0; i < keys.length; ++i) {
+            map.set(keys[i], getModeForResolutionAtIndex(file, i), values[i]);
         }
+        return map;
     }
 
     export function createModuleResolutionCache(
@@ -650,14 +715,14 @@ namespace ts {
         currentDirectory: string,
         getCanonicalFileName: GetCanonicalFileName,
         options: undefined,
-        directoryToModuleNameMap: CacheWithRedirects<ESMap<string, ResolvedModuleWithFailedLookupLocations>>,
+        directoryToModuleNameMap: CacheWithRedirects<ModeAwareCache<ResolvedModuleWithFailedLookupLocations>>,
         moduleNameToDirectoryMap: CacheWithRedirects<PerModuleNameCache>,
     ): ModuleResolutionCache;
     export function createModuleResolutionCache(
         currentDirectory: string,
         getCanonicalFileName: GetCanonicalFileName,
         options?: CompilerOptions,
-        directoryToModuleNameMap?: CacheWithRedirects<ESMap<string, ResolvedModuleWithFailedLookupLocations>>,
+        directoryToModuleNameMap?: CacheWithRedirects<ModeAwareCache<ResolvedModuleWithFailedLookupLocations>>,
         moduleNameToDirectoryMap?: CacheWithRedirects<PerModuleNameCache>,
     ): ModuleResolutionCache {
         const preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options));
@@ -683,9 +748,9 @@ namespace ts {
             updateRedirectsMap(options, directoryToModuleNameMap!, moduleNameToDirectoryMap);
         }
 
-        function getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache {
+        function getOrCreateCacheForModuleName(nonRelativeModuleName: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, redirectedReference?: ResolvedProjectReference): PerModuleNameCache {
             Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
-            return getOrCreateCache(moduleNameToDirectoryMap!, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
+            return getOrCreateCache(moduleNameToDirectoryMap!, redirectedReference, mode === undefined ? nonRelativeModuleName : `${mode}|${nonRelativeModuleName}`, createPerModuleNameCache);
         }
 
         function createPerModuleNameCache(): PerModuleNameCache {
@@ -773,14 +838,14 @@ namespace ts {
         getCanonicalFileName: GetCanonicalFileName,
         options: undefined,
         packageJsonInfoCache: PackageJsonInfoCache | undefined,
-        directoryToModuleNameMap: CacheWithRedirects<ESMap<string, ResolvedTypeReferenceDirectiveWithFailedLookupLocations>>,
+        directoryToModuleNameMap: CacheWithRedirects<ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>>,
     ): TypeReferenceDirectiveResolutionCache;
     export function createTypeReferenceDirectiveResolutionCache(
         currentDirectory: string,
         getCanonicalFileName: GetCanonicalFileName,
         options?: CompilerOptions,
         packageJsonInfoCache?: PackageJsonInfoCache | undefined,
-        directoryToModuleNameMap?: CacheWithRedirects<ESMap<string, ResolvedTypeReferenceDirectiveWithFailedLookupLocations>>,
+        directoryToModuleNameMap?: CacheWithRedirects<ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>>,
     ): TypeReferenceDirectiveResolutionCache {
         const preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options));
         packageJsonInfoCache ||= createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
@@ -797,13 +862,14 @@ namespace ts {
         }
     }
 
-    export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined {
+    export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined {
         const containingDirectory = getDirectoryPath(containingFile);
         const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
-        return perFolderCache && perFolderCache.get(moduleName);
+        if (!perFolderCache) return undefined;
+        return perFolderCache.get(moduleName, mode);
     }
 
-    export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations {
+    export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations {
         const traceEnabled = isTraceEnabled(compilerOptions, host);
         if (redirectedReference) {
             compilerOptions = redirectedReference.commandLine.options;
@@ -816,7 +882,7 @@ namespace ts {
         }
         const containingDirectory = getDirectoryPath(containingFile);
         const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
-        let result = perFolderCache && perFolderCache.get(moduleName);
+        let result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
 
         if (result) {
             if (traceEnabled) {
@@ -826,7 +892,20 @@ namespace ts {
         else {
             let moduleResolution = compilerOptions.moduleResolution;
             if (moduleResolution === undefined) {
-                moduleResolution = getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
+                switch (getEmitModuleKind(compilerOptions)) {
+                    case ModuleKind.CommonJS:
+                        moduleResolution = ModuleResolutionKind.NodeJs;
+                        break;
+                    case ModuleKind.Node12:
+                        moduleResolution = ModuleResolutionKind.Node12;
+                        break;
+                    case ModuleKind.NodeNext:
+                        moduleResolution = ModuleResolutionKind.NodeNext;
+                        break;
+                    default:
+                        moduleResolution = ModuleResolutionKind.Classic;
+                        break;
+                }
                 if (traceEnabled) {
                     trace(host, Diagnostics.Module_resolution_kind_is_not_specified_using_0, ModuleResolutionKind[moduleResolution]);
                 }
@@ -839,6 +918,12 @@ namespace ts {
 
             perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/);
             switch (moduleResolution) {
+                case ModuleResolutionKind.Node12:
+                    result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
+                    break;
+                case ModuleResolutionKind.NodeNext:
+                    result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
+                    break;
                 case ModuleResolutionKind.NodeJs:
                     result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
                     break;
@@ -852,10 +937,10 @@ namespace ts {
             perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
 
             if (perFolderCache) {
-                perFolderCache.set(moduleName, result);
+                perFolderCache.set(moduleName, resolutionMode, result);
                 if (!isExternalModuleNameRelative(moduleName)) {
                     // put result in per-module name cache
-                    cache!.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
+                    cache!.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
                 }
             }
         }
@@ -1087,25 +1172,90 @@ namespace ts {
         return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
     }
 
+    /* @internal */
+    enum NodeResolutionFeatures {
+        None = 0,
+        // resolving `#local` names in your own package.json
+        Imports = 1 << 1,
+        // resolving `your-own-name` from your own package.json
+        SelfName = 1 << 2,
+        // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names
+        Exports = 1 << 3,
+        // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"`
+        // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
+        ExportsPatternTrailers = 1 << 4,
+        AllFeatures = Imports | SelfName | Exports | ExportsPatternTrailers,
+
+        EsmMode = 1 << 5,
+    }
+
+    function node12ModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions,
+            host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
+            resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations {
+        return nodeNextModuleNameResolverWorker(
+            NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports,
+            moduleName,
+            containingFile,
+            compilerOptions,
+            host,
+            cache,
+            redirectedReference,
+            resolutionMode
+        );
+    }
+
+    function nodeNextModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions,
+            host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
+            resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations {
+        return nodeNextModuleNameResolverWorker(
+            NodeResolutionFeatures.AllFeatures,
+            moduleName,
+            containingFile,
+            compilerOptions,
+            host,
+            cache,
+            redirectedReference,
+            resolutionMode
+        );
+    }
+
+    function nodeNextModuleNameResolverWorker(features: NodeResolutionFeatures, moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations {
+        const containingDirectory = getDirectoryPath(containingFile);
+
+        // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
+        const esmMode = resolutionMode === ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
+        return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
+    }
+
     const jsOnlyExtensions = [Extensions.JavaScript];
     const tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
     const tsPlusJsonExtensions = [...tsExtensions, Extensions.Json];
     const tsconfigExtensions = [Extensions.TSConfig];
     function tryResolveJSModuleWorker(moduleName: string, initialDir: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
-        return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
+        return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
     }
 
     export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
     /* @internal */ export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations; // eslint-disable-line @typescript-eslint/unified-signatures
     export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations {
-        return nodeModuleNameResolverWorker(moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
+        return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
     }
 
-    function nodeModuleNameResolverWorker(moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, extensions: Extensions[], redirectedReference: ResolvedProjectReference | undefined): ResolvedModuleWithFailedLookupLocations {
+    function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, extensions: Extensions[], redirectedReference: ResolvedProjectReference | undefined): ResolvedModuleWithFailedLookupLocations {
         const traceEnabled = isTraceEnabled(compilerOptions, host);
 
         const failedLookupLocations: string[] = [];
-        const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache };
+        // conditions are only used by the node12/nodenext resolver - 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 state: ModuleResolutionState = {
+            compilerOptions,
+            host,
+            traceEnabled,
+            failedLookupLocations,
+            packageJsonInfoCache: cache,
+            features,
+            conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
+        };
 
         const result = forEach(extensions, ext => tryResolve(ext));
         return createResolvedModuleWithFailedLookupLocations(result?.value?.resolved, result?.value?.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
@@ -1118,10 +1268,19 @@ namespace ts {
             }
 
             if (!isExternalModuleNameRelative(moduleName)) {
-                if (traceEnabled) {
-                    trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
+                let resolved: SearchResult<Resolved> | undefined;
+                if (features & NodeResolutionFeatures.Imports && startsWith(moduleName, "#")) {
+                    resolved = loadModuleFromImports(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
+                }
+                if (!resolved && features & NodeResolutionFeatures.SelfName) {
+                    resolved = loadModuleFromSelfNameReference(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
+                }
+                if (!resolved) {
+                    if (traceEnabled) {
+                        trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
+                    }
+                    resolved = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
                 }
-                const resolved = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
                 if (!resolved) return undefined;
 
                 let resolvedValue = resolved.value;
@@ -1237,29 +1396,46 @@ namespace ts {
     function loadModuleFromFile(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined {
         if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
             const extensionLess = tryRemoveExtension(candidate, Extension.Json);
-            return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state);
+            const extension = extensionLess ? candidate.substring(extensionLess.length) : "";
+            return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state);
         }
 
-        // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
-        const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state);
-        if (resolvedByAddingExtension) {
-            return resolvedByAddingExtension;
+        // esm mode resolutions don't include automatic extension lookup (without additional flags, at least)
+        if (!(state.features & NodeResolutionFeatures.EsmMode)) {
+            // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
+            const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state);
+            if (resolvedByAddingExtension) {
+                return resolvedByAddingExtension;
+            }
         }
 
+        return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
+    }
+
+    function loadModuleFromFileNoImplicitExtensions(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined {
         // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
         // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
-        if (hasJSFileExtension(candidate)) {
+        if (hasJSFileExtension(candidate) || (fileExtensionIs(candidate, Extension.Json) && state.compilerOptions.resolveJsonModule)) {
             const extensionless = removeFileExtension(candidate);
+            const extension = candidate.substring(extensionless.length);
             if (state.traceEnabled) {
-                const extension = candidate.substring(extensionless.length);
                 trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
             }
-            return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
+            return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
+        }
+    }
+
+    function loadJSOrExactTSFileName(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined {
+        if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && fileExtensionIsOneOf(candidate, [Extension.Dts, Extension.Dcts, Extension.Dmts])) {
+            const result = tryFile(candidate, onlyRecordFailures, state);
+            return result !== undefined ? { path: candidate, ext: forEach([Extension.Dts, Extension.Dcts, Extension.Dmts], e => fileExtensionIs(candidate, e) ? e : undefined)! } : undefined;
         }
+
+        return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
     }
 
     /** Try to return an existing file that adds one of the `extensions` to `candidate`. */
-    function tryAddingExtensions(candidate: string, extensions: Extensions, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined {
+    function tryAddingExtensions(candidate: string, extensions: Extensions, originalExtension: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined {
         if (!onlyRecordFailures) {
             // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
             const directory = getDirectoryPath(candidate);
@@ -1270,11 +1446,51 @@ namespace ts {
 
         switch (extensions) {
             case Extensions.DtsOnly:
-                return tryExtension(Extension.Dts);
+                switch (originalExtension) {
+                    case Extension.Mjs:
+                    case Extension.Mts:
+                    case Extension.Dmts:
+                        return tryExtension(Extension.Dmts);
+                    case Extension.Cjs:
+                    case Extension.Cts:
+                    case Extension.Dcts:
+                        return tryExtension(Extension.Dcts);
+                    case Extension.Json:
+                        candidate += Extension.Json;
+                        return tryExtension(Extension.Dts);
+                    default: return tryExtension(Extension.Dts);
+                }
             case Extensions.TypeScript:
-                return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts);
+                switch (originalExtension) {
+                    case Extension.Mjs:
+                    case Extension.Mts:
+                    case Extension.Dmts:
+                        return tryExtension(Extension.Mts) || tryExtension(Extension.Dmts);
+                    case Extension.Cjs:
+                    case Extension.Cts:
+                    case Extension.Dcts:
+                        return tryExtension(Extension.Cts) || tryExtension(Extension.Dcts);
+                    case Extension.Json:
+                        candidate += Extension.Json;
+                        return tryExtension(Extension.Dts);
+                    default:
+                        return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts);
+                }
             case Extensions.JavaScript:
-                return tryExtension(Extension.Js) || tryExtension(Extension.Jsx);
+                switch (originalExtension) {
+                    case Extension.Mjs:
+                    case Extension.Mts:
+                    case Extension.Dmts:
+                        return tryExtension(Extension.Mjs);
+                    case Extension.Cjs:
+                    case Extension.Cts:
+                    case Extension.Dcts:
+                        return tryExtension(Extension.Cjs);
+                    case Extension.Json:
+                        return tryExtension(Extension.Json);
+                    default:
+                        return tryExtension(Extension.Js) || tryExtension(Extension.Jsx);
+                }
             case Extensions.TSConfig:
             case Extensions.Json:
                 return tryExtension(Extension.Json);
@@ -1319,7 +1535,43 @@ namespace ts {
         versionPaths: VersionPaths | undefined;
     }
 
-    function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PackageJsonInfo | undefined {
+    /**
+     * A function for locating the package.json scope for a given path
+     */
+    /*@internal*/
+     export function getPackageScopeForPath(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): PackageJsonInfo | undefined {
+        const state: {
+            host: ModuleResolutionHost;
+            compilerOptions: CompilerOptions;
+            traceEnabled: boolean;
+            failedLookupLocations: Push<string>;
+            resultFromCache?: ResolvedModuleWithFailedLookupLocations;
+            packageJsonInfoCache: PackageJsonInfoCache | undefined;
+            features: number;
+            conditions: never[];
+        } = {
+            host,
+            compilerOptions: options,
+            traceEnabled: isTraceEnabled(options, host),
+            failedLookupLocations: [],
+            packageJsonInfoCache,
+            features: 0,
+            conditions: [],
+        };
+        const parts = getPathComponents(fileName);
+        parts.pop();
+        while (parts.length > 0) {
+            const pkg = getPackageJsonInfo(getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
+            if (pkg) {
+                return pkg;
+            }
+            parts.pop();
+        }
+        return undefined;
+    }
+
+    /*@internal*/
+    export function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PackageJsonInfo | undefined {
         const { host, traceEnabled } = state;
         const packageJsonPath = combinePaths(packageDirectory, "package.json");
         if (onlyRecordFailures) {
@@ -1420,7 +1672,10 @@ namespace ts {
         const packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile!, state));
         if (packageFileResult) return packageFileResult;
 
-        return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
+        // esm mode resolutions don't do package `index` lookups
+        if (!(state.features & NodeResolutionFeatures.EsmMode)) {
+            return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
+        }
     }
 
     /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */
@@ -1453,7 +1708,231 @@ namespace ts {
         return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
     }
 
-    function loadModuleFromNearestNodeModulesDirectory(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, cache: NonRelativeModuleNameResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
+    function allKeysStartWithDot(obj: MapLike<unknown>) {
+        return every(getOwnKeys(obj), k => startsWith(k, "."));
+    }
+
+    function noKeyStartsWithDot(obj: MapLike<unknown>) {
+        return !some(getOwnKeys(obj), k => startsWith(k, "."));
+    }
+
+    function loadModuleFromSelfNameReference(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
+        const useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
+        const directoryPath = toPath(combinePaths(directory, "dummy"), state.host.getCurrentDirectory?.(), createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
+        const scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
+        if (!scope || !scope.packageJsonContent.exports) {
+            return undefined;
+        }
+        const parts = getPathComponents(moduleName); // unrooted paths should have `""` as their 0th entry
+        if (scope.packageJsonContent.name !== parts[1]) {
+            return undefined;
+        }
+        const trailingParts = parts.slice(2);
+        return loadModuleFromExports(scope, extensions, !length(trailingParts) ? "." : `.${directorySeparator}${trailingParts.join(directorySeparator)}`, state, cache, redirectedReference);
+    }
+
+    function loadModuleFromExports(scope: PackageJsonInfo, extensions: Extensions, subpath: string, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
+        if (!scope.packageJsonContent.exports) {
+            return undefined;
+        }
+
+        if (subpath === ".") {
+            let mainExport;
+            if (typeof scope.packageJsonContent.exports === "string" || Array.isArray(scope.packageJsonContent.exports) || (typeof scope.packageJsonContent.exports === "object" && noKeyStartsWithDot(scope.packageJsonContent.exports as MapLike<unknown>))) {
+                mainExport = scope.packageJsonContent.exports;
+            }
+            else if (hasProperty(scope.packageJsonContent.exports as MapLike<unknown>, ".")) {
+                mainExport = (scope.packageJsonContent.exports as MapLike<unknown>)["."];
+            }
+            if (mainExport) {
+                const loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
+                return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
+            }
+        }
+        else if (allKeysStartWithDot(scope.packageJsonContent.exports as MapLike<unknown>)) {
+            if (typeof scope.packageJsonContent.exports !== "object") {
+                if (state.traceEnabled) {
+                    trace(state.host, Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
+                }
+                return toSearchResult(/*value*/ undefined);
+            }
+            const result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, subpath, scope.packageJsonContent.exports, scope, /*isImports*/ false);
+            if (result) {
+                return result;
+            }
+        }
+
+        if (state.traceEnabled) {
+            trace(state.host, Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
+        }
+        return toSearchResult(/*value*/ undefined);
+    }
+
+    function loadModuleFromImports(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
+        if (moduleName === "#" || startsWith(moduleName, "#/")) {
+            if (state.traceEnabled) {
+                trace(state.host, Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName);
+            }
+            return toSearchResult(/*value*/ undefined);
+        }
+        const useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
+        const directoryPath = toPath(combinePaths(directory, "dummy"), state.host.getCurrentDirectory?.(), createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
+        const scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
+        if (!scope) {
+            if (state.traceEnabled) {
+                trace(state.host, Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
+            }
+            return toSearchResult(/*value*/ undefined);
+        }
+        if (!scope.packageJsonContent.imports) {
+            if (state.traceEnabled) {
+                trace(state.host, Diagnostics.package_json_scope_0_has_no_imports_defined, scope.packageDirectory);
+            }
+            return toSearchResult(/*value*/ undefined);
+        }
+
+        const result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, scope.packageJsonContent.imports, scope, /*isImports*/ true);
+        if (result) {
+            return result;
+        }
+
+        if (state.traceEnabled) {
+            trace(state.host, Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, moduleName, scope.packageDirectory);
+        }
+        return toSearchResult(/*value*/ undefined);
+    }
+
+    function loadModuleFromImportsOrExports(extensions: Extensions, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined, moduleName: string, lookupTable: object, scope: PackageJsonInfo, isImports: boolean): SearchResult<Resolved> | undefined {
+        const loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
+
+        if (!endsWith(moduleName, directorySeparator) && moduleName.indexOf("*") === -1 && hasProperty(lookupTable, moduleName)) {
+            const target = (lookupTable as {[idx: string]: unknown})[moduleName];
+            return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
+        }
+        const expandingKeys = sort(filter(getOwnKeys(lookupTable as MapLike<unknown>), k => k.indexOf("*") !== -1 || endsWith(k, "/")), (a, b) => a.length - b.length);
+        for (const potentialTarget of expandingKeys) {
+            if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
+                const target = (lookupTable as {[idx: string]: unknown})[potentialTarget];
+                const starPos = potentialTarget.indexOf("*");
+                const subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
+                return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
+            }
+            else if (endsWith(potentialTarget, "*") && startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
+                const target = (lookupTable as {[idx: string]: unknown})[potentialTarget];
+                const subpath = moduleName.substring(potentialTarget.length - 1);
+                return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
+            }
+            else if (startsWith(moduleName, potentialTarget)) {
+                const target = (lookupTable as {[idx: string]: unknown})[potentialTarget];
+                const subpath = moduleName.substring(potentialTarget.length);
+                return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
+            }
+        }
+
+        function matchesPatternWithTrailer(target: string, name: string) {
+            if (endsWith(target, "*")) return false; // handled by next case in loop
+            const starPos = target.indexOf("*");
+            if (starPos === -1) return false; // handled by last case in loop
+            return startsWith(name, target.substring(0, starPos)) && endsWith(name, target.substring(starPos + 1));
+        }
+    }
+
+    /**
+     * Gets the self-recursive function specialized to retrieving the targeted import/export element for the given resolution configuration
+     */
+    function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined, moduleName: string, scope: PackageJsonInfo, isImports: boolean) {
+        return loadModuleFromTargetImportOrExport;
+        function loadModuleFromTargetImportOrExport(target: unknown, subpath: string, pattern: boolean): SearchResult<Resolved> | undefined {
+            if (typeof target === "string") {
+                if (!pattern && subpath.length > 0 && !endsWith(target, "/")) {
+                    if (state.traceEnabled) {
+                        trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
+                    }
+                    return toSearchResult(/*value*/ undefined);
+                }
+                if (!startsWith(target, "./")) {
+                    if (isImports && !startsWith(target, "../") && !startsWith(target, "/") && !isRootedDiskPath(target)) {
+                        const combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
+                        const result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
+                        return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
+                    }
+                    if (state.traceEnabled) {
+                        trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
+                    }
+                    return toSearchResult(/*value*/ undefined);
+                }
+                const parts = pathIsRelative(target) ? getPathComponents(target).slice(1) : getPathComponents(target);
+                const partsAfterFirst = parts.slice(1);
+                if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
+                    if (state.traceEnabled) {
+                        trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
+                    }
+                    return toSearchResult(/*value*/ undefined);
+                }
+                const resolvedTarget = combinePaths(scope.packageDirectory, target);
+                // TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need
+                // to be in the business of validating everyone's import and export map correctness.
+                const subpathParts = getPathComponents(subpath);
+                if (subpathParts.indexOf("..") >= 0 || subpathParts.indexOf(".") >= 0 || subpathParts.indexOf("node_modules") >= 0) {
+                    if (state.traceEnabled) {
+                        trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
+                    }
+                    return toSearchResult(/*value*/ undefined);
+                }
+                const finalPath = getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, state.host.getCurrentDirectory?.());
+
+                return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
+            }
+            else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
+                if (!Array.isArray(target)) {
+                    for (const key of getOwnKeys(target as MapLike<unknown>)) {
+                        if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
+                            const subTarget = (target as MapLike<unknown>)[key];
+                            const result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
+                            if (result) {
+                                return result;
+                            }
+                        }
+                    }
+                    return undefined;
+                }
+                else {
+                    if (!length(target)) {
+                        if (state.traceEnabled) {
+                            trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
+                        }
+                        return toSearchResult(/*value*/ undefined);
+                    }
+                    for (const elem of target) {
+                        const result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
+                        if (result) {
+                            return result;
+                        }
+                    }
+                }
+            }
+            else if (target === null) { // eslint-disable-line no-null/no-null
+                if (state.traceEnabled) {
+                    trace(state.host, Diagnostics.package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.packageDirectory, moduleName);
+                }
+                return toSearchResult(/*value*/ undefined);
+            }
+            if (state.traceEnabled) {
+                trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
+            }
+            return toSearchResult(/*value*/ undefined);
+        }
+
+        function isApplicableVersionedTypesKey(conditions: string[], key: string) {
+            if (conditions.indexOf("types") === -1) return false; // only apply versioned types conditions if the types condition is applied
+            if (!startsWith(key, "types@")) return false;
+            const range = VersionRange.tryParse(key.substring("types@".length));
+            if (!range) return false;
+            return range.test(version);
+        }
+    }
+
+    function loadModuleFromNearestNodeModulesDirectory(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
         return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
     }
 
@@ -1462,27 +1941,27 @@ namespace ts {
         return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
     }
 
-    function loadModuleFromNearestNodeModulesDirectoryWorker(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, typesScopeOnly: boolean, cache: NonRelativeModuleNameResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
-        const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
+    function loadModuleFromNearestNodeModulesDirectoryWorker(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, typesScopeOnly: boolean, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
+        const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ModuleKind.ESNext : ModuleKind.CommonJS, redirectedReference);
         return forEachAncestorDirectory(normalizeSlashes(directory), ancestorDirectory => {
             if (getBaseFileName(ancestorDirectory) !== "node_modules") {
                 const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
                 if (resolutionFromCache) {
                     return resolutionFromCache;
                 }
-                return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
+                return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
             }
         });
     }
 
-    function loadModuleFromImmediateNodeModulesDirectory(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, typesScopeOnly: boolean): Resolved | undefined {
+    function loadModuleFromImmediateNodeModulesDirectory(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, typesScopeOnly: boolean, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): Resolved | undefined {
         const nodeModulesFolder = combinePaths(directory, "node_modules");
         const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host);
         if (!nodeModulesFolderExists && state.traceEnabled) {
             trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
         }
 
-        const packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
+        const packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference);
         if (packageResult) {
             return packageResult;
         }
@@ -1495,33 +1974,41 @@ namespace ts {
                 }
                 nodeModulesAtTypesExists = false;
             }
-            return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes, nodeModulesAtTypesExists, state);
+            return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes, nodeModulesAtTypesExists, state, cache, redirectedReference);
         }
     }
 
-    function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, moduleName: string, nodeModulesDirectory: string, nodeModulesDirectoryExists: boolean, state: ModuleResolutionState): Resolved | undefined {
+    function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, moduleName: string, nodeModulesDirectory: string, nodeModulesDirectoryExists: boolean, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): Resolved | undefined {
         const candidate = normalizePath(combinePaths(nodeModulesDirectory, moduleName));
 
         // First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
         let packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
-        if (packageInfo) {
-            const fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
-            if (fromFile) {
-                return noPackageId(fromFile);
-            }
+        // But only if we're not respecting export maps (if we are, we might redirect around this location)
+        if (!(state.features & NodeResolutionFeatures.Exports)) {
+            if (packageInfo) {
+                const fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
+                if (fromFile) {
+                    return noPackageId(fromFile);
+                }
 
-            const fromDirectory = loadNodeModuleFromDirectoryWorker(
-                extensions,
-                candidate,
-                !nodeModulesDirectoryExists,
-                state,
-                packageInfo.packageJsonContent,
-                packageInfo.versionPaths
-            );
-            return withPackageId(packageInfo, fromDirectory);
+                const fromDirectory = loadNodeModuleFromDirectoryWorker(
+                    extensions,
+                    candidate,
+                    !nodeModulesDirectoryExists,
+                    state,
+                    packageInfo.packageJsonContent,
+                    packageInfo.versionPaths
+                );
+                return withPackageId(packageInfo, fromDirectory);
+            }
         }
 
+        const { packageName, rest } = parsePackageName(moduleName);
         const loader: ResolutionKindSpecificLoader = (extensions, candidate, onlyRecordFailures, state) => {
+            // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
+            if (packageInfo && packageInfo.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
+                return loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)?.value;
+            }
             const pathAndExtension =
                 loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
                 loadNodeModuleFromDirectoryWorker(
@@ -1535,7 +2022,6 @@ namespace ts {
             return withPackageId(packageInfo, pathAndExtension);
         };
 
-        const { packageName, rest } = parsePackageName(moduleName);
         if (rest !== "") { // If "rest" is empty, we just did this search above.
             const packageDirectory = combinePaths(nodeModulesDirectory, packageName);
 
@@ -1644,7 +2130,7 @@ namespace ts {
     export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations {
         const traceEnabled = isTraceEnabled(compilerOptions, host);
         const failedLookupLocations: string[] = [];
-        const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache };
+        const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
         const containingDirectory = getDirectoryPath(containingFile);
 
         const resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
@@ -1658,7 +2144,7 @@ namespace ts {
             }
 
             if (!isExternalModuleNameRelative(moduleName)) {
-                const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
+                const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
                 // Climb up parent directories looking for a module.
                 const resolved = forEachAncestorDirectory(containingDirectory, directory => {
                     const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, state);
@@ -1694,8 +2180,8 @@ namespace ts {
             trace(host, Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
         }
         const failedLookupLocations: string[] = [];
-        const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache };
-        const resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false);
+        const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
+        const resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
         return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
     }
 
diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts
index f246f44c013d4..620e28c984baa 100644
--- a/src/compiler/moduleSpecifiers.ts
+++ b/src/compiler/moduleSpecifiers.ts
@@ -11,7 +11,7 @@ namespace ts.moduleSpecifiers {
         readonly ending: Ending;
     }
 
-    function getPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }: UserPreferences, compilerOptions: CompilerOptions, importingSourceFile: SourceFile): Preferences {
+    function getPreferences(host: ModuleSpecifierResolutionHost, { importModuleSpecifierPreference, importModuleSpecifierEnding }: UserPreferences, compilerOptions: CompilerOptions, importingSourceFile: SourceFile): Preferences {
         return {
             relativePreference:
                 importModuleSpecifierPreference === "relative" ? RelativePreference.Relative :
@@ -25,21 +25,40 @@ namespace ts.moduleSpecifiers {
                 case "minimal": return Ending.Minimal;
                 case "index": return Ending.Index;
                 case "js": return Ending.JsExtension;
-                default: return usesJsExtensionOnImports(importingSourceFile) ? Ending.JsExtension
+                default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? Ending.JsExtension
                     : getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeJs ? Ending.Index : Ending.Minimal;
             }
         }
     }
 
-    function getPreferencesForUpdate(compilerOptions: CompilerOptions, oldImportSpecifier: string): Preferences {
+    function getPreferencesForUpdate(compilerOptions: CompilerOptions, oldImportSpecifier: string, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost): Preferences {
         return {
             relativePreference: isExternalModuleNameRelative(oldImportSpecifier) ? RelativePreference.Relative : RelativePreference.NonRelative,
-            ending: hasJSFileExtension(oldImportSpecifier) ?
+            ending: hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ?
                 Ending.JsExtension :
                 getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeJs || endsWith(oldImportSpecifier, "index") ? Ending.Index : Ending.Minimal,
         };
     }
 
+    function isFormatRequiringExtensions(compilerOptions: CompilerOptions, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost) {
+        if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12
+        && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
+            return false;
+        }
+        return getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ModuleKind.CommonJS;
+    }
+
+    function getModuleResolutionHost(host: ModuleSpecifierResolutionHost): ModuleResolutionHost {
+        return {
+            fileExists: host.fileExists,
+            readFile: Debug.checkDefined(host.readFile),
+            directoryExists: host.directoryExists,
+            getCurrentDirectory: host.getCurrentDirectory,
+            realpath: host.realpath,
+            useCaseSensitiveFileNames: host.useCaseSensitiveFileNames?.(),
+        };
+    }
+
     export function updateModuleSpecifier(
         compilerOptions: CompilerOptions,
         importingSourceFileName: Path,
@@ -47,7 +66,7 @@ namespace ts.moduleSpecifiers {
         host: ModuleSpecifierResolutionHost,
         oldImportSpecifier: string,
     ): string | undefined {
-        const res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier), {});
+        const res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
         if (res === oldImportSpecifier) return undefined;
         return res;
     }
@@ -60,7 +79,7 @@ namespace ts.moduleSpecifiers {
         toFileName: string,
         host: ModuleSpecifierResolutionHost,
     ): string {
-        return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile), {});
+        return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
     }
 
     export function getNodeModulesPackageName(
@@ -175,7 +194,7 @@ namespace ts.moduleSpecifiers {
         userPreferences: UserPreferences,
     ): readonly string[] {
         const info = getInfo(importingSourceFile.path, host);
-        const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
+        const preferences = getPreferences(host, userPreferences, compilerOptions, importingSourceFile);
         const existingSpecifier = forEach(modulePaths, modulePath => forEach(
             host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
             reason => {
@@ -652,7 +671,7 @@ namespace ts.moduleSpecifiers {
     function tryGetAnyFileFromPath(host: ModuleSpecifierResolutionHost, path: string) {
         if (!host.fileExists) return;
         // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
-        const extensions = getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: ScriptKind.JSON }]);
+        const extensions = flatten(getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: ScriptKind.JSON }]));
         for (const e of extensions) {
             const fullPath = path + e;
             if (host.fileExists(fullPath)) {
@@ -733,8 +752,9 @@ namespace ts.moduleSpecifiers {
     }
 
     function removeExtensionAndIndexPostFix(fileName: string, ending: Ending, options: CompilerOptions): string {
-        if (fileExtensionIs(fileName, Extension.Json)) return fileName;
+        if (fileExtensionIsOneOf(fileName, [Extension.Json, Extension.Mjs, Extension.Cjs])) return fileName;
         const noExtension = removeFileExtension(fileName);
+        if (fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Dcts, Extension.Cts])) return noExtension + getJSExtensionForFile(fileName, options);
         switch (ending) {
             case Ending.Minimal:
                 return removeSuffix(noExtension, "/index");
@@ -763,6 +783,14 @@ namespace ts.moduleSpecifiers {
             case Extension.Jsx:
             case Extension.Json:
                 return ext;
+            case Extension.Dmts:
+            case Extension.Mts:
+            case Extension.Mjs:
+                return Extension.Mjs;
+            case Extension.Dcts:
+            case Extension.Cts:
+            case Extension.Cjs:
+                return Extension.Cjs;
             default:
                 return undefined;
         }
diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts
index 4040ec3d7d584..dd6fa14566eaa 100644
--- a/src/compiler/parser.ts
+++ b/src/compiler/parser.ts
@@ -8675,6 +8675,7 @@ namespace ts {
                 newText,
                 aggressiveChecks
             );
+            result.impliedNodeFormat = sourceFile.impliedNodeFormat;
             return result;
         }
 
@@ -9215,7 +9216,7 @@ namespace ts {
 
     /** @internal */
     export function isDeclarationFileName(fileName: string): boolean {
-        return fileExtensionIs(fileName, Extension.Dts);
+        return fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Dmts, Extension.Dcts]);
     }
 
     /*@internal*/
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index 58affcfdb13ee..663abb30314cc 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -529,6 +529,58 @@ namespace ts {
         return resolutions;
     }
 
+    /* @internal */
+    interface SourceFileImportsList {
+        imports: SourceFile["imports"];
+        moduleAugmentations: SourceFile["moduleAugmentations"];
+        impliedNodeFormat?: SourceFile["impliedNodeFormat"];
+    };
+
+    /* @internal */
+    export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number) {
+        if (file.impliedNodeFormat === undefined) return undefined;
+        // we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup,
+        // so it's safe to use them even pre-bind
+        return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index));
+    }
+
+    /* @internal */
+    export function getModeForUsageLocation(file: {impliedNodeFormat?: SourceFile["impliedNodeFormat"]}, usage: StringLiteralLike) {
+        if (file.impliedNodeFormat === undefined) return undefined;
+        if (file.impliedNodeFormat !== ModuleKind.ESNext) {
+            // in cjs files, import call expressions are esm format, otherwise everything is cjs
+            return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? ModuleKind.ESNext : ModuleKind.CommonJS;
+        }
+        // in esm files, import=require statements are cjs format, otherwise everything is esm
+        // imports are only parent'd up to their containing declaration/expression, so access farther parents with care
+        const exprParentParent = walkUpParenthesizedExpressions(usage.parent)?.parent;
+        return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? ModuleKind.CommonJS : ModuleKind.ESNext;
+    }
+
+    /* @internal */
+    export function loadWithModeAwareCache<T>(names: string[], containingFile: SourceFile, containingFileName: string, redirectedReference: ResolvedProjectReference | undefined, loader: (name: string, resolverMode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, containingFileName: string, redirectedReference: ResolvedProjectReference | undefined) => T): T[] {
+        if (names.length === 0) {
+            return [];
+        }
+        const resolutions: T[] = [];
+        const cache = new Map<string, T>();
+        let i = 0;
+        for (const name of names) {
+            let result: T;
+            const mode = getModeForResolutionAtIndex(containingFile, i);
+            i++;
+            const cacheKey = mode !== undefined ? `${mode}|${name}` : name;
+            if (cache.has(cacheKey)) {
+                result = cache.get(cacheKey)!;
+            }
+            else {
+                cache.set(cacheKey, result = loader(name, mode, containingFileName, redirectedReference));
+            }
+            resolutions.push(result);
+        }
+        return resolutions;
+    }
+
     /* @internal */
     export function forEachResolvedProjectReference<T>(
         resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined,
@@ -623,7 +675,7 @@ namespace ts {
         switch (kind) {
             case FileIncludeKind.Import:
                 const importLiteral = getModuleNameStringLiteralAt(file, index);
-                packageId = file.resolvedModules?.get(importLiteral.text)?.packageId;
+                packageId = file.resolvedModules?.get(importLiteral.text, getModeForResolutionAtIndex(file, index))?.packageId;
                 if (importLiteral.pos === -1) return { file, packageId, text: importLiteral.text };
                 pos = skipTrivia(file.text, importLiteral.pos);
                 end = importLiteral.end;
@@ -633,7 +685,7 @@ namespace ts {
                 break;
             case FileIncludeKind.TypeReferenceDirective:
                 ({ pos, end } = file.typeReferenceDirectives[index]);
-                packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName))?.packageId;
+                packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), getModeForResolutionAtIndex(file, index))?.packageId;
                 break;
             case FileIncludeKind.LibReferenceDirective:
                 ({ pos, end } = file.libReferenceDirectives[index]);
@@ -738,6 +790,34 @@ namespace ts {
             configFileParseResult.errors;
     }
 
+    /**
+     * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
+     * `options` parameter.
+     *
+     * @param fileName The normalized absolute path to check the format of (it need not exist on disk)
+     * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
+     * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
+     * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
+     * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
+     */
+    export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined {
+        switch (getEmitModuleResolutionKind(options)) {
+            case ModuleResolutionKind.Node12:
+            case ModuleResolutionKind.NodeNext:
+                return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
+                    fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
+                    fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
+                    undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
+            default:
+                return undefined;
+        }
+        function lookupFromPackageJson(): ModuleKind.ESNext | ModuleKind.CommonJS {
+            const scope = getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
+            return scope?.packageJsonContent.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS;
+
+        }
+    }
+
     /**
      * Determine if source file needs to be re-created even if its text hasn't changed
      */
@@ -834,7 +914,7 @@ namespace ts {
         const programDiagnostics = createDiagnosticCollection();
         const currentDirectory = host.getCurrentDirectory();
         const supportedExtensions = getSupportedExtensions(options);
-        const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
+        const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
 
         // Map storing if there is emit blocking diagnostics for given input
         const hasEmitBlockingDiagnostics = new Map<string, boolean>();
@@ -842,10 +922,10 @@ namespace ts {
 
         let moduleResolutionCache: ModuleResolutionCache | undefined;
         let typeReferenceDirectiveResolutionCache: TypeReferenceDirectiveResolutionCache | undefined;
-        let actualResolveModuleNamesWorker: (moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference) => ResolvedModuleFull[];
+        let actualResolveModuleNamesWorker: (moduleNames: string[], containingFile: SourceFile, containingFileName: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference) => ResolvedModuleFull[];
         const hasInvalidatedResolution = host.hasInvalidatedResolution || returnFalse;
         if (host.resolveModuleNames) {
-            actualResolveModuleNamesWorker = (moduleNames, containingFile, reusedNames, redirectedReference) => host.resolveModuleNames!(Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(resolved => {
+            actualResolveModuleNamesWorker = (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) => host.resolveModuleNames!(Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(resolved => {
                 // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
                 if (!resolved || (resolved as ResolvedModuleFull).extension !== undefined) {
                     return resolved as ResolvedModuleFull;
@@ -854,11 +934,12 @@ namespace ts {
                 withExtension.extension = extensionFromPath(resolved.resolvedFileName);
                 return withExtension;
             });
+            moduleResolutionCache = host.getModuleResolutionCache?.();
         }
         else {
             moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
-            const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule!; // TODO: GH#18217
-            actualResolveModuleNamesWorker = (moduleNames, containingFile, _reusedNames, redirectedReference) => loadWithLocalCache<ResolvedModuleFull>(Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader);
+            const loader = (moduleName: string, resolverMode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, containingFileName: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule!; // TODO: GH#18217
+            actualResolveModuleNamesWorker = (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) => loadWithModeAwareCache<ResolvedModuleFull>(Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader);
         }
 
         let actualResolveTypeReferenceDirectiveNamesWorker: (typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference) => (ResolvedTypeReferenceDirective | undefined)[];
@@ -917,6 +998,7 @@ namespace ts {
             getSourceOfProjectReferenceRedirect,
             forEachResolvedProjectReference
         });
+        const readFile = host.readFile.bind(host) as typeof host.readFile;
 
         tracing?.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
         const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -1101,6 +1183,7 @@ namespace ts {
             isSourceOfProjectReferenceRedirect,
             emitBuildInfo,
             fileExists,
+            readFile,
             directoryExists,
             getSymlinkCache,
             realpath: host.realpath?.bind(host),
@@ -1137,7 +1220,7 @@ namespace ts {
             const redirectedReference = getRedirectReferenceForResolution(containingFile);
             tracing?.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
             performance.mark("beforeResolveModule");
-            const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
+            const result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
             performance.mark("afterResolveModule");
             performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
             tracing?.pop();
@@ -1159,7 +1242,7 @@ namespace ts {
 
         function getRedirectReferenceForResolution(file: SourceFile) {
             const redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
-            if (redirect || !fileExtensionIs(file.originalFileName, Extension.Dts)) return redirect;
+            if (redirect || !fileExtensionIsOneOf(file.originalFileName, [Extension.Dts, Extension.Dcts, Extension.Dmts])) return redirect;
 
             // The originalFileName could not be actual source file name if file found was d.ts from referecned project
             // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
@@ -1202,8 +1285,8 @@ namespace ts {
             return libs.length + 2;
         }
 
-        function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined {
-            return moduleResolutionCache && resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
+        function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined {
+            return moduleResolutionCache && resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
         }
 
         function toPath(fileName: string): Path {
@@ -1256,8 +1339,10 @@ namespace ts {
                 // Since we assume the filesystem does not change during program creation,
                 // it is safe to reuse resolutions from the earlier call.
                 const result: ResolvedModuleFull[] = [];
+                let i = 0;
                 for (const moduleName of moduleNames) {
-                    const resolvedModule = file.resolvedModules.get(moduleName)!;
+                    const resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i))!;
+                    i++;
                     result.push(resolvedModule);
                 }
                 return result;
@@ -1287,7 +1372,7 @@ namespace ts {
                 const moduleName = moduleNames[i];
                 // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
-                    const oldResolvedModule = getResolvedModule(oldSourceFile, moduleName);
+                    const oldResolvedModule = getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
                     if (oldResolvedModule) {
                         if (isTraceEnabled(options, host)) {
                             trace(host,
@@ -1317,7 +1402,7 @@ namespace ts {
                     }
                 }
                 else {
-                    resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
+                    resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
                 }
 
                 if (resolvesToAmbientModuleInNonModifiedFile) {
@@ -1360,8 +1445,9 @@ namespace ts {
 
             // If we change our policy of rechecking failed lookups on each program create,
             // we should adjust the value returned here.
-            function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string): boolean {
-                const resolutionToFile = getResolvedModule(oldSourceFile, moduleName);
+            function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string, index: number): boolean {
+                if (index >= length(oldSourceFile?.imports) + length(oldSourceFile?.moduleAugmentations)) return false; // mode index out of bounds, don't reuse resolution
+                const resolutionToFile = getResolvedModule(oldSourceFile, moduleName, oldSourceFile && getModeForResolutionAtIndex(oldSourceFile, index));
                 const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName);
                 if (resolutionToFile && resolvedFile) {
                     // In the old program, we resolved to an ambient module that was in the same
@@ -1455,8 +1541,8 @@ namespace ts {
 
             for (const oldSourceFile of oldSourceFiles) {
                 let newSourceFile = host.getSourceFileByPath
-                    ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target!, /*onError*/ undefined, shouldCreateNewSourceFile)
-                    : host.getSourceFile(oldSourceFile.fileName, options.target!, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
+                    ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
+                    : host.getSourceFile(oldSourceFile.fileName, getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
 
                 if (!newSourceFile) {
                     return StructureIsReused.Not;
@@ -1576,10 +1662,10 @@ namespace ts {
                 const moduleNames = getModuleNames(newSourceFile);
                 const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
                 // ensure that module resolution results are still correct
-                const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
+                const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, moduleResolutionIsEqualTo);
                 if (resolutionsChanged) {
                     structureIsReused = StructureIsReused.SafeModules;
-                    newSourceFile.resolvedModules = zipToMap(moduleNames, resolutions);
+                    newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
                 }
                 else {
                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
@@ -1588,10 +1674,10 @@ namespace ts {
                 const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, ref => toFileNameLowerCase(ref.fileName));
                 const typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
                 // ensure that types resolutions are still correct
-                const typeReferenceEesolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
+                const typeReferenceEesolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, typeDirectiveIsEqualTo);
                 if (typeReferenceEesolutionsChanged) {
                     structureIsReused = StructureIsReused.SafeModules;
-                    newSourceFile.resolvedTypeReferenceDirectiveNames = zipToMap(typesReferenceDirectives, typeReferenceResolutions);
+                    newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
                 }
                 else {
                     newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
@@ -2328,6 +2414,7 @@ namespace ts {
                     // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules
                     // only through top - level external module names. Relative external module names are not permitted.
                     if (moduleNameExpr && isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !isExternalModuleNameRelative(moduleNameExpr.text))) {
+                        setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
                         imports = append(imports, moduleNameExpr);
                         if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) {
                             usesUriStyleNodeCoreModules = startsWith(moduleNameExpr.text, "node:");
@@ -2336,6 +2423,7 @@ namespace ts {
                 }
                 else if (isModuleDeclaration(node)) {
                     if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) {
+                        (node.name as Mutable<Node>).parent = node;
                         const nameText = getTextOfIdentifierOrLiteral(node.name);
                         // Ambient module declarations can be interpreted as augmentations for some existing external modules.
                         // This will happen in two cases:
@@ -2372,13 +2460,16 @@ namespace ts {
                 while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
                     const node = getNodeAtPosition(file, r.lastIndex);
                     if (isJavaScriptFile && isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
+                        setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
                         imports = append(imports, node.arguments[0]);
                     }
                     // we have to check the argument list has length of at least 1. We will still have to process these even though we have parsing error.
                     else if (isImportCall(node) && node.arguments.length >= 1 && isStringLiteralLike(node.arguments[0])) {
+                        setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
                         imports = append(imports, node.arguments[0]);
                     }
                     else if (isLiteralImportTypeNode(node)) {
+                        setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
                         imports = append(imports, node.argument.literal);
                     }
                 }
@@ -2423,13 +2514,13 @@ namespace ts {
 
             if (hasExtension(fileName)) {
                 const canonicalFileName = host.getCanonicalFileName(fileName);
-                if (!options.allowNonTsExtensions && !forEach(supportedExtensionsWithJsonIfResolveJsonModule, extension => fileExtensionIs(canonicalFileName, extension))) {
+                if (!options.allowNonTsExtensions && !forEach(flatten(supportedExtensionsWithJsonIfResolveJsonModule), extension => fileExtensionIs(canonicalFileName, extension))) {
                     if (fail) {
                         if (hasJSFileExtension(canonicalFileName)) {
                             fail(Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
                         }
                         else {
-                            fail(Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
+                            fail(Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + flatten(supportedExtensions).join("', '") + "'");
                         }
                     }
                     return undefined;
@@ -2461,8 +2552,9 @@ namespace ts {
                     return undefined;
                 }
 
-                const sourceFileWithAddedExtension = forEach(supportedExtensions, extension => getSourceFile(fileName + extension));
-                if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
+                // Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts)
+                const sourceFileWithAddedExtension = forEach(supportedExtensions[0], extension => getSourceFile(fileName + extension));
+                if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + flatten(supportedExtensions).join("', '") + "'");
                 return sourceFileWithAddedExtension;
             }
         }
@@ -2616,7 +2708,7 @@ namespace ts {
             // We haven't looked for this file, do so now and cache result
             const file = host.getSourceFile(
                 fileName,
-                options.target!,
+                getEmitScriptTarget(options),
                 hostErrorMessage => addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]),
                 shouldCreateNewSourceFile
             );
@@ -2649,6 +2741,10 @@ namespace ts {
                 file.path = path;
                 file.resolvedPath = toPath(fileName);
                 file.originalFileName = originalFileName;
+                // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
+                // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
+                // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
+                file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache?.getPackageJsonInfoCache(), host, options);
                 addFileIncludeReason(file, reason);
 
                 if (host.useCaseSensitiveFileNames()) {
@@ -2938,7 +3034,7 @@ namespace ts {
                 const optionsForFile = (useSourceOfProjectReferenceRedirect ? getRedirectReferenceForResolution(file)?.commandLine.options : undefined) || options;
                 for (let index = 0; index < moduleNames.length; index++) {
                     const resolution = resolutions[index];
-                    setResolvedModule(file, moduleNames[index], resolution);
+                    setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
 
                     if (!resolution) {
                         continue;
@@ -3200,7 +3296,7 @@ namespace ts {
                 createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
             }
 
-            const languageVersion = options.target || ScriptTarget.ES3;
+            const languageVersion = getEmitScriptTarget(options);
 
             const firstNonAmbientExternalModuleSourceFile = find(files, f => isExternalModule(f) && !f.isDeclarationFile);
             if (options.isolatedModules) {
@@ -3489,7 +3585,7 @@ namespace ts {
                         message = Diagnostics.File_is_library_specified_here;
                         break;
                     }
-                    const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === options.target ? key : undefined);
+                    const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === getEmitScriptTarget(options) ? key : undefined);
                     configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined;
                     message = Diagnostics.File_is_default_library_for_target_specified_here;
                     break;
@@ -3679,7 +3775,7 @@ namespace ts {
                 return containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
             }
 
-            if (fileExtensionIsOneOf(filePath, supportedJSExtensions) || fileExtensionIs(filePath, Extension.Dts)) {
+            if (fileExtensionIsOneOf(filePath, supportedJSExtensionsFlat) || fileExtensionIs(filePath, Extension.Dts)) {
                 // Otherwise just check if sourceFile with the name exists
                 const filePathWithoutExtension = removeFileExtension(filePath);
                 return !!getSourceFileByPath((filePathWithoutExtension + Extension.Ts) as Path) ||
@@ -4033,7 +4129,7 @@ namespace ts {
     }
 
     /* @internal */
-    export function getModuleNameStringLiteralAt({ imports, moduleAugmentations }: SourceFile, index: number): StringLiteralLike {
+    export function getModuleNameStringLiteralAt({ imports, moduleAugmentations }: SourceFileImportsList, index: number): StringLiteralLike {
         if (index < imports.length) return imports[index];
         let augIndex = imports.length;
         for (const aug of moduleAugmentations) {
diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts
index f15cc9766d507..8c09ec3ef721d 100644
--- a/src/compiler/resolutionCache.ts
+++ b/src/compiler/resolutionCache.ts
@@ -5,8 +5,8 @@ namespace ts {
         startRecordingFilesWithChangedResolutions(): void;
         finishRecordingFilesWithChangedResolutions(): Path[] | undefined;
 
-        resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference?: ResolvedProjectReference): (ResolvedModuleFull | undefined)[];
-        getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): CachedResolvedModuleWithFailedLookupLocations | undefined;
+        resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference?: ResolvedProjectReference, containingSourceFile?: SourceFile): (ResolvedModuleFull | undefined)[];
+        getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): CachedResolvedModuleWithFailedLookupLocations | undefined;
         resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[];
 
         invalidateResolutionsOfFailedLookupLocations(): boolean;
@@ -166,8 +166,8 @@ namespace ts {
         // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file.
         // The key in the map is source file's path.
         // The values are Map of resolutions with key being name lookedup.
-        const resolvedModuleNames = new Map<Path, ESMap<string, CachedResolvedModuleWithFailedLookupLocations>>();
-        const perDirectoryResolvedModuleNames: CacheWithRedirects<ESMap<string, CachedResolvedModuleWithFailedLookupLocations>> = createCacheWithRedirects();
+        const resolvedModuleNames = new Map<Path, ModeAwareCache<CachedResolvedModuleWithFailedLookupLocations>>();
+        const perDirectoryResolvedModuleNames: CacheWithRedirects<ModeAwareCache<CachedResolvedModuleWithFailedLookupLocations>> = createCacheWithRedirects();
         const nonRelativeModuleNameCache: CacheWithRedirects<PerModuleNameCache> = createCacheWithRedirects();
         const moduleResolutionCache = createModuleResolutionCache(
             getCurrentDirectory(),
@@ -177,8 +177,8 @@ namespace ts {
             nonRelativeModuleNameCache,
         );
 
-        const resolvedTypeReferenceDirectives = new Map<Path, ESMap<string, CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>>();
-        const perDirectoryResolvedTypeReferenceDirectives: CacheWithRedirects<ESMap<string, CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>> = createCacheWithRedirects();
+        const resolvedTypeReferenceDirectives = new Map<Path, ModeAwareCache<CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>>();
+        const perDirectoryResolvedTypeReferenceDirectives: CacheWithRedirects<ModeAwareCache<CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>> = createCacheWithRedirects();
         const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(
             getCurrentDirectory(),
             resolutionHost.getCanonicalFileName,
@@ -354,27 +354,28 @@ namespace ts {
             names: readonly string[];
             containingFile: string;
             redirectedReference: ResolvedProjectReference | undefined;
-            cache: ESMap<Path, ESMap<string, T>>;
-            perDirectoryCacheWithRedirects: CacheWithRedirects<ESMap<string, T>>;
-            loader: (name: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference) => T;
+            cache: ESMap<Path, ModeAwareCache<T>>;
+            perDirectoryCacheWithRedirects: CacheWithRedirects<ModeAwareCache<T>>;
+            loader: (name: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, containingSourceFile?: SourceFile) => T;
             getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>;
             shouldRetryResolution: (t: T) => boolean;
             reusedNames?: readonly string[];
             logChanges?: boolean;
+            containingSourceFile?: SourceFile;
         }
         function resolveNamesWithLocalCache<T extends ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName>({
             names, containingFile, redirectedReference,
             cache, perDirectoryCacheWithRedirects,
             loader, getResolutionWithResolvedFileName,
-            shouldRetryResolution, reusedNames, logChanges
+            shouldRetryResolution, reusedNames, logChanges, containingSourceFile
         }: ResolveNamesWithLocalCacheInput<T, R>): (R | undefined)[] {
             const path = resolutionHost.toPath(containingFile);
-            const resolutionsInFile = cache.get(path) || cache.set(path, new Map()).get(path)!;
+            const resolutionsInFile = cache.get(path) || cache.set(path, createModeAwareCache()).get(path)!;
             const dirPath = getDirectoryPath(path);
             const perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
             let perDirectoryResolution = perDirectoryCache.get(dirPath);
             if (!perDirectoryResolution) {
-                perDirectoryResolution = new Map();
+                perDirectoryResolution = createModeAwareCache();
                 perDirectoryCache.set(dirPath, perDirectoryResolution);
             }
             const resolvedModules: (R | undefined)[] = [];
@@ -388,16 +389,19 @@ namespace ts {
                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
                 !!redirectedReference;
 
-            const seenNamesInFile = new Map<string, true>();
+            const seenNamesInFile = createModeAwareCache<true>();
+            let i = 0;
             for (const name of names) {
-                let resolution = resolutionsInFile.get(name);
+                const mode = containingSourceFile ? getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
+                i++;
+                let resolution = resolutionsInFile.get(name, mode);
                 // Resolution is valid if it is present and not invalidated
-                if (!seenNamesInFile.has(name) &&
+                if (!seenNamesInFile.has(name, mode) &&
                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
                     // If the name is unresolved import that was invalidated, recalculate
                     (hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
                     const existingResolution = resolution;
-                    const resolutionInDirectory = perDirectoryResolution.get(name);
+                    const resolutionInDirectory = perDirectoryResolution.get(name, mode);
                     if (resolutionInDirectory) {
                         resolution = resolutionInDirectory;
                         const host = resolutionHost.getCompilerHost?.() || resolutionHost;
@@ -425,10 +429,10 @@ namespace ts {
                         }
                     }
                     else {
-                        resolution = loader(name, containingFile, compilerOptions, resolutionHost.getCompilerHost?.() || resolutionHost, redirectedReference);
-                        perDirectoryResolution.set(name, resolution);
+                        resolution = loader(name, containingFile, compilerOptions, resolutionHost.getCompilerHost?.() || resolutionHost, redirectedReference, containingSourceFile);
+                        perDirectoryResolution.set(name, mode, resolution);
                     }
-                    resolutionsInFile.set(name, resolution);
+                    resolutionsInFile.set(name, mode, resolution);
                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
                     if (existingResolution) {
                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
@@ -442,7 +446,7 @@ namespace ts {
                 }
                 else {
                     const host = resolutionHost.getCompilerHost?.() || resolutionHost;
-                    if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) {
+                    if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
                         const resolved = getResolutionWithResolvedFileName(resolution);
                         trace(
                             host,
@@ -465,15 +469,15 @@ namespace ts {
                     }
                 }
                 Debug.assert(resolution !== undefined && !resolution.isInvalidated);
-                seenNamesInFile.set(name, true);
+                seenNamesInFile.set(name, mode, true);
                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
             }
 
             // Stop watching and remove the unused name
-            resolutionsInFile.forEach((resolution, name) => {
-                if (!seenNamesInFile.has(name) && !contains(reusedNames, name)) {
+            resolutionsInFile.forEach((resolution, name, mode) => {
+                if (!seenNamesInFile.has(name, mode) && !contains(reusedNames, name)) {
                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
-                    resolutionsInFile.delete(name);
+                    resolutionsInFile.delete(name, mode);
                 }
             });
 
@@ -511,7 +515,7 @@ namespace ts {
             });
         }
 
-        function resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference?: ResolvedProjectReference): (ResolvedModuleFull | undefined)[] {
+        function resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference?: ResolvedProjectReference, containingSourceFile?: SourceFile): (ResolvedModuleFull | undefined)[] {
             return resolveNamesWithLocalCache<CachedResolvedModuleWithFailedLookupLocations, ResolvedModuleFull>({
                 names: moduleNames,
                 containingFile,
@@ -523,12 +527,14 @@ namespace ts {
                 shouldRetryResolution: resolution => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
                 reusedNames,
                 logChanges: logChangesWhenResolvingModule,
+                containingSourceFile,
             });
         }
 
-        function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): CachedResolvedModuleWithFailedLookupLocations | undefined {
+        function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): CachedResolvedModuleWithFailedLookupLocations | undefined {
             const cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
-            return cache && cache.get(moduleName);
+            if (!cache) return undefined;
+            return cache.get(moduleName, resolutionMode);
         }
 
         function isNodeModulesAtTypesDirectory(dirPath: Path) {
@@ -751,7 +757,7 @@ namespace ts {
         }
 
         function removeResolutionsOfFileFromCache<T extends ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName>(
-            cache: ESMap<string, ESMap<string, T>>,
+            cache: ESMap<string, ModeAwareCache<T>>,
             filePath: Path,
             getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>,
         ) {
diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts
index 732205c00a34b..4c4b07d23a43a 100644
--- a/src/compiler/transformer.ts
+++ b/src/compiler/transformer.ts
@@ -8,6 +8,9 @@ namespace ts {
                 return transformECMAScriptModule;
             case ModuleKind.System:
                 return transformSystemModule;
+            case ModuleKind.Node12:
+            case ModuleKind.NodeNext:
+                return transformNodeModule;
             default:
                 return transformModule;
         }
diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts
index 935c549dbcea5..de979f8a0ffa9 100644
--- a/src/compiler/transformers/classFields.ts
+++ b/src/compiler/transformers/classFields.ts
@@ -172,7 +172,7 @@ namespace ts {
         function transformSourceFile(node: SourceFile) {
             const options = context.getCompilerOptions();
             if (node.isDeclarationFile
-                || useDefineForClassFields && options.target === ScriptTarget.ESNext) {
+                || useDefineForClassFields && getEmitScriptTarget(options) === ScriptTarget.ESNext) {
                 return node;
             }
             const visited = visitEachChild(node, visitor, context);
diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts
index 018e2ad2cb411..d162ebafd120b 100644
--- a/src/compiler/transformers/jsx.ts
+++ b/src/compiler/transformers/jsx.ts
@@ -292,7 +292,7 @@ namespace ts {
                 // When there are no attributes, React wants "null"
             }
             else {
-                const target = compilerOptions.target;
+                const target = getEmitScriptTarget(compilerOptions);
                 if (target && target >= ScriptTarget.ES2018) {
                     objectProperties = factory.createObjectLiteralExpression(
                         flatten<SpreadAssignment | PropertyAssignment>(
diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts
index ee08ed77b9871..19fbdfcebfbc2 100644
--- a/src/compiler/transformers/module/esnextAnd2015.ts
+++ b/src/compiler/transformers/module/esnextAnd2015.ts
@@ -5,7 +5,10 @@ namespace ts {
             factory,
             getEmitHelperFactory: emitHelpers,
         } = context;
+        const host = context.getEmitHost();
+        const resolver = context.getEmitResolver();
         const compilerOptions = context.getCompilerOptions();
+        const languageVersion = getEmitScriptTarget(compilerOptions);
         const previousOnEmitNode = context.onEmitNode;
         const previousOnSubstituteNode = context.onSubstituteNode;
         context.onEmitNode = onEmitNode;
@@ -14,6 +17,8 @@ namespace ts {
         context.enableSubstitution(SyntaxKind.Identifier);
 
         let helperNameSubstitutions: ESMap<string, Identifier> | undefined;
+        let currentSourceFile: SourceFile | undefined;
+        let importRequireStatements: [ImportDeclaration, VariableStatement] | undefined;
         return chainBundle(context, transformSourceFile);
 
         function transformSourceFile(node: SourceFile) {
@@ -22,7 +27,16 @@ namespace ts {
             }
 
             if (isExternalModule(node) || compilerOptions.isolatedModules) {
-                const result = updateExternalModule(node);
+                currentSourceFile = node;
+                importRequireStatements = undefined;
+                let result = updateExternalModule(node);
+                currentSourceFile = undefined;
+                if (importRequireStatements) {
+                    result = factory.updateSourceFile(
+                        result,
+                        setTextRange(factory.createNodeArray(insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements),
+                    );
+                }
                 if (!isExternalModule(node) || some(result.statements, isExternalModuleIndicator)) {
                     return result;
                 }
@@ -55,8 +69,10 @@ namespace ts {
         function visitor(node: Node): VisitResult<Node> {
             switch (node.kind) {
                 case SyntaxKind.ImportEqualsDeclaration:
-                    // Elide `import=` as it is not legal with --module ES6
-                    return undefined;
+                    // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
+                    // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
+                    // is available, just because the output is reasonable for a node-like runtime.
+                    return getEmitScriptTarget(compilerOptions) >= ModuleKind.ES2020 ? visitImportEqualsDeclaration(node as ImportEqualsDeclaration) : undefined;
                 case SyntaxKind.ExportAssignment:
                     return visitExportAssignment(node as ExportAssignment);
                 case SyntaxKind.ExportDeclaration:
@@ -67,6 +83,106 @@ namespace ts {
             return node;
         }
 
+        /**
+         * Creates a `require()` call to import an external module.
+         *
+         * @param importNode The declaration to import.
+         */
+         function createRequireCall(importNode: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) {
+            const moduleName = getExternalModuleNameLiteral(factory, importNode, Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions);
+            const args: Expression[] = [];
+            if (moduleName) {
+                args.push(moduleName);
+            }
+
+            if (!importRequireStatements) {
+                const createRequireName = factory.createUniqueName("_createRequire", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel);
+                const importStatement = factory.createImportDeclaration(
+                    /*decorators*/ undefined,
+                    /*modifiers*/ undefined,
+                    factory.createImportClause(
+                        /*isTypeOnly*/ false,
+                        /*name*/ undefined,
+                        factory.createNamedImports([
+                            factory.createImportSpecifier(factory.createIdentifier("createRequire"), createRequireName)
+                        ])
+                    ),
+                    factory.createStringLiteral("module")
+                );
+                const requireHelperName = factory.createUniqueName("__require", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel);
+                const requireStatement = factory.createVariableStatement(
+                    /*modifiers*/ undefined,
+                    factory.createVariableDeclarationList(
+                        [
+                            factory.createVariableDeclaration(
+                                requireHelperName,
+                                /*exclamationToken*/ undefined,
+                                /*type*/ undefined,
+                                factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [
+                                    factory.createPropertyAccessExpression(factory.createMetaProperty(SyntaxKind.ImportKeyword, factory.createIdentifier("meta")), factory.createIdentifier("url"))
+                                ])
+                            )
+                        ],
+                        /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None
+                    )
+                );
+                importRequireStatements = [importStatement, requireStatement];
+
+            }
+
+            const name = importRequireStatements[1].declarationList.declarations[0].name;
+            Debug.assertNode(name, isIdentifier);
+            return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args);
+        }
+
+        /**
+         * Visits an ImportEqualsDeclaration node.
+         *
+         * @param node The node to visit.
+         */
+        function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult<Statement> {
+            Debug.assert(isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
+
+            let statements: Statement[] | undefined;
+            statements = append(statements,
+                setOriginalNode(
+                    setTextRange(
+                        factory.createVariableStatement(
+                            /*modifiers*/ undefined,
+                            factory.createVariableDeclarationList(
+                                [
+                                    factory.createVariableDeclaration(
+                                        factory.cloneNode(node.name),
+                                        /*exclamationToken*/ undefined,
+                                        /*type*/ undefined,
+                                        createRequireCall(node)
+                                    )
+                                ],
+                                /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None
+                            )
+                        ),
+                        node),
+                    node
+                )
+            );
+
+            statements = appendExportsOfImportEqualsDeclaration(statements, node);
+
+            return singleOrMany(statements);
+        }
+
+        function appendExportsOfImportEqualsDeclaration(statements: Statement[] | undefined, node: ImportEqualsDeclaration) {
+            if (hasSyntacticModifier(node, ModifierFlags.Export)) {
+                statements = append(statements, factory.createExportDeclaration(
+                    /*decorators*/ undefined,
+                    /*modifiers*/ undefined,
+                    node.isTypeOnly,
+                    factory.createNamedExports([factory.createExportSpecifier(/*propertyName*/ undefined, idText(node.name))])
+                ));
+            }
+            return statements;
+        }
+
         function visitExportAssignment(node: ExportAssignment): VisitResult<ExportAssignment> {
             // Elide `export=` as it is not legal with --module ES6
             return node.isExportEquals ? undefined : node;
diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts
index 225939a9df8a5..9c88471640956 100644
--- a/src/compiler/transformers/module/module.ts
+++ b/src/compiler/transformers/module/module.ts
@@ -556,7 +556,7 @@ namespace ts {
                 case SyntaxKind.PartiallyEmittedExpression:
                     return visitPartiallyEmittedExpression(node as PartiallyEmittedExpression, valueIsDiscarded);
                 case SyntaxKind.CallExpression:
-                    if (isImportCall(node)) {
+                    if (isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) {
                         return visitImportCallExpression(node);
                     }
                     break;
@@ -814,7 +814,7 @@ namespace ts {
             }
 
             const promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
-            if (compilerOptions.esModuleInterop) {
+            if (getESModuleInterop(compilerOptions)) {
                 return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]);
             }
             return promise;
@@ -828,7 +828,7 @@ namespace ts {
             // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
             const promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
             let requireCall: Expression = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
-            if (compilerOptions.esModuleInterop) {
+            if (getESModuleInterop(compilerOptions)) {
                 requireCall = emitHelpers().createImportStarHelper(requireCall);
             }
 
@@ -864,7 +864,7 @@ namespace ts {
         }
 
         function getHelperExpressionForExport(node: ExportDeclaration, innerExpr: Expression) {
-            if (!compilerOptions.esModuleInterop || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) {
+            if (!getESModuleInterop(compilerOptions) || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) {
                 return innerExpr;
             }
             if (getExportNeedsImportStarHelper(node)) {
@@ -874,7 +874,7 @@ namespace ts {
         }
 
         function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) {
-            if (!compilerOptions.esModuleInterop || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) {
+            if (!getESModuleInterop(compilerOptions) || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) {
                 return innerExpr;
             }
             if (getImportNeedsImportStarHelper(node)) {
@@ -1134,7 +1134,7 @@ namespace ts {
                     }
                     else {
                         const exportNeedsImportDefault =
-                            !!compilerOptions.esModuleInterop &&
+                            !!getESModuleInterop(compilerOptions) &&
                             !(getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) &&
                             idText(specifier.propertyName || specifier.name) === "default";
                         const exportedValue = factory.createPropertyAccessExpression(
diff --git a/src/compiler/transformers/module/node.ts b/src/compiler/transformers/module/node.ts
new file mode 100644
index 0000000000000..b1addf4f3ece2
--- /dev/null
+++ b/src/compiler/transformers/module/node.ts
@@ -0,0 +1,84 @@
+/*@internal*/
+namespace ts {
+    export function transformNodeModule(context: TransformationContext) {
+        const previousOnSubstituteNode = context.onSubstituteNode;
+        const previousOnEmitNode = context.onEmitNode;
+
+        const esmTransform = transformECMAScriptModule(context);
+
+        const esmOnSubstituteNode = context.onSubstituteNode;
+        const esmOnEmitNode = context.onEmitNode;
+
+        context.onSubstituteNode = previousOnSubstituteNode;
+        context.onEmitNode = previousOnEmitNode;
+
+        const cjsTransform = transformModule(context);
+
+        const cjsOnSubstituteNode = context.onSubstituteNode;
+        const cjsOnEmitNode = context.onEmitNode;
+
+        context.onSubstituteNode = onSubstituteNode;
+        context.onEmitNode = onEmitNode;
+        context.enableSubstitution(SyntaxKind.SourceFile);
+        context.enableEmitNotification(SyntaxKind.SourceFile);
+
+        let currentSourceFile: SourceFile | undefined;
+        return transformSourceFileOrBundle;
+
+        function onSubstituteNode(hint: EmitHint, node: Node) {
+            if (isSourceFile(node)) {
+                currentSourceFile = node;
+                // Neither component transform wants substitution notifications for `SourceFile`s, and, in fact, relies on
+                // the source file emit notification to setup scope variables for substitutions (so we _cannot_ call their substitute
+                // functions on source files safely, as that context only gets setup in a later pipeline phase!)
+                return previousOnSubstituteNode(hint, node);
+            }
+            else {
+                if (!currentSourceFile) {
+                    return previousOnSubstituteNode(hint, node);
+                }
+                if (currentSourceFile.impliedNodeFormat === ModuleKind.ESNext) {
+                    return esmOnSubstituteNode(hint, node);
+                }
+                return cjsOnSubstituteNode(hint, node);
+            }
+        }
+
+        function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void {
+            if (isSourceFile(node)) {
+                currentSourceFile = node;
+            }
+            if (!currentSourceFile) {
+                return previousOnEmitNode(hint, node, emitCallback);
+            }
+            if (currentSourceFile.impliedNodeFormat === ModuleKind.ESNext) {
+                return esmOnEmitNode(hint, node, emitCallback);
+            }
+            return cjsOnEmitNode(hint, node, emitCallback);
+        }
+
+        function getModuleTransformForFile(file: SourceFile): (typeof esmTransform) {
+            return file.impliedNodeFormat === ModuleKind.ESNext ? esmTransform : cjsTransform;
+        }
+
+        function transformSourceFile(node: SourceFile) {
+            if (node.isDeclarationFile) {
+                return node;
+            }
+
+            currentSourceFile = node;
+            const result = getModuleTransformForFile(node)(node);
+            currentSourceFile = undefined;
+            Debug.assert(isSourceFile(result));
+            return result;
+        }
+
+        function transformSourceFileOrBundle(node: SourceFile | Bundle) {
+            return node.kind === SyntaxKind.SourceFile ? transformSourceFile(node) : transformBundle(node);
+        }
+
+        function transformBundle(node: Bundle) {
+            return context.factory.createBundle(map(node.sourceFiles, transformSourceFile), node.prepends);
+        }
+    }
+}
diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts
index b92741a3de8dc..3f0e366be3afe 100644
--- a/src/compiler/tsbuildPublic.ts
+++ b/src/compiler/tsbuildPublic.ts
@@ -281,9 +281,10 @@ namespace ts {
         const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
         const typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()) : undefined;
         if (!compilerHost.resolveModuleNames) {
-            const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule!;
-            compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) =>
-                loadWithLocalCache<ResolvedModuleFull>(Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader);
+            const loader = (moduleName: string, resolverMode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule!;
+            compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) =>
+                loadWithModeAwareCache<ResolvedModuleFull>(Debug.checkEachDefined(moduleNames), Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader);
+            compilerHost.getModuleResolutionCache = () => moduleResolutionCache;
         }
         if (!compilerHost.resolveTypeReferenceDirectives) {
             const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective!;
diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json
index 5f118cf1e47bd..c5db068d120c1 100644
--- a/src/compiler/tsconfig.json
+++ b/src/compiler/tsconfig.json
@@ -63,6 +63,7 @@
         "transformers/module/module.ts",
         "transformers/module/system.ts",
         "transformers/module/esnextAnd2015.ts",
+        "transformers/module/node.ts",
         "transformers/declarations/diagnostics.ts",
         "transformers/declarations.ts",
         "transformer.ts",
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index b6a6258b21a24..aa4e399ed1609 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -3583,6 +3583,20 @@ namespace ts {
         hasNoDefaultLib: boolean;
 
         languageVersion: ScriptTarget;
+
+        /**
+         * When `module` is `Node12` or `NodeNext`, this field controls whether the
+         * source file in question is an ESNext-output-format file, or a CommonJS-output-format
+         * module. This is derived by the module resolver as it looks up the file, since
+         * it is derived from either the file extension of the module, or the containing
+         * `package.json` context, and affects both checking and emit.
+         *
+         * It is _public_ so that (pre)transformers can set this field,
+         * since it switches the builtin `node` module transform. Generally speaking, if unset,
+         * the field is treated as though it is `ModuleKind.CommonJS`.
+         */
+        impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
+
         /* @internal */ scriptKind: ScriptKind;
 
         /**
@@ -3624,8 +3638,8 @@ namespace ts {
         // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined
         // It is used to resolve module names in the checker.
         // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
-        /* @internal */ resolvedModules?: ESMap<string, ResolvedModuleFull | undefined>;
-        /* @internal */ resolvedTypeReferenceDirectiveNames: ESMap<string, ResolvedTypeReferenceDirective | undefined>;
+        /* @internal */ resolvedModules?: ModeAwareCache<ResolvedModuleFull | undefined>;
+        /* @internal */ resolvedTypeReferenceDirectiveNames: ModeAwareCache<ResolvedTypeReferenceDirective | undefined>;
         /* @internal */ imports: readonly StringLiteralLike[];
         // Identifier only if `declare global`
         /* @internal */ moduleAugmentations: readonly (StringLiteral | Identifier)[];
@@ -4007,7 +4021,7 @@ namespace ts {
         /* @internal */ getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>;
         /* @internal */ useCaseSensitiveFileNames(): boolean;
 
-        /* @internal */ getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
+        /* @internal */ getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
 
         getProjectReferences(): readonly ProjectReference[] | undefined;
         getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
@@ -5961,7 +5975,13 @@ namespace ts {
 
     export enum ModuleResolutionKind {
         Classic  = 1,
-        NodeJs   = 2
+        NodeJs   = 2,
+        // Starting with node12, node's module resolver has significant departures from tranditional cjs resolution
+        // to better support ecmascript modules and their use within node - more features are still being added, so
+        // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
+        // version-anchored resolution target
+        Node12   = 3,
+        NodeNext = 99, // Not simply `Node12` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`)
     }
 
     export interface PluginImport {
@@ -6115,7 +6135,7 @@ namespace ts {
         suppressExcessPropertyErrors?: boolean;
         suppressImplicitAnyIndexErrors?: boolean;
         /* @internal */ suppressOutputPathCheck?: boolean;
-        target?: ScriptTarget; // TODO: GH#18217 frequently asserted as defined
+        target?: ScriptTarget;
         traceResolution?: boolean;
         useUnknownInCatchVariables?: boolean;
         resolveJsonModule?: boolean;
@@ -6167,7 +6187,11 @@ namespace ts {
         //       module kind).
         ES2015 = 5,
         ES2020 = 6,
-        ESNext = 99
+        ESNext = 99,
+
+        // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
+        Node12 = 100,
+        NodeNext = 199,
     }
 
     export const enum JsxEmit {
@@ -6563,7 +6587,13 @@ namespace ts {
         Js = ".js",
         Jsx = ".jsx",
         Json = ".json",
-        TsBuildInfo = ".tsbuildinfo"
+        TsBuildInfo = ".tsbuildinfo",
+        Mjs = ".mjs",
+        Mts = ".mts",
+        Dmts = ".d.mts",
+        Cjs = ".cjs",
+        Cts = ".cts",
+        Dcts = ".d.cts",
     }
 
     export interface ResolvedModuleWithFailedLookupLocations {
@@ -6618,7 +6648,11 @@ namespace ts {
          * If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just
          * 'throw new Error("NotImplemented")'
          */
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
+        /**
+         * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
+         */
+        getModuleResolutionCache?(): ModuleResolutionCache | undefined;
         /**
          * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
          */
diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts
index 8ac91f86f99dd..0873aba6a933b 100644
--- a/src/compiler/utilities.ts
+++ b/src/compiler/utilities.ts
@@ -169,24 +169,24 @@ namespace ts {
         return node.end - node.pos;
     }
 
-    export function getResolvedModule(sourceFile: SourceFile | undefined, moduleNameText: string): ResolvedModuleFull | undefined {
-        return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
+    export function getResolvedModule(sourceFile: SourceFile | undefined, moduleNameText: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): ResolvedModuleFull | undefined {
+        return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
     }
 
-    export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void {
+    export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): void {
         if (!sourceFile.resolvedModules) {
-            sourceFile.resolvedModules = new Map<string, ResolvedModuleFull>();
+            sourceFile.resolvedModules = createModeAwareCache();
         }
 
-        sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
+        sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
     }
 
     export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective?: ResolvedTypeReferenceDirective): void {
         if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
-            sourceFile.resolvedTypeReferenceDirectiveNames = new Map<string, ResolvedTypeReferenceDirective | undefined>();
+            sourceFile.resolvedTypeReferenceDirectiveNames = createModeAwareCache();
         }
 
-        sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
+        sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
     }
 
     export function projectReferenceIsEqualTo(oldRef: ProjectReference, newRef: ProjectReference) {
@@ -221,13 +221,14 @@ namespace ts {
     export function hasChangesInResolutions<T>(
         names: readonly string[],
         newResolutions: readonly T[],
-        oldResolutions: ReadonlyESMap<string, T> | undefined,
+        oldResolutions: ModeAwareCache<T> | undefined,
+        oldSourceFile: SourceFile | undefined,
         comparer: (oldResolution: T, newResolution: T) => boolean): boolean {
         Debug.assert(names.length === newResolutions.length);
 
         for (let i = 0; i < names.length; i++) {
             const newResolution = newResolutions[i];
-            const oldResolution = oldResolutions && oldResolutions.get(names[i]);
+            const oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && getModeForResolutionAtIndex(oldSourceFile, i));
             const changed =
                 oldResolution
                     ? !newResolution || !comparer(oldResolution, newResolution)
@@ -791,8 +792,12 @@ namespace ts {
         return symbol.declarations?.find(d => !isExternalModuleAugmentation(d) && !(isModuleDeclaration(d) && isGlobalScopeAugmentation(d)));
     }
 
+    function isCommonJSContainingModuleKind(kind: ModuleKind) {
+        return kind === ModuleKind.CommonJS || kind === ModuleKind.Node12 || kind === ModuleKind.NodeNext;
+    }
+
     export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) {
-        return isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
+        return isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
     }
 
     /**
@@ -4270,7 +4275,15 @@ namespace ts {
         const path = outputDir
             ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
             : fileName;
-        return removeFileExtension(path) + Extension.Dts;
+        const declarationExtension = getDeclarationEmitExtensionForPath(path);
+        return removeFileExtension(path) + declarationExtension;
+    }
+
+    export function getDeclarationEmitExtensionForPath(path: string) {
+        return fileExtensionIsOneOf(path, [Extension.Mjs, Extension.Mts]) ? Extension.Dmts :
+            fileExtensionIsOneOf(path, [Extension.Cjs, Extension.Cts]) ? Extension.Dcts :
+            fileExtensionIsOneOf(path, [Extension.Json]) ? `.json.d.ts` : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
+            Extension.Dts;
     }
 
     export function outFile(options: CompilerOptions) {
@@ -6110,8 +6123,11 @@ namespace ts {
         return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS || scriptKind === ScriptKind.JSON ? LanguageVariant.JSX : LanguageVariant.Standard;
     }
 
-    export function getEmitScriptTarget(compilerOptions: CompilerOptions) {
-        return compilerOptions.target || ScriptTarget.ES3;
+    export function getEmitScriptTarget(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) {
+        return compilerOptions.target ||
+            (compilerOptions.module === ModuleKind.Node12 && ScriptTarget.ES2020) ||
+            (compilerOptions.module === ModuleKind.NodeNext && ScriptTarget.ESNext) ||
+            ScriptTarget.ES3;
     }
 
     export function getEmitModuleKind(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) {
@@ -6123,7 +6139,20 @@ namespace ts {
     export function getEmitModuleResolutionKind(compilerOptions: CompilerOptions) {
         let moduleResolution = compilerOptions.moduleResolution;
         if (moduleResolution === undefined) {
-            moduleResolution = getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
+            switch (getEmitModuleKind(compilerOptions)) {
+                case ModuleKind.CommonJS:
+                    moduleResolution = ModuleResolutionKind.NodeJs;
+                    break;
+                case ModuleKind.Node12:
+                    moduleResolution = ModuleResolutionKind.Node12;
+                    break;
+                case ModuleKind.NodeNext:
+                    moduleResolution = ModuleResolutionKind.NodeNext;
+                    break;
+                default:
+                    moduleResolution = ModuleResolutionKind.Classic;
+                    break;
+            }
         }
         return moduleResolution;
     }
@@ -6153,11 +6182,23 @@ namespace ts {
         return !!(getEmitDeclarations(options) && options.declarationMap);
     }
 
+    export function getESModuleInterop(compilerOptions: CompilerOptions) {
+        if (compilerOptions.esModuleInterop !== undefined) {
+            return compilerOptions.esModuleInterop;
+        }
+        switch (getEmitModuleKind(compilerOptions)) {
+            case ModuleKind.Node12:
+            case ModuleKind.NodeNext:
+                return true;
+        }
+        return undefined;
+    }
+
     export function getAllowSyntheticDefaultImports(compilerOptions: CompilerOptions) {
         const moduleKind = getEmitModuleKind(compilerOptions);
         return compilerOptions.allowSyntheticDefaultImports !== undefined
             ? compilerOptions.allowSyntheticDefaultImports
-            : compilerOptions.esModuleInterop ||
+            : getESModuleInterop(compilerOptions) ||
             moduleKind === ModuleKind.System;
     }
 
@@ -6193,7 +6234,7 @@ namespace ts {
     }
 
     export function getUseDefineForClassFields(compilerOptions: CompilerOptions): boolean {
-        return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === ScriptTarget.ESNext : compilerOptions.useDefineForClassFields;
+        return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext : compilerOptions.useDefineForClassFields;
     }
 
     export function compilerOptionsAffectSemanticDiagnostics(newOptions: CompilerOptions, oldOptions: CompilerOptions): boolean {
@@ -6710,39 +6751,44 @@ namespace ts {
     }
 
     /**
-     *  List of supported extensions in order of file resolution precedence.
+     *  Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS)
      */
-    export const supportedTSExtensions: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts];
-    export const supportedTSExtensionsWithJson: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Json];
+    export const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]];
+    export const supportedTSExtensionsFlat: readonly Extension[] = flatten(supportedTSExtensions);
+    const supportedTSExtensionsWithJson: readonly Extension[][] = [...supportedTSExtensions, [Extension.Json]];
     /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
-    export const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Ts, Extension.Tsx];
-    export const supportedJSExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx];
-    export const supportedJSAndJsonExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx, Extension.Json];
-    const allSupportedExtensions: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions];
-    const allSupportedExtensionsWithJson: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions, Extension.Json];
-
-    export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[];
-    export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[];
-    export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[] {
+    const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Dcts, Extension.Dmts, Extension.Cts, Extension.Mts, Extension.Ts, Extension.Tsx, Extension.Cts, Extension.Mts];
+    export const supportedJSExtensions: readonly Extension[][] = [[Extension.Js, Extension.Jsx], [Extension.Mjs], [Extension.Cjs]];
+    export const supportedJSExtensionsFlat: readonly Extension[] = flatten(supportedJSExtensions);
+    const allSupportedExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Js, Extension.Jsx], [Extension.Cts, Extension.Dcts, Extension.Cjs], [Extension.Mts, Extension.Dmts, Extension.Mjs]];
+    const allSupportedExtensionsWithJson: readonly Extension[][] = [...allSupportedExtensions, [Extension.Json]];
+
+    export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[][];
+    export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][];
+    export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][] {
         const needJsExtensions = options && getAllowJSCompilerOption(options);
 
         if (!extraFileExtensions || extraFileExtensions.length === 0) {
             return needJsExtensions ? allSupportedExtensions : supportedTSExtensions;
         }
 
+        const builtins = needJsExtensions ? allSupportedExtensions : supportedTSExtensions;
+        const flatBuiltins = flatten(builtins);
         const extensions = [
-            ...needJsExtensions ? allSupportedExtensions : supportedTSExtensions,
-            ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined)
+            ...builtins,
+            ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension as Extension) === -1 ? [x.extension] : undefined)
         ];
 
-        return deduplicate<string>(extensions, equateStringsCaseSensitive, compareStringsCaseSensitive);
+        return extensions;
     }
 
-    export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[]): readonly string[] {
+    export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][];
+    export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][];
+    export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] {
         if (!options || !options.resolveJsonModule) return supportedExtensions;
         if (supportedExtensions === allSupportedExtensions) return allSupportedExtensionsWithJson;
         if (supportedExtensions === supportedTSExtensions) return supportedTSExtensionsWithJson;
-        return [...supportedExtensions, Extension.Json];
+        return [...supportedExtensions, [Extension.Json]];
     }
 
     function isJSLike(scriptKind: ScriptKind | undefined): boolean {
@@ -6750,18 +6796,18 @@ namespace ts {
     }
 
     export function hasJSFileExtension(fileName: string): boolean {
-        return some(supportedJSExtensions, extension => fileExtensionIs(fileName, extension));
+        return some(supportedJSExtensionsFlat, extension => fileExtensionIs(fileName, extension));
     }
 
     export function hasTSFileExtension(fileName: string): boolean {
-        return some(supportedTSExtensions, extension => fileExtensionIs(fileName, extension));
+        return some(supportedTSExtensionsFlat, extension => fileExtensionIs(fileName, extension));
     }
 
     export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]) {
         if (!fileName) return false;
 
         const supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
-        for (const extension of getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)) {
+        for (const extension of flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) {
             if (fileExtensionIs(fileName, extension)) {
                 return true;
             }
@@ -6781,59 +6827,7 @@ namespace ts {
         );
     }
 
-    /**
-     * Extension boundaries by priority. Lower numbers indicate higher priorities, and are
-     * aligned to the offset of the highest priority extension in the
-     * allSupportedExtensions array.
-     */
-    export const enum ExtensionPriority {
-        TypeScriptFiles = 0,
-        DeclarationAndJavaScriptFiles = 2,
-
-        Highest = TypeScriptFiles,
-        Lowest = DeclarationAndJavaScriptFiles,
-    }
-
-    export function getExtensionPriority(path: string, supportedExtensions: readonly string[]): ExtensionPriority {
-        for (let i = supportedExtensions.length - 1; i >= 0; i--) {
-            if (fileExtensionIs(path, supportedExtensions[i])) {
-                return adjustExtensionPriority(i as ExtensionPriority, supportedExtensions);
-            }
-        }
-
-        // If its not in the list of supported extensions, this is likely a
-        // TypeScript file with a non-ts extension
-        return ExtensionPriority.Highest;
-    }
-
-    /**
-     * Adjusts an extension priority to be the highest priority within the same range.
-     */
-    export function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority {
-        if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) {
-            return ExtensionPriority.TypeScriptFiles;
-        }
-        else if (extensionPriority < supportedExtensions.length) {
-            return ExtensionPriority.DeclarationAndJavaScriptFiles;
-        }
-        else {
-            return supportedExtensions.length;
-        }
-    }
-
-    /**
-     * Gets the next lowest extension priority for a given priority.
-     */
-    export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority {
-        if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) {
-            return ExtensionPriority.DeclarationAndJavaScriptFiles;
-        }
-        else {
-            return supportedExtensions.length;
-        }
-    }
-
-    const extensionsToRemove = [Extension.Dts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json];
+    const extensionsToRemove = [Extension.Dts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Mts, Extension.Cjs, Extension.Cts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json];
     export function removeFileExtension(path: string): string {
         for (const ext of extensionsToRemove) {
             const extensionless = tryRemoveExtension(path, ext);
@@ -6885,7 +6879,7 @@ namespace ts {
 
     /** True if an extension is one of the supported TypeScript extensions. */
     export function extensionIsTS(ext: Extension): boolean {
-        return ext === Extension.Ts || ext === Extension.Tsx || ext === Extension.Dts;
+        return ext === Extension.Ts || ext === Extension.Tsx || ext === Extension.Dts || ext === Extension.Cts || ext === Extension.Mts || ext === Extension.Dmts || ext === Extension.Dcts;
     }
 
     export function resolutionExtensionIsTSOrJson(ext: Extension) {
diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts
index a5c0f9296d350..a315d12200878 100644
--- a/src/compiler/utilitiesPublic.ts
+++ b/src/compiler/utilitiesPublic.ts
@@ -11,7 +11,7 @@ namespace ts {
     }
 
     export function getDefaultLibFileName(options: CompilerOptions): string {
-        switch (options.target) {
+        switch (getEmitScriptTarget(options)) {
             case ScriptTarget.ESNext:
                 return "lib.esnext.full.d.ts";
             case ScriptTarget.ES2021:
diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts
index 3f63422a7fa16..71853f4f34b52 100644
--- a/src/compiler/watch.ts
+++ b/src/compiler/watch.ts
@@ -279,7 +279,7 @@ namespace ts {
                 );
             case FileIncludeKind.LibFile:
                 if (reason.index !== undefined) return chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Library_0_specified_in_compilerOptions, options.lib![reason.index]);
-                const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === options.target ? key : undefined);
+                const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === getEmitScriptTarget(options) ? key : undefined);
                 return chainDiagnosticMessages(
                     /*details*/ undefined,
                     target ?
diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts
index 1cc21a0bc9400..4b1eba91b7cdc 100644
--- a/src/compiler/watchPublic.ts
+++ b/src/compiler/watchPublic.ts
@@ -101,7 +101,7 @@ namespace ts {
         getEnvironmentVariable?(name: string): string | undefined;
 
         /** If provided, used to resolve the module names, otherwise typescript's default module resolution */
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
         /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
         resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
     }
@@ -349,7 +349,7 @@ namespace ts {
         // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names
         compilerHost.resolveModuleNames = host.resolveModuleNames ?
             ((...args) => host.resolveModuleNames!(...args)) :
-            ((moduleNames, containingFile, reusedNames, redirectedReference) => resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference));
+            ((moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) => resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile));
         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
             ((...args) => host.resolveTypeReferenceDirectives!(...args)) :
             ((typeDirectiveNames, containingFile, redirectedReference) => resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference));
diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts
index aac36908badb2..c6b9df2c3e3b5 100644
--- a/src/compiler/watchUtilities.ts
+++ b/src/compiler/watchUtilities.ts
@@ -499,7 +499,7 @@ namespace ts {
             // If its declaration directory: its not ignored if not excluded by config
             if (options.declarationDir) return false;
         }
-        else if (!fileExtensionIsOneOf(fileOrDirectoryPath, supportedJSExtensions)) {
+        else if (!fileExtensionIsOneOf(fileOrDirectoryPath, supportedJSExtensionsFlat)) {
             return false;
         }
 
diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts
index 87084d4f4bb75..0db32b94c0d9f 100644
--- a/src/executeCommandLine/executeCommandLine.ts
+++ b/src/executeCommandLine/executeCommandLine.ts
@@ -43,10 +43,10 @@ namespace ts {
         }
 
         const path = file.path;
-        if (fileExtensionIsOneOf(path, supportedTSExtensions)) {
+        if (fileExtensionIsOneOf(path, supportedTSExtensionsFlat)) {
             return "TypeScript";
         }
-        else if (fileExtensionIsOneOf(path, supportedJSExtensions)) {
+        else if (fileExtensionIsOneOf(path, supportedJSExtensionsFlat)) {
             return "JavaScript";
         }
         else if (fileExtensionIs(path, Extension.Json)) {
diff --git a/src/harness/compilerImpl.ts b/src/harness/compilerImpl.ts
index 41003356fc23a..40e3994b1c9bd 100644
--- a/src/harness/compilerImpl.ts
+++ b/src/harness/compilerImpl.ts
@@ -118,11 +118,11 @@ namespace compiler {
                             const input = new documents.TextDocument(sourceFile.fileName, sourceFile.text);
                             this._inputs.push(input);
                             if (!vpath.isDeclaration(sourceFile.fileName)) {
-                                const extname = ts.getOutputExtension(sourceFile, this.options);
+                                const extname = ts.getOutputExtension(sourceFile.fileName, this.options);
                                 const outputs: CompilationOutput = {
                                     inputs: [input],
                                     js: js.get(this.getOutputPath(sourceFile.fileName, extname)),
-                                    dts: dts.get(this.getOutputPath(sourceFile.fileName, ".d.ts")),
+                                    dts: dts.get(this.getOutputPath(sourceFile.fileName, ts.getDeclarationEmitExtensionForPath(sourceFile.fileName))),
                                     map: maps.get(this.getOutputPath(sourceFile.fileName, extname + ".map"))
                                 };
 
@@ -205,7 +205,7 @@ namespace compiler {
             }
             else {
                 path = vpath.resolve(this.vfs.cwd(), path);
-                const outDir = ext === ".d.ts" ? this.options.declarationDir || this.options.outDir : this.options.outDir;
+                const outDir = ext === ".d.ts" || ext === ".json.d.ts" || ext === ".d.mts" || ext === ".d.cts" ? this.options.declarationDir || this.options.outDir : this.options.outDir;
                 if (outDir) {
                     const common = this.commonSourceDirectory;
                     if (common) {
@@ -249,7 +249,7 @@ namespace compiler {
         }
 
         // establish defaults (aligns with old harness)
-        if (compilerOptions.target === undefined) compilerOptions.target = ts.ScriptTarget.ES3;
+        if (compilerOptions.target === undefined && compilerOptions.module !== ts.ModuleKind.Node12 && compilerOptions.module !== ts.ModuleKind.NodeNext) compilerOptions.target = ts.ScriptTarget.ES3;
         if (compilerOptions.newLine === undefined) compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed;
         if (compilerOptions.skipDefaultLibCheck === undefined) compilerOptions.skipDefaultLibCheck = true;
         if (compilerOptions.noErrorTruncation === undefined) compilerOptions.noErrorTruncation = true;
@@ -264,7 +264,9 @@ namespace compiler {
         const program = ts.createProgram(rootFiles || [], compilerOptions, host);
         const emitResult = program.emit();
         const postErrors = ts.getPreEmitDiagnostics(program);
-        const errors = preErrors && (preErrors.length !== postErrors.length) ? [...postErrors,
+        const longerErrors = ts.length(preErrors) > postErrors.length ? preErrors : postErrors;
+        const shorterErrors = longerErrors === preErrors ? postErrors : preErrors;
+        const errors = preErrors && (preErrors.length !== postErrors.length) ? [...shorterErrors!,
             ts.addRelatedInfo(
                 ts.createCompilerDiagnostic({
                     category: ts.DiagnosticCategory.Error,
@@ -278,7 +280,7 @@ namespace compiler {
                     key: "-1",
                     message: `The excess diagnostics are:`
                 }),
-                ...ts.filter(postErrors, p => !ts.some(preErrors, p2 => ts.compareDiagnostics(p, p2) === ts.Comparison.EqualTo))
+                ...ts.filter(longerErrors!, p => !ts.some(shorterErrors, p2 => ts.compareDiagnostics(p, p2) === ts.Comparison.EqualTo))
             )
         ] : postErrors;
         return new CompilationResult(host, compilerOptions, program, emitResult, errors);
diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts
index 9e4db5e973b1d..9d3dbfb8a8075 100644
--- a/src/harness/fourslashImpl.ts
+++ b/src/harness/fourslashImpl.ts
@@ -313,12 +313,13 @@ namespace FourSlash {
                     this.addMatchedInputFile(referenceFilePath, /* extensions */ undefined);
                 });
 
+                const exts = ts.flatten(ts.getSupportedExtensions(compilationOptions));
                 // Add import files into language-service host
                 ts.forEach(importedFiles, importedFile => {
                     // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts"
                     // so convert them before making appropriate comparison
                     const importedFilePath = this.basePath + "/" + importedFile.fileName;
-                    this.addMatchedInputFile(importedFilePath, ts.getSupportedExtensions(compilationOptions));
+                    this.addMatchedInputFile(importedFilePath, exts);
                 });
 
                 // Check if no-default-lib flag is false and if so add default library
@@ -636,7 +637,8 @@ namespace FourSlash {
             ts.forEachKey(this.inputFiles, fileName => {
                 if (!ts.isAnySupportedFileExtension(fileName)
                     || Harness.getConfigNameFromFileName(fileName)
-                    || !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))) return;
+                    || !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
+                    || ts.getBaseFileName(fileName) === "package.json") return;
                 const errors = this.getDiagnostics(fileName).filter(e => e.category !== ts.DiagnosticCategory.Suggestion);
                 if (errors.length) {
                     this.printErrorLog(/*expectErrors*/ false, errors);
@@ -1927,7 +1929,7 @@ namespace FourSlash {
         }
 
         public baselineSyntacticAndSemanticDiagnostics() {
-            const files = this.getCompilerTestFiles();
+            const files = ts.filter(this.getCompilerTestFiles(), f => !ts.endsWith(f.unitName, ".json"));
             const result = this.getSyntacticDiagnosticBaselineText(files)
                 + Harness.IO.newLine()
                 + Harness.IO.newLine()
diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts
index e4730a2e9fdda..450ed9f6174f6 100644
--- a/src/harness/harnessIO.ts
+++ b/src/harness/harnessIO.ts
@@ -271,7 +271,7 @@ namespace Harness {
         }
 
         export function getDefaultLibFileName(options: ts.CompilerOptions): string {
-            switch (options.target) {
+            switch (ts.getEmitScriptTarget(options)) {
                 case ts.ScriptTarget.ESNext:
                 case ts.ScriptTarget.ES2017:
                     return "lib.es2017.d.ts";
@@ -391,7 +391,7 @@ namespace Harness {
             symlinks?: vfs.FileSet
         ): compiler.CompilationResult {
             const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.cloneCompilerOptions(compilerOptions) : { noResolve: false };
-            options.target = options.target || ts.ScriptTarget.ES3;
+            options.target = ts.getEmitScriptTarget(options);
             options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed;
             options.noErrorTruncation = true;
             options.skipDefaultLibCheck = typeof options.skipDefaultLibCheck === "undefined" ? true : options.skipDefaultLibCheck;
@@ -505,7 +505,7 @@ namespace Harness {
                     sourceFileName = outFile;
                 }
 
-                const dTsFileName = ts.removeFileExtension(sourceFileName) + ts.Extension.Dts;
+                const dTsFileName = ts.removeFileExtension(sourceFileName) + ts.getDeclarationEmitExtensionForPath(sourceFileName);
                 return result.dts.get(dTsFileName);
             }
 
@@ -897,7 +897,7 @@ namespace Harness {
                     jsCode += "\r\n";
                 }
                 if (!result.diagnostics.length && !ts.endsWith(file.file, ts.Extension.Json)) {
-                    const fileParseResult = ts.createSourceFile(file.file, file.text, options.target || ts.ScriptTarget.ES3, /*parentNodes*/ false, ts.endsWith(file.file, "x") ? ts.ScriptKind.JSX : ts.ScriptKind.JS);
+                    const fileParseResult = ts.createSourceFile(file.file, file.text, ts.getEmitScriptTarget(options), /*parentNodes*/ false, ts.endsWith(file.file, "x") ? ts.ScriptKind.JSX : ts.ScriptKind.JS);
                     if (ts.length(fileParseResult.parseDiagnostics)) {
                         jsCode += getErrorBaseline([file.asTestFile()], fileParseResult.parseDiagnostics);
                         return;
diff --git a/src/harness/vpathUtil.ts b/src/harness/vpathUtil.ts
index 31419e976fffb..44ef5b0f6af3f 100644
--- a/src/harness/vpathUtil.ts
+++ b/src/harness/vpathUtil.ts
@@ -108,7 +108,7 @@ namespace vpath {
     }
 
     export function isDeclaration(path: string) {
-        return extname(path, ".d.ts", /*ignoreCase*/ false).length > 0;
+        return ts.fileExtensionIsOneOf(path, [ts.Extension.Dmts, ts.Extension.Dcts, ts.Extension.Dts]);
     }
 
     export function isSourceMap(path: string) {
diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts
index 81afcd26f79c9..50402fa2c12b3 100644
--- a/src/server/editorServices.ts
+++ b/src/server/editorServices.ts
@@ -4134,7 +4134,7 @@ namespace ts.server {
                     },
                     PollingInterval.Low,
                     this.hostConfiguration.watchOptions,
-                    WatchType.PackageJsonFile,
+                    WatchType.PackageJson,
                 ));
             }
         }
diff --git a/src/server/project.ts b/src/server/project.ts
index 30560bc3e2b2a..197585ff86b91 100644
--- a/src/server/project.ts
+++ b/src/server/project.ts
@@ -472,12 +472,12 @@ namespace ts.server {
             return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file);
         }
 
-        resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModuleFull | undefined)[] {
-            return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference);
+        resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference, _options?: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModuleFull | undefined)[] {
+            return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile);
         }
 
-        getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined {
-            return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile);
+        getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined {
+            return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
         }
 
         resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[] {
diff --git a/src/server/watchType.ts b/src/server/watchType.ts
index 2b9edafb09870..7893de0e26bc1 100644
--- a/src/server/watchType.ts
+++ b/src/server/watchType.ts
@@ -8,7 +8,6 @@ namespace ts {
         MissingSourceMapFile: "Missing source map file",
         NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root",
         MissingGeneratedFile: "Missing generated file",
-        PackageJsonFile: "package.json file for import suggestions",
         NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation",
     }
     WatchType.ClosedScriptInfo = "Closed Script info";
@@ -17,5 +16,4 @@ namespace ts {
     WatchType.MissingSourceMapFile = "Missing source map file";
     WatchType.NoopConfigFileForInferredRoot = "Noop Config file for the inferred project root";
     WatchType.MissingGeneratedFile = "Missing generated file";
-    WatchType.PackageJsonFile = "package.json file for import suggestions";
 }
diff --git a/src/services/codefixes/convertFunctionToEs6Class.ts b/src/services/codefixes/convertFunctionToEs6Class.ts
index 70de7a1978d14..8a20f68840d4c 100644
--- a/src/services/codefixes/convertFunctionToEs6Class.ts
+++ b/src/services/codefixes/convertFunctionToEs6Class.ts
@@ -259,7 +259,7 @@ namespace ts.codefix {
         }
 
         if (isStringLiteralLike(propName)) {
-            return isIdentifierText(propName.text, compilerOptions.target) ? factory.createIdentifier(propName.text)
+            return isIdentifierText(propName.text, getEmitScriptTarget(compilerOptions)) ? factory.createIdentifier(propName.text)
                 : isNoSubstitutionTemplateLiteral(propName) ? factory.createStringLiteral(propName.text, quotePreference === QuotePreference.Single)
                 : propName;
         }
diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts
index e15c507a4ef65..f01209290b234 100644
--- a/src/services/codefixes/convertToEs6Module.ts
+++ b/src/services/codefixes/convertToEs6Module.ts
@@ -5,7 +5,7 @@ namespace ts.codefix {
         getCodeActions(context) {
             const { sourceFile, program, preferences } = context;
             const changes = textChanges.ChangeTracker.with(context, changes => {
-                const moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target!, getQuotePreference(sourceFile, preferences));
+                const moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, getEmitScriptTarget(program.getCompilerOptions()), getQuotePreference(sourceFile, preferences));
                 if (moduleExportsChangedToDefault) {
                     for (const importingFile of program.getSourceFiles()) {
                         fixImportOfModuleExports(importingFile, sourceFile, changes, getQuotePreference(importingFile, preferences));
@@ -19,7 +19,7 @@ namespace ts.codefix {
 
     function fixImportOfModuleExports(importingFile: SourceFile, exportingFile: SourceFile, changes: textChanges.ChangeTracker, quotePreference: QuotePreference) {
         for (const moduleSpecifier of importingFile.imports) {
-            const imported = getResolvedModule(importingFile, moduleSpecifier.text);
+            const imported = getResolvedModule(importingFile, moduleSpecifier.text, getModeForUsageLocation(importingFile, moduleSpecifier));
             if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
                 continue;
             }
diff --git a/src/services/codefixes/fixModuleAndTargetOptions.ts b/src/services/codefixes/fixModuleAndTargetOptions.ts
index 16ea0fab7fd07..45e1185cac909 100644
--- a/src/services/codefixes/fixModuleAndTargetOptions.ts
+++ b/src/services/codefixes/fixModuleAndTargetOptions.ts
@@ -2,8 +2,8 @@
 namespace ts.codefix {
     registerCodeFix({
         errorCodes: [
-            Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code,
-            Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code,
+            Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
+            Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
         ],
         getCodeActions: context => {
             const compilerOptions = context.program.getCompilerOptions();
diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts
index 99ccc51e83d8b..fcac2b985597b 100644
--- a/src/services/codefixes/fixSpelling.ts
+++ b/src/services/codefixes/fixSpelling.ts
@@ -23,15 +23,15 @@ namespace ts.codefix {
             const info = getInfo(sourceFile, context.span.start, context, errorCode);
             if (!info) return undefined;
             const { node, suggestedSymbol } = info;
-            const { target } = context.host.getCompilationSettings();
-            const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestedSymbol, target!));
+            const target = getEmitScriptTarget(context.host.getCompilationSettings());
+            const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestedSymbol, target));
             return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId, Diagnostics.Fix_all_detected_spelling_errors)];
         },
         fixIds: [fixId],
         getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
             const info = getInfo(diag.file, diag.start, context, diag.code);
-            const { target } = context.host.getCompilationSettings();
-            if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target!);
+            const target = getEmitScriptTarget(context.host.getCompilationSettings());
+            if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
         }),
     });
 
@@ -128,7 +128,7 @@ namespace ts.codefix {
     function getResolvedSourceFileFromImportDeclaration(sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined {
         if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined;
 
-        const resolvedModule = getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text);
+        const resolvedModule = getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier));
         if (!resolvedModule) return undefined;
 
         return context.program.getSourceFile(resolvedModule.resolvedFileName);
diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts
index 646b6e7c9d5ec..3fc29c64b9935 100644
--- a/src/services/codefixes/importFixes.ts
+++ b/src/services/codefixes/importFixes.ts
@@ -255,7 +255,7 @@ namespace ts.codefix {
             }
 
             const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
-            if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
+            if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, getEmitScriptTarget(compilerOptions)) === symbolName) && skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
                 result.push({ symbol: defaultInfo.symbol, moduleSymbol, moduleFileName: moduleFile?.fileName, exportKind: defaultInfo.exportKind, targetFlags: skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson });
             }
 
@@ -597,6 +597,9 @@ namespace ts.codefix {
             case ModuleKind.None:
                 // Fall back to the `import * as ns` style import.
                 return ImportKind.Namespace;
+            case ModuleKind.Node12:
+            case ModuleKind.NodeNext:
+                return importingFile.impliedNodeFormat === ModuleKind.ESNext ? ImportKind.Namespace : ImportKind.CommonJS;
             default:
                 return Debug.assertNever(moduleKind, `Unexpected moduleKind ${moduleKind}`);
         }
@@ -662,7 +665,7 @@ namespace ts.codefix {
 
             const compilerOptions = program.getCompilerOptions();
             const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
-            if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
+            if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
                 addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
             }
 
diff --git a/src/services/completions.ts b/src/services/completions.ts
index ad5e24ea3ebfb..c318d29b82a94 100644
--- a/src/services/completions.ts
+++ b/src/services/completions.ts
@@ -426,7 +426,7 @@ namespace ts.Completions {
                 location,
                 sourceFile,
                 typeChecker,
-                compilerOptions.target!,
+                getEmitScriptTarget(compilerOptions),
                 log,
                 completionKind,
                 preferences,
@@ -440,7 +440,7 @@ namespace ts.Completions {
                 symbolToOriginInfoMap,
                 symbolToSortTextIdMap
             );
-            getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target!, entries); // TODO: GH#18217
+            getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
         }
         else {
             if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === KeywordCompletionFilters.None) {
@@ -454,7 +454,7 @@ namespace ts.Completions {
                 location,
                 sourceFile,
                 typeChecker,
-                compilerOptions.target!,
+                getEmitScriptTarget(compilerOptions),
                 log,
                 completionKind,
                 preferences,
@@ -965,7 +965,7 @@ namespace ts.Completions {
         // completion entry.
         return firstDefined(symbols, (symbol, index): SymbolCompletion | undefined => {
             const origin = symbolToOriginInfoMap[index];
-            const info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target!, origin, completionKind, completionData.isJsxIdentifierExpected);
+            const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
             return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
                 ? { type: "symbol" as const, symbol, location, origin, previousToken, isJsxInitializer, isTypeOnlyLocation }
                 : undefined;
@@ -1085,7 +1085,7 @@ namespace ts.Completions {
             exportedSymbol,
             moduleSymbol,
             sourceFile,
-            getNameForExportedSymbol(symbol, compilerOptions.target),
+            getNameForExportedSymbol(symbol, getEmitScriptTarget(compilerOptions)),
             host,
             program,
             formatContext,
diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts
index 77e64bf618bd2..719f219025929 100644
--- a/src/services/documentRegistry.ts
+++ b/src/services/documentRegistry.ts
@@ -201,7 +201,7 @@ namespace ts {
             acquiring: boolean,
             scriptKind?: ScriptKind): SourceFile {
             scriptKind = ensureScriptKind(fileName, scriptKind);
-            const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : compilationSettings.target || ScriptTarget.ES5;
+            const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : getEmitScriptTarget(compilationSettings);
             const bucket = getOrUpdate(buckets, key, () => new Map());
             const bucketEntry = bucket.get(path);
             let entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts
index 37661b28d0f54..3938653da9f0b 100644
--- a/src/services/findAllReferences.ts
+++ b/src/services/findAllReferences.ts
@@ -658,7 +658,7 @@ namespace ts.FindAllReferences {
                 if (!options.implementations && isStringLiteralLike(node)) {
                     if (isModuleSpecifierLike(node)) {
                         const fileIncludeReasons = program.getFileIncludeReasons();
-                        const referencedFileName = node.getSourceFile().resolvedModules?.get(node.text)?.resolvedFileName;
+                        const referencedFileName = node.getSourceFile().resolvedModules?.get(node.text, getModeForUsageLocation(node.getSourceFile(), node))?.resolvedFileName;
                         const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined;
                         if (referencedFile) {
                             return [{ definition: { type: DefinitionKind.String, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }];
diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts
index 907cc8f221ee6..fa0749df0cecc 100644
--- a/src/services/getEditsForFileRename.ts
+++ b/src/services/getEditsForFileRename.ts
@@ -189,9 +189,10 @@ namespace ts {
             return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true };
         }
         else {
+            const mode = getModeForUsageLocation(importingSourceFile, importLiteral);
             const resolved = host.resolveModuleNames
-                ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName)
-                : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName);
+                ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode)
+                : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
             return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
         }
     }
diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts
index 746e5a19a6927..af03eb260f507 100644
--- a/src/services/goToDefinition.ts
+++ b/src/services/goToDefinition.ts
@@ -170,10 +170,10 @@ namespace ts.GoToDefinition {
             return file && { reference: libReferenceDirective, fileName: file.fileName, file, unverified: false };
         }
 
-        if (sourceFile.resolvedModules?.size) {
+        if (sourceFile.resolvedModules?.size()) {
             const node = getTokenAtPosition(sourceFile, position);
-            if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) {
-                const verifiedFileName = sourceFile.resolvedModules.get(node.text)?.resolvedFileName;
+            if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, getModeForUsageLocation(sourceFile, node))) {
+                const verifiedFileName = sourceFile.resolvedModules.get(node.text, getModeForUsageLocation(sourceFile, node))?.resolvedFileName;
                 const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
                 return {
                     file: program.getSourceFile(fileName),
diff --git a/src/services/services.ts b/src/services/services.ts
index 426fe7a52690d..7c0dce0c5d999 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -642,8 +642,8 @@ namespace ts {
         public languageVariant!: LanguageVariant;
         public identifiers!: ESMap<string, string>;
         public nameTable: UnderscoreEscapedMap<number> | undefined;
-        public resolvedModules: ESMap<string, ResolvedModuleFull> | undefined;
-        public resolvedTypeReferenceDirectiveNames!: ESMap<string, ResolvedTypeReferenceDirective>;
+        public resolvedModules: ModeAwareCache<ResolvedModuleFull> | undefined;
+        public resolvedTypeReferenceDirectiveNames!: ModeAwareCache<ResolvedTypeReferenceDirective>;
         public imports!: readonly StringLiteralLike[];
         public moduleAugmentations!: StringLiteral[];
         private namedDeclarations: ESMap<string, Declaration[]> | undefined;
diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts
index 8105a537a7664..d0771f2e97b3b 100644
--- a/src/services/stringCompletions.ts
+++ b/src/services/stringCompletions.ts
@@ -91,6 +91,12 @@ namespace ts.Completions.StringCompletions {
             case Extension.Jsx: return ScriptElementKindModifier.jsxModifier;
             case Extension.Ts: return ScriptElementKindModifier.tsModifier;
             case Extension.Tsx: return ScriptElementKindModifier.tsxModifier;
+            case Extension.Dmts: return ScriptElementKindModifier.dmtsModifier;
+            case Extension.Mjs: return ScriptElementKindModifier.mjsModifier;
+            case Extension.Mts: return ScriptElementKindModifier.mtsModifier;
+            case Extension.Dcts: return ScriptElementKindModifier.dctsModifier;
+            case Extension.Cjs: return ScriptElementKindModifier.cjsModifier;
+            case Extension.Cts: return ScriptElementKindModifier.ctsModifier;
             case Extension.TsBuildInfo: return Debug.fail(`Extension ${Extension.TsBuildInfo} is unsupported.`);
             case undefined: return ScriptElementKindModifier.none;
             default:
@@ -315,8 +321,13 @@ namespace ts.Completions.StringCompletions {
         const scriptDirectory = getDirectoryPath(scriptPath);
 
         return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (isRootedDiskPath(literalValue) || isUrl(literalValue))
-            ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences)
+            ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
             : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
+
+        function getIncludeExtensionOption() {
+            const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined;
+            return preferences.importModuleSpecifierEnding === "js" || mode === ModuleKind.ESNext ? IncludeExtensionsOption.ModuleSpecifierCompletion : IncludeExtensionsOption.Exclude;
+        }
     }
 
     interface ExtensionOptions {
@@ -324,10 +335,9 @@ namespace ts.Completions.StringCompletions {
         readonly includeExtensionsOption: IncludeExtensionsOption;
     }
     function getExtensionOptions(compilerOptions: CompilerOptions, includeExtensionsOption = IncludeExtensionsOption.Exclude): ExtensionOptions {
-        return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensionsOption };
+        return { extensions: flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption };
     }
-    function getCompletionEntriesForRelativeModules(literalValue: string, scriptDirectory: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, scriptPath: Path, preferences: UserPreferences) {
-        const includeExtensions = preferences.importModuleSpecifierEnding === "js" ? IncludeExtensionsOption.ModuleSpecifierCompletion : IncludeExtensionsOption.Exclude;
+    function getCompletionEntriesForRelativeModules(literalValue: string, scriptDirectory: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, scriptPath: Path, includeExtensions: IncludeExtensionsOption) {
         const extensionOptions = getExtensionOptions(compilerOptions, includeExtensions);
         if (compilerOptions.rootDirs) {
             return getCompletionEntriesForDirectoryFragmentWithRootDirs(
@@ -338,10 +348,10 @@ namespace ts.Completions.StringCompletions {
         }
     }
 
-    function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[] {
+    function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[][] {
         const extensions = getSupportedExtensions(compilerOptions);
-        return compilerOptions.resolveJsonModule && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ?
-            extensions.concat(Extension.Json) :
+        return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ?
+            getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
             extensions;
     }
 
@@ -426,11 +436,11 @@ namespace ts.Completions.StringCompletions {
 
                 let foundFileName: string;
                 const outputExtension = moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
-                if (includeExtensionsOption === IncludeExtensionsOption.Exclude && !fileExtensionIs(filePath, Extension.Json)) {
+                if (includeExtensionsOption === IncludeExtensionsOption.Exclude && !fileExtensionIsOneOf(filePath, [Extension.Json, Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs])) {
                     foundFileName = removeFileExtension(getBaseFileName(filePath));
                     foundFiles.set(foundFileName, tryGetExtensionFromPath(filePath));
                 }
-                else if (includeExtensionsOption === IncludeExtensionsOption.ModuleSpecifierCompletion && outputExtension) {
+                else if ((fileExtensionIsOneOf(filePath, [Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs]) || includeExtensionsOption === IncludeExtensionsOption.ModuleSpecifierCompletion) && outputExtension) {
                     foundFileName = changeExtension(getBaseFileName(filePath), outputExtension);
                     foundFiles.set(foundFileName, outputExtension);
                 }
diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts
index 4e8392e837d09..ebefddfd80dec 100644
--- a/src/services/suggestionDiagnostics.ts
+++ b/src/services/suggestionDiagnostics.ts
@@ -23,7 +23,7 @@ namespace ts {
                 const importNode = importFromModuleSpecifier(moduleSpecifier);
                 const name = importNameForConvertToDefaultImport(importNode);
                 if (!name) continue;
-                const module = getResolvedModule(sourceFile, moduleSpecifier.text);
+                const module = getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier));
                 const resolvedFile = module && program.getSourceFile(module.resolvedFileName);
                 if (resolvedFile && resolvedFile.externalModuleIndicator && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
                     diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import));
diff --git a/src/services/transpile.ts b/src/services/transpile.ts
index 0ac54f8d172ca..5b73b91bd7f47 100644
--- a/src/services/transpile.ts
+++ b/src/services/transpile.ts
@@ -48,7 +48,7 @@ namespace ts {
 
         // if jsx is specified then treat file as .tsx
         const inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
-        const sourceFile = createSourceFile(inputFileName, input, options.target!); // TODO: GH#18217
+        const sourceFile = createSourceFile(inputFileName, input, getEmitScriptTarget(options));
         if (transpileOptions.moduleName) {
             sourceFile.moduleName = transpileOptions.moduleName;
         }
diff --git a/src/services/types.ts b/src/services/types.ts
index 0e5d95a15e971..816c83771b0a5 100644
--- a/src/services/types.ts
+++ b/src/services/types.ts
@@ -275,8 +275,8 @@ namespace ts {
          *
          * If this is implemented, `getResolvedModuleWithFailedLookupLocationsFromCache` should be too.
          */
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
-        getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
+        getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
         resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
         /* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution;
         /* @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames;
@@ -1481,6 +1481,12 @@ namespace ts {
         jsModifier = ".js",
         jsxModifier = ".jsx",
         jsonModifier = ".json",
+        dmtsModifier = ".d.mts",
+        mtsModifier = ".mts",
+        mjsModifier = ".mjs",
+        dctsModifier = ".d.cts",
+        ctsModifier = ".cts",
+        cjsModifier = ".cjs",
     }
 
     export const enum ClassificationTypeNames {
diff --git a/src/services/utilities.ts b/src/services/utilities.ts
index 851d6c91d04d9..696e8e02337fd 100644
--- a/src/services/utilities.ts
+++ b/src/services/utilities.ts
@@ -1840,7 +1840,7 @@ namespace ts {
         return program.getSourceFiles().some(s => !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator);
     }
     export function compilerOptionsIndicateEs6Modules(compilerOptions: CompilerOptions): boolean {
-        return !!compilerOptions.module || compilerOptions.target! >= ScriptTarget.ES2015 || !!compilerOptions.noEmit;
+        return !!compilerOptions.module || getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 || !!compilerOptions.noEmit;
     }
 
     export function createModuleSpecifierResolutionHost(program: Program, host: LanguageServiceHost): ModuleSpecifierResolutionHost {
diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts
index 2b973991f8c41..50bb22cdfbc8e 100644
--- a/src/testRunner/unittests/config/commandLineParsing.ts
+++ b/src/testRunner/unittests/config/commandLineParsing.ts
@@ -159,7 +159,7 @@ namespace ts {
                         start: undefined,
                         length: undefined,
                     }, {
-                        messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.",
+                        messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.",
                         category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
                         code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
 
diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts
index a11978dab4993..87c3587ec2fed 100644
--- a/src/testRunner/unittests/moduleResolution.ts
+++ b/src/testRunner/unittests/moduleResolution.ts
@@ -82,9 +82,11 @@ namespace ts {
     }
 
     describe("unittests:: moduleResolution:: Node module resolution - relative paths", () => {
-
+        // node module resolution does _not_ implicitly append these extensions to an extensionless path (though will still attempt to load them if explicitly)
+        const nonImplicitExtensions = [Extension.Mts, Extension.Dmts, Extension.Mjs, Extension.Cts, Extension.Dcts, Extension.Cjs];
+        const autoExtensions = filter(supportedTSExtensionsFlat, e => nonImplicitExtensions.indexOf(e) === -1);
         function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void {
-            for (const ext of supportedTSExtensions) {
+            for (const ext of autoExtensions) {
                 test(ext, /*hasDirectoryExists*/ false);
                 test(ext, /*hasDirectoryExists*/ true);
             }
@@ -97,7 +99,7 @@ namespace ts {
 
                 const failedLookupLocations: string[] = [];
                 const dir = getDirectoryPath(containingFileName);
-                for (const e of supportedTSExtensions) {
+                for (const e of autoExtensions) {
                     if (e === ext) {
                         break;
                     }
@@ -138,7 +140,7 @@ namespace ts {
                 const resolution = nodeModuleNameResolver(moduleName, containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, packageJson, moduleFile));
                 checkResolvedModule(resolution.resolvedModule, createResolvedModule(moduleFile.name));
                 // expect three failed lookup location - attempt to load module as file with all supported extensions
-                assert.equal(resolution.failedLookupLocations.length, supportedTSExtensions.length);
+                assert.equal(resolution.failedLookupLocations.length, supportedTSExtensions[0].length);
             }
         }
 
@@ -204,7 +206,7 @@ namespace ts {
     describe("unittests:: moduleResolution:: Node module resolution - non-relative paths", () => {
         it("computes correct commonPrefix for moduleName cache", () => {
             const resolutionCache = createModuleResolutionCache("/", (f) => f);
-            let cache = resolutionCache.getOrCreateCacheForModuleName("a");
+            let cache = resolutionCache.getOrCreateCacheForModuleName("a", /*mode*/ undefined);
             cache.set("/sub", {
                 resolvedModule: {
                     originalPath: undefined,
@@ -217,7 +219,7 @@ namespace ts {
             assert.isDefined(cache.get("/sub"));
             assert.isUndefined(cache.get("/"));
 
-            cache = resolutionCache.getOrCreateCacheForModuleName("b");
+            cache = resolutionCache.getOrCreateCacheForModuleName("b", /*mode*/ undefined);
             cache.set("/sub/dir/foo", {
                 resolvedModule: {
                     originalPath: undefined,
@@ -232,7 +234,7 @@ namespace ts {
             assert.isDefined(cache.get("/sub"));
             assert.isUndefined(cache.get("/"));
 
-            cache = resolutionCache.getOrCreateCacheForModuleName("c");
+            cache = resolutionCache.getOrCreateCacheForModuleName("c", /*mode*/ undefined);
             cache.set("/foo/bar", {
                 resolvedModule: {
                     originalPath: undefined,
@@ -246,7 +248,7 @@ namespace ts {
             assert.isDefined(cache.get("/foo"));
             assert.isDefined(cache.get("/"));
 
-            cache = resolutionCache.getOrCreateCacheForModuleName("d");
+            cache = resolutionCache.getOrCreateCacheForModuleName("d", /*mode*/ undefined);
             cache.set("/foo", {
                 resolvedModule: {
                     originalPath: undefined,
@@ -259,7 +261,7 @@ namespace ts {
             assert.isDefined(cache.get("/foo"));
             assert.isUndefined(cache.get("/"));
 
-            cache = resolutionCache.getOrCreateCacheForModuleName("e");
+            cache = resolutionCache.getOrCreateCacheForModuleName("e", /*mode*/ undefined);
             cache.set("c:/foo", {
                 resolvedModule: {
                     originalPath: undefined,
@@ -273,7 +275,7 @@ namespace ts {
             assert.isDefined(cache.get("c:/"));
             assert.isUndefined(cache.get("d:/"));
 
-            cache = resolutionCache.getOrCreateCacheForModuleName("f");
+            cache = resolutionCache.getOrCreateCacheForModuleName("f", /*mode*/ undefined);
             cache.set("/foo/bar/baz", {
                 resolvedModule: undefined,
                 failedLookupLocations: [],
diff --git a/src/testRunner/unittests/programApi.ts b/src/testRunner/unittests/programApi.ts
index b71d13e54cd7e..359dff1c03434 100644
--- a/src/testRunner/unittests/programApi.ts
+++ b/src/testRunner/unittests/programApi.ts
@@ -11,7 +11,7 @@ namespace ts {
         assert.equal(notFound.length, 0, `Not found ${notFound} in actual: ${missingPaths} expected: ${expected}`);
     }
 
-    describe("unittests:: Program.getMissingFilePaths", () => {
+    describe("unittests:: programApi:: Program.getMissingFilePaths", () => {
 
         const options: CompilerOptions = {
             noLib: true,
diff --git a/src/testRunner/unittests/reuseProgramStructure.ts b/src/testRunner/unittests/reuseProgramStructure.ts
index 2face82e2d0aa..6dc13de241d47 100644
--- a/src/testRunner/unittests/reuseProgramStructure.ts
+++ b/src/testRunner/unittests/reuseProgramStructure.ts
@@ -175,7 +175,7 @@ namespace ts {
         return true;
     }
 
-    function checkCache<T>(caption: string, program: Program, fileName: string, expectedContent: ESMap<string, T> | undefined, getCache: (f: SourceFile) => ESMap<string, T> | undefined, entryChecker: (expected: T, original: T) => boolean): void {
+    function checkCache<T>(caption: string, program: Program, fileName: string, expectedContent: ESMap<string, T> | undefined, getCache: (f: SourceFile) => ModeAwareCache<T> | undefined, entryChecker: (expected: T, original: T) => boolean): void {
         const file = program.getSourceFile(fileName);
         assert.isTrue(file !== undefined, `cannot find file ${fileName}`);
         const cache = getCache(file!);
@@ -184,21 +184,22 @@ namespace ts {
         }
         else {
             assert.isTrue(cache !== undefined, `expected ${caption} to be set`);
-            assert.isTrue(mapsAreEqual(expectedContent, cache!, entryChecker), `contents of ${caption} did not match the expected contents.`);
+            assert.isTrue(mapEqualToCache(expectedContent, cache!, entryChecker), `contents of ${caption} did not match the expected contents.`);
         }
     }
 
     /** True if the maps have the same keys and values. */
-    function mapsAreEqual<T>(left: ESMap<string, T>, right: ESMap<string, T>, valuesAreEqual?: (left: T, right: T) => boolean): boolean {
-        if (left === right) return true;
+    function mapEqualToCache<T>(left: ESMap<string, T>, right: ModeAwareCache<T>, valuesAreEqual?: (left: T, right: T) => boolean): boolean {
+        if (left as any === right) return true; // given the type mismatch (the tests never pass a cache), this'll never be true
         if (!left || !right) return false;
         const someInLeftHasNoMatch = forEachEntry(left, (leftValue, leftKey) => {
-            if (!right.has(leftKey)) return true;
-            const rightValue = right.get(leftKey)!;
+            if (!right.has(leftKey, /*mode*/ undefined)) return true;
+            const rightValue = right.get(leftKey, /*mode*/ undefined)!;
             return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue);
         });
         if (someInLeftHasNoMatch) return false;
-        const someInRightHasNoMatch = forEachKey(right, rightKey => !left.has(rightKey));
+        let someInRightHasNoMatch = false;
+        right.forEach((_, rightKey) => someInRightHasNoMatch = someInRightHasNoMatch || !left.has(rightKey));
         return !someInRightHasNoMatch;
     }
 
@@ -383,7 +384,7 @@ namespace ts {
             const program2 = updateProgram(program1, ["/a.ts"], options, files => {
                 files[0].text = files[0].text.updateProgram('import * as aa from "a";');
             });
-            assert.isDefined(program2.getSourceFile("/a.ts")!.resolvedModules!.get("a"), "'a' is not an unresolved module after re-use");
+            assert.isDefined(program2.getSourceFile("/a.ts")!.resolvedModules!.get("a", /*mode*/ undefined), "'a' is not an unresolved module after re-use");
         });
 
         it("works with updated SourceFiles", () => {
@@ -406,7 +407,7 @@ namespace ts {
                 }
             };
             const program2 = createProgram(["/a.ts"], options, updateHost, program1);
-            assert.isDefined(program2.getSourceFile("/a.ts")!.resolvedModules!.get("a"), "'a' is not an unresolved module after re-use");
+            assert.isDefined(program2.getSourceFile("/a.ts")!.resolvedModules!.get("a", /*mode*/ undefined), "'a' is not an unresolved module after re-use");
             assert.strictEqual(sourceFile.statements[2].getSourceFile(), sourceFile, "parent pointers are not altered");
         });
 
diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts
index 7d9924f764165..0ac722293626f 100644
--- a/src/testRunner/unittests/tsbuild/moduleResolution.ts
+++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts
@@ -66,6 +66,96 @@ namespace ts.tscWatch {
             changes: emptyArray
         });
 
+        verifyTscWatch({
+            scenario: "moduleResolution",
+            subScenario: `resolves specifier in output declaration file from referenced project correctly with cts and mts extensions`,
+            sys: () => createWatchedSystem([
+                {
+                    path: `${projectRoot}/packages/pkg1/package.json`,
+                    content: JSON.stringify({
+                        name: "pkg1",
+                        version: "1.0.0",
+                        main: "build/index.js",
+                        type: "module"
+                    })
+                },
+                {
+                    path: `${projectRoot}/packages/pkg1/index.ts`,
+                    content: Utils.dedent`
+                    import type { TheNum } from 'pkg2'
+                    export const theNum: TheNum = 42;`
+                },
+                {
+                    path: `${projectRoot}/packages/pkg1/tsconfig.json`,
+                    content: JSON.stringify({
+                        compilerOptions: {
+                            outDir: "build",
+                            module: "node12",
+                        },
+                        references: [{ path: "../pkg2" }]
+                    })
+                },
+                {
+                    path: `${projectRoot}/packages/pkg2/const.cts`,
+                    content: `export type TheNum = 42;`
+                },
+                {
+                    path: `${projectRoot}/packages/pkg2/index.ts`,
+                    content: `export type { TheNum } from './const.cjs';`
+                },
+                {
+                    path: `${projectRoot}/packages/pkg2/tsconfig.json`,
+                    content: JSON.stringify({
+                        compilerOptions: {
+                            composite: true,
+                            outDir: "build",
+                            module: "node12",
+                        }
+                    })
+                },
+                {
+                    path: `${projectRoot}/packages/pkg2/package.json`,
+                    content: JSON.stringify({
+                        name: "pkg2",
+                        version: "1.0.0",
+                        main: "build/index.js",
+                        type: "module"
+                    })
+                },
+                {
+                    path: `${projectRoot}/node_modules/pkg2`,
+                    symLink: `${projectRoot}/packages/pkg2`,
+                },
+                { ...libFile, path: `/a/lib/lib.es2020.full.d.ts` }
+            ], { currentDirectory: projectRoot }),
+            commandLineArgs: ["-b", "packages/pkg1", "-w", "--verbose", "--traceResolution"],
+            changes: [
+                {
+                    caption: "reports import errors after change to package file",
+                    change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"module"`, `"commonjs"`),
+                    timeouts: runQueuedTimeoutCallbacks,
+                },
+                {
+                    caption: "removes those errors when a package file is changed back",
+                    change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"commonjs"`, `"module"`),
+                    timeouts: runQueuedTimeoutCallbacks,
+                },
+                {
+                    caption: "reports import errors after change to package file",
+                    change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"module"`, `"commonjs"`),
+                    timeouts: runQueuedTimeoutCallbacks,
+                },
+                {
+                    caption: "removes those errors when a package file is changed to cjs extensions",
+                    change: sys => {
+                        replaceFileText(sys, `${projectRoot}/packages/pkg2/package.json`, `"build/index.js"`, `"build/index.cjs"`);
+                        sys.renameFile(`${projectRoot}/packages/pkg2/index.ts`, `${projectRoot}/packages/pkg2/index.cts`);
+                    },
+                    timeouts: runQueuedTimeoutCallbacks,
+                },
+            ]
+        });
+
         verifyTsc({
             scenario: "moduleResolution",
             subScenario: `type reference resolution uses correct options for different resolution options referenced project`,
diff --git a/src/testRunner/unittests/tscWatch/incremental.ts b/src/testRunner/unittests/tscWatch/incremental.ts
index bc6e541815a5c..8da2d0c09c4ba 100644
--- a/src/testRunner/unittests/tscWatch/incremental.ts
+++ b/src/testRunner/unittests/tscWatch/incremental.ts
@@ -163,16 +163,19 @@ namespace ts.tscWatch {
                         version: system.createHash(libFile.content),
                         signature: system.createHash(libFile.content),
                         affectsGlobalScope: true,
+                        impliedFormat: undefined,
                     });
                     assert.deepEqual(state.fileInfos.get(file1.path as Path), {
                         version: system.createHash(file1.content),
                         signature: system.createHash(file1.content),
                         affectsGlobalScope: undefined,
+                        impliedFormat: undefined,
                     });
                     assert.deepEqual(state.fileInfos.get(file2.path as Path), {
                         version: system.createHash(fileModified.content),
                         signature: system.createHash(fileModified.content),
                         affectsGlobalScope: undefined,
+                        impliedFormat: undefined,
                     });
 
                     assert.deepEqual(state.compilerOptions, {
diff --git a/src/testRunner/unittests/tsserver/typingsInstaller.ts b/src/testRunner/unittests/tsserver/typingsInstaller.ts
index 7995b66670ec8..470eb8717f276 100644
--- a/src/testRunner/unittests/tsserver/typingsInstaller.ts
+++ b/src/testRunner/unittests/tsserver/typingsInstaller.ts
@@ -1838,7 +1838,7 @@ namespace ts.projectSystem {
         const foooPath = "/a/b/node_modules/fooo/index.d.ts";
         function verifyResolvedModuleOfFooo(project: server.Project) {
             server.updateProjectIfDirty(project);
-            const foooResolution = project.getLanguageService().getProgram()!.getSourceFileByPath(appPath)!.resolvedModules!.get("fooo")!;
+            const foooResolution = project.getLanguageService().getProgram()!.getSourceFileByPath(appPath)!.resolvedModules!.get("fooo", /*mode*/ undefined)!;
             assert.equal(foooResolution.resolvedFileName, foooPath);
             return foooResolution;
         }
diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts
index baa075cbd9a71..f03149497862a 100644
--- a/tests/baselines/reference/api/tsserverlibrary.d.ts
+++ b/tests/baselines/reference/api/tsserverlibrary.d.ts
@@ -2030,6 +2030,18 @@ declare namespace ts {
          */
         hasNoDefaultLib: boolean;
         languageVersion: ScriptTarget;
+        /**
+         * When `module` is `Node12` or `NodeNext`, this field controls whether the
+         * source file in question is an ESNext-output-format file, or a CommonJS-output-format
+         * module. This is derived by the module resolver as it looks up the file, since
+         * it is derived from either the file extension of the module, or the containing
+         * `package.json` context, and affects both checking and emit.
+         *
+         * It is _public_ so that (pre)transformers can set this field,
+         * since it switches the builtin `node` module transform. Generally speaking, if unset,
+         * the field is treated as though it is `ModuleKind.CommonJS`.
+         */
+        impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
     }
     export interface Bundle extends Node {
         readonly kind: SyntaxKind.Bundle;
@@ -2847,7 +2859,9 @@ declare namespace ts {
     }
     export enum ModuleResolutionKind {
         Classic = 1,
-        NodeJs = 2
+        NodeJs = 2,
+        Node12 = 3,
+        NodeNext = 99
     }
     export interface PluginImport {
         name: string;
@@ -3009,7 +3023,9 @@ declare namespace ts {
         System = 4,
         ES2015 = 5,
         ES2020 = 6,
-        ESNext = 99
+        ESNext = 99,
+        Node12 = 100,
+        NodeNext = 199
     }
     export enum JsxEmit {
         None = 0,
@@ -3155,7 +3171,13 @@ declare namespace ts {
         Js = ".js",
         Jsx = ".jsx",
         Json = ".json",
-        TsBuildInfo = ".tsbuildinfo"
+        TsBuildInfo = ".tsbuildinfo",
+        Mjs = ".mjs",
+        Mts = ".mts",
+        Dmts = ".d.mts",
+        Cjs = ".cjs",
+        Cts = ".cts",
+        Dcts = ".d.cts"
     }
     export interface ResolvedModuleWithFailedLookupLocations {
         readonly resolvedModule: ResolvedModuleFull | undefined;
@@ -3183,7 +3205,11 @@ declare namespace ts {
         useCaseSensitiveFileNames(): boolean;
         getNewLine(): string;
         readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[];
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
+        /**
+         * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
+         */
+        getModuleResolutionCache?(): ModuleResolutionCache | undefined;
         /**
          * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
          */
@@ -4829,12 +4855,20 @@ declare namespace ts {
     export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[];
     export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
     }
+    export interface ModeAwareCache<T> {
+        get(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): T | undefined;
+        set(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, value: T): this;
+        delete(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): this;
+        has(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): boolean;
+        forEach(cb: (elem: T, key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined) => void): void;
+        size(): number;
+    }
     /**
      * Cached resolutions per containing directory.
      * This assumes that any module id will have the same resolution for sibling files located in the same folder.
      */
     export interface PerDirectoryResolutionCache<T> {
-        getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map<T>;
+        getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): ModeAwareCache<T>;
         clear(): void;
         /**
          *  Updates with the current compilerOptions the cache will operate with.
@@ -4850,7 +4884,7 @@ declare namespace ts {
      * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive.
      */
     export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache {
-        getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
+        getOrCreateCacheForModuleName(nonRelativeModuleName: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
     }
     export interface PackageJsonInfoCache {
         clear(): void;
@@ -4861,8 +4895,8 @@ declare namespace ts {
     }
     export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache;
     export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache;
-    export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined;
-    export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
+    export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
+    export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations;
     export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
     export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
     export {};
@@ -4973,6 +5007,17 @@ declare namespace ts {
     export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
     export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
     export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
+    /**
+     * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
+     * `options` parameter.
+     *
+     * @param fileName The normalized absolute path to check the format of (it need not exist on disk)
+     * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
+     * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
+     * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
+     * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
+     */
+    export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined;
     /**
      * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
      * that represent a compilation unit.
@@ -5217,7 +5262,7 @@ declare namespace ts {
         /** If provided is used to get the environment variable */
         getEnvironmentVariable?(name: string): string | undefined;
         /** If provided, used to resolve the module names, otherwise typescript's default module resolution */
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
         /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
         resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
     }
@@ -5607,8 +5652,8 @@ declare namespace ts {
         realpath?(path: string): string;
         fileExists?(path: string): boolean;
         getTypeRootsVersion?(): number;
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
-        getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
+        getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
         resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
         getDirectories?(directoryName: string): string[];
         /**
@@ -6556,7 +6601,13 @@ declare namespace ts {
         tsxModifier = ".tsx",
         jsModifier = ".js",
         jsxModifier = ".jsx",
-        jsonModifier = ".json"
+        jsonModifier = ".json",
+        dmtsModifier = ".d.mts",
+        mtsModifier = ".mts",
+        mjsModifier = ".mjs",
+        dctsModifier = ".d.cts",
+        ctsModifier = ".cts",
+        cjsModifier = ".cjs"
     }
     enum ClassificationTypeNames {
         comment = "comment",
@@ -9793,8 +9844,8 @@ declare namespace ts.server {
         readFile(fileName: string): string | undefined;
         writeFile(fileName: string, content: string): void;
         fileExists(file: string): boolean;
-        resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModuleFull | undefined)[];
-        getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
+        resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference, _options?: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModuleFull | undefined)[];
+        getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
         resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[];
         directoryExists(path: string): boolean;
         getDirectories(path: string): string[];
diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts
index da759028a5b98..8ebce80cf41f1 100644
--- a/tests/baselines/reference/api/typescript.d.ts
+++ b/tests/baselines/reference/api/typescript.d.ts
@@ -2030,6 +2030,18 @@ declare namespace ts {
          */
         hasNoDefaultLib: boolean;
         languageVersion: ScriptTarget;
+        /**
+         * When `module` is `Node12` or `NodeNext`, this field controls whether the
+         * source file in question is an ESNext-output-format file, or a CommonJS-output-format
+         * module. This is derived by the module resolver as it looks up the file, since
+         * it is derived from either the file extension of the module, or the containing
+         * `package.json` context, and affects both checking and emit.
+         *
+         * It is _public_ so that (pre)transformers can set this field,
+         * since it switches the builtin `node` module transform. Generally speaking, if unset,
+         * the field is treated as though it is `ModuleKind.CommonJS`.
+         */
+        impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
     }
     export interface Bundle extends Node {
         readonly kind: SyntaxKind.Bundle;
@@ -2847,7 +2859,9 @@ declare namespace ts {
     }
     export enum ModuleResolutionKind {
         Classic = 1,
-        NodeJs = 2
+        NodeJs = 2,
+        Node12 = 3,
+        NodeNext = 99
     }
     export interface PluginImport {
         name: string;
@@ -3009,7 +3023,9 @@ declare namespace ts {
         System = 4,
         ES2015 = 5,
         ES2020 = 6,
-        ESNext = 99
+        ESNext = 99,
+        Node12 = 100,
+        NodeNext = 199
     }
     export enum JsxEmit {
         None = 0,
@@ -3155,7 +3171,13 @@ declare namespace ts {
         Js = ".js",
         Jsx = ".jsx",
         Json = ".json",
-        TsBuildInfo = ".tsbuildinfo"
+        TsBuildInfo = ".tsbuildinfo",
+        Mjs = ".mjs",
+        Mts = ".mts",
+        Dmts = ".d.mts",
+        Cjs = ".cjs",
+        Cts = ".cts",
+        Dcts = ".d.cts"
     }
     export interface ResolvedModuleWithFailedLookupLocations {
         readonly resolvedModule: ResolvedModuleFull | undefined;
@@ -3183,7 +3205,11 @@ declare namespace ts {
         useCaseSensitiveFileNames(): boolean;
         getNewLine(): string;
         readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[];
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
+        /**
+         * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
+         */
+        getModuleResolutionCache?(): ModuleResolutionCache | undefined;
         /**
          * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
          */
@@ -4829,12 +4855,20 @@ declare namespace ts {
     export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[];
     export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
     }
+    export interface ModeAwareCache<T> {
+        get(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): T | undefined;
+        set(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, value: T): this;
+        delete(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): this;
+        has(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): boolean;
+        forEach(cb: (elem: T, key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined) => void): void;
+        size(): number;
+    }
     /**
      * Cached resolutions per containing directory.
      * This assumes that any module id will have the same resolution for sibling files located in the same folder.
      */
     export interface PerDirectoryResolutionCache<T> {
-        getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map<T>;
+        getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): ModeAwareCache<T>;
         clear(): void;
         /**
          *  Updates with the current compilerOptions the cache will operate with.
@@ -4850,7 +4884,7 @@ declare namespace ts {
      * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive.
      */
     export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache {
-        getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
+        getOrCreateCacheForModuleName(nonRelativeModuleName: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
     }
     export interface PackageJsonInfoCache {
         clear(): void;
@@ -4861,8 +4895,8 @@ declare namespace ts {
     }
     export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache;
     export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache;
-    export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined;
-    export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
+    export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
+    export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations;
     export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
     export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
     export {};
@@ -4973,6 +5007,17 @@ declare namespace ts {
     export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
     export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
     export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
+    /**
+     * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
+     * `options` parameter.
+     *
+     * @param fileName The normalized absolute path to check the format of (it need not exist on disk)
+     * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
+     * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
+     * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
+     * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
+     */
+    export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined;
     /**
      * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
      * that represent a compilation unit.
@@ -5217,7 +5262,7 @@ declare namespace ts {
         /** If provided is used to get the environment variable */
         getEnvironmentVariable?(name: string): string | undefined;
         /** If provided, used to resolve the module names, otherwise typescript's default module resolution */
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
         /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
         resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
     }
@@ -5607,8 +5652,8 @@ declare namespace ts {
         realpath?(path: string): string;
         fileExists?(path: string): boolean;
         getTypeRootsVersion?(): number;
-        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
-        getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
+        resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
+        getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
         resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
         getDirectories?(directoryName: string): string[];
         /**
@@ -6556,7 +6601,13 @@ declare namespace ts {
         tsxModifier = ".tsx",
         jsModifier = ".js",
         jsxModifier = ".jsx",
-        jsonModifier = ".json"
+        jsonModifier = ".json",
+        dmtsModifier = ".d.mts",
+        mtsModifier = ".mts",
+        mjsModifier = ".mjs",
+        dctsModifier = ".d.cts",
+        ctsModifier = ".cts",
+        cjsModifier = ".cjs"
     }
     enum ClassificationTypeNames {
         comment = "comment",
diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt
index ee1aa75d3cc74..6a5b413c154c2 100644
--- a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt
+++ b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt
@@ -12,8 +12,8 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(30,9): error TS1103: 'for await'
 tests/cases/compiler/awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.
 tests/cases/compiler/awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules.
 tests/cases/compiler/awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.
-tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
-tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
 
 
 ==== tests/cases/compiler/awaitInNonAsyncFunction.ts (16 errors) ====
@@ -97,7 +97,7 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level '
     
     for await (const _ of []);
         ~~~~~
-!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
     await null;
     ~~~~~
-!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
\ No newline at end of file
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
\ No newline at end of file
diff --git a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt
index 79f9afa5f34cb..c035c443cf289 100644
--- a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt
+++ b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt
@@ -1,9 +1,9 @@
-tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts(1,22): error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts(1,22): error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'.
 
 
 ==== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts (1 errors) ====
     /// <reference path="invalid" />
                          ~~~~~~~
-!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'.
     var x = 0; 
     
\ No newline at end of file
diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js
new file mode 100644
index 0000000000000..8aed6c9347aa2
--- /dev/null
+++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js
@@ -0,0 +1,27 @@
+//// [a.ts]
+declare var dec: any, __decorate: any;
+@dec export class A {
+}
+
+const o = { a: 1 };
+const y = { ...o };
+
+
+//// [a.js]
+"use strict";
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.A = void 0;
+let A = class A {
+};
+A = __decorate([
+    dec
+], A);
+exports.A = A;
+const o = { a: 1 };
+const y = Object.assign({}, o);
diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js
new file mode 100644
index 0000000000000..8aed6c9347aa2
--- /dev/null
+++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js
@@ -0,0 +1,27 @@
+//// [a.ts]
+declare var dec: any, __decorate: any;
+@dec export class A {
+}
+
+const o = { a: 1 };
+const y = { ...o };
+
+
+//// [a.js]
+"use strict";
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.A = void 0;
+let A = class A {
+};
+A = __decorate([
+    dec
+], A);
+exports.A = A;
+const o = { a: 1 };
+const y = Object.assign({}, o);
diff --git a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt
index f9603006232bb..12775e5e5807b 100644
--- a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt
+++ b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt
@@ -3,15 +3,15 @@ tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import asserti
 tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'.
 tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'.
 tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'.
-tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
 
 
 ==== tests/cases/conformance/importAssertion/0.ts (0 errors) ====
@@ -48,31 +48,31 @@ tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic impor
 ==== tests/cases/conformance/importAssertion/3.ts (9 errors) ====
     const a = import('./0')
               ~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     const b = import('./0', { assert: { type: "json" } })
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     const c = import('./0', { assert: { type: "json", ttype: "typo" } })
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     const d = import('./0', { assert: {} })
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     const dd = import('./0', {})
                ~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     declare function foo(): any;
     const e = import('./0', foo())
               ~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     const f = import()
               ~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     const g = import('./0', {}, {})
               ~~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     const h = import('./0', { assert: { type: "json" }},)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     
     
\ No newline at end of file
diff --git a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt
index d55a470765854..95937040daa0d 100644
--- a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt
+++ b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt
@@ -1,6 +1,6 @@
-tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
 
 
 ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ====
@@ -9,10 +9,10 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports
 ==== tests/cases/conformance/dynamicImport/1.ts (3 errors) ====
     import("./0");
     ~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     var p1 = import("./0");
              ~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     p1.then(zero => {
         return zero.foo();
     })
@@ -20,5 +20,5 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports
     function foo() {
         const p2 = import("./0");
                    ~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     }
\ No newline at end of file
diff --git a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt
index 6a0efe8747b20..4d1f7a55b3ce8 100644
--- a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt
+++ b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt
@@ -1,5 +1,5 @@
-tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
 
 
 ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ====
@@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo
     async function foo() {
         return await import((await import("./foo")).default);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
                                    ~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     }
\ No newline at end of file
diff --git a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt
index 6a0efe8747b20..4d1f7a55b3ce8 100644
--- a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt
+++ b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt
@@ -1,5 +1,5 @@
-tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
-tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
+tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
 
 
 ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ====
@@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo
     async function foo() {
         return await import((await import("./foo")).default);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
                                    ~~~~~~~~~~~~~~~
-!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
+!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.
     }
\ No newline at end of file
diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt
index c152da9696952..ba01672d75a8f 100644
--- a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt
+++ b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt
@@ -1,25 +1,25 @@
 error TS2468: Cannot find global value 'Promise'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
-tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
-tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
-tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
-tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
-tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
 
 
@@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
 !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
       const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
                                                               ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
       const blob = await response.blob();
     
       const size = import.meta.scriptElement.dataset.size || 300;
                    ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                                ~~~~~~~~~~~~~
 !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
     
@@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
 ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ====
     export let x = import.meta;
                    ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     export let y = import.metal;
                    ~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                           ~~~~~
 !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     export let z = import.import.import.malkovich;
                    ~~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                           ~~~~~~
 !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     
 ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ====
     let globalA = import.meta;
                   ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     let globalB = import.metal;
                   ~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                          ~~~~~
 !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     let globalC = import.import.import.malkovich;
                   ~~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                          ~~~~~~
 !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     
 ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ====
     export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
                                    ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                                                ~~~~
 !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
                                                       ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                                                                   ~~~~
 !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
                                                                          ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     import.meta = foo;
     ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     ~~~~~~~~~~~
 !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
     
@@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
     
     const { a, b, c } = import.meta.wellKnownProperty;
                         ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
\ No newline at end of file
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
\ No newline at end of file
diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt
index c152da9696952..ba01672d75a8f 100644
--- a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt
+++ b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt
@@ -1,25 +1,25 @@
 error TS2468: Cannot find global value 'Promise'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
-tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
-tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
-tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
-tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
-tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
-tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
+tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
-tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
 tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
 
 
@@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
 !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
       const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
                                                               ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
       const blob = await response.blob();
     
       const size = import.meta.scriptElement.dataset.size || 300;
                    ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                                ~~~~~~~~~~~~~
 !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
     
@@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
 ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ====
     export let x = import.meta;
                    ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     export let y = import.metal;
                    ~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                           ~~~~~
 !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     export let z = import.import.import.malkovich;
                    ~~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                           ~~~~~~
 !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     
 ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ====
     let globalA = import.meta;
                   ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     let globalB = import.metal;
                   ~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                          ~~~~~
 !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     let globalC = import.import.import.malkovich;
                   ~~~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                          ~~~~~~
 !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
     
 ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ====
     export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
                                    ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                                                ~~~~
 !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
                                                       ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
                                                                   ~~~~
 !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
                                                                          ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     import.meta = foo;
     ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
     ~~~~~~~~~~~
 !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
     
@@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
     
     const { a, b, c } = import.meta.wellKnownProperty;
                         ~~~~~~~~~~~
-!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
\ No newline at end of file
+!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.
\ No newline at end of file
diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt
index 1f078b80a0002..2520eedbc7f64 100644
--- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt
+++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt
@@ -1,13 +1,13 @@
 error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
   Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
-error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+error TS6054: File 'tests/cases/compiler/b.js.map' 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
 
 
 !!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
 !!! error TS5055:   Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
-!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'.
 !!! error TS6054:   The file is in the program because:
 !!! error TS6054:     Root file specified for compilation
 ==== tests/cases/compiler/a.ts (0 errors) ====
diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt
index 1f078b80a0002..2520eedbc7f64 100644
--- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt
+++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt
@@ -1,13 +1,13 @@
 error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
   Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
-error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+error TS6054: File 'tests/cases/compiler/b.js.map' 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
 
 
 !!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
 !!! error TS5055:   Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
-!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'.
 !!! error TS6054:   The file is in the program because:
 !!! error TS6054:     Root file specified for compilation
 ==== tests/cases/compiler/a.ts (0 errors) ====
diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt
index 5b421bbfc8642..321ab08822506 100644
--- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt
+++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt
@@ -1,4 +1,4 @@
-error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
   The file is in the program because:
     Root file specified for compilation
 error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
@@ -6,7 +6,7 @@ error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mea
     Root file specified for compilation
 
 
-!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
 !!! error TS6054:   The file is in the program because:
 !!! error TS6054:     Root file specified for compilation
 !!! error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
diff --git a/tests/baselines/reference/moduleNodeNextImportFix.baseline b/tests/baselines/reference/moduleNodeNextImportFix.baseline
new file mode 100644
index 0000000000000..5f000f3f10fa1
--- /dev/null
+++ b/tests/baselines/reference/moduleNodeNextImportFix.baseline
@@ -0,0 +1,24 @@
+Syntactic Diagnostics for file '/tests/cases/fourslash/moduleNodeNextImportFix.ts':
+
+
+==== /tests/cases/fourslash/src/index.mts (0 errors) ====
+    import { util } from './deps.mts'
+    export function main() {
+        util()
+    }
+==== /tests/cases/fourslash/src/deps.mts (0 errors) ====
+    export function util() {}
+
+Semantic Diagnostics for file '/tests/cases/fourslash/moduleNodeNextImportFix.ts':
+/tests/cases/fourslash/src/index.mts(1,22): error TS2691: An import path cannot end with a '.mts' extension. Consider importing './deps.mjs' instead.
+
+
+==== /tests/cases/fourslash/src/index.mts (1 errors) ====
+    import { util } from './deps.mts'
+                         ~~~~~~~~~~~~
+!!! error TS2691: An import path cannot end with a '.mts' extension. Consider importing './deps.mjs' instead.
+    export function main() {
+        util()
+    }
+==== /tests/cases/fourslash/src/deps.mts (0 errors) ====
+    export function util() {}
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).errors.txt b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).errors.txt
new file mode 100644
index 0000000000000..bdf6aba250c51
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).errors.txt
@@ -0,0 +1,24 @@
+tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ====
+    // esm format file
+    import * as self from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    self;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).js b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).js
new file mode 100644
index 0000000000000..07532294ff7d3
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).js
@@ -0,0 +1,63 @@
+//// [tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts] ////
+
+//// [index.js]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mjs]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cjs]
+// esm format file
+import * as self from "package";
+self;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js"
+}
+
+//// [index.js]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mjs]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const self = __importStar(require("package"));
+self;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).symbols b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).symbols
new file mode 100644
index 0000000000000..eb9fab3a89a50
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.js, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.js, 1, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.mjs, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.mjs, 1, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.cjs, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.cjs, 1, 6))
+
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).types b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).types
new file mode 100644
index 0000000000000..894b0d651035f
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node12).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).errors.txt b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..bdf6aba250c51
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).errors.txt
@@ -0,0 +1,24 @@
+tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ====
+    // esm format file
+    import * as self from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    self;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).js b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).js
new file mode 100644
index 0000000000000..07532294ff7d3
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).js
@@ -0,0 +1,63 @@
+//// [tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts] ////
+
+//// [index.js]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mjs]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cjs]
+// esm format file
+import * as self from "package";
+self;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js"
+}
+
+//// [index.js]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mjs]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const self = __importStar(require("package"));
+self;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).symbols b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).symbols
new file mode 100644
index 0000000000000..eb9fab3a89a50
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.js, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.js, 1, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.mjs, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.mjs, 1, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.cjs, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.cjs, 1, 6))
+
diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).types b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).types
new file mode 100644
index 0000000000000..894b0d651035f
--- /dev/null
+++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
diff --git a/tests/baselines/reference/nodeModules1(module=node12).errors.txt b/tests/baselines/reference/nodeModules1(module=node12).errors.txt
new file mode 100644
index 0000000000000..6398640a86946
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=node12).errors.txt
@@ -0,0 +1,564 @@
+tests/cases/conformance/node/index.cts(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(75,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(76,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(77,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(78,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(79,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(80,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(81,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(82,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(83,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(84,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(85,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.cts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.mts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.cts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.mts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.mts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.cts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/index.mts (27 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should all fail - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/index.cts (27 errors) ====
+    // ESM-format imports below should issue errors
+    import * as m1 from "./index.js";
+                        ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m2 from "./index.mjs";
+                        ~~~~~~~~~~~~~
+!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m11 from "./subfolder2/another/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m15 from "./subfolder";
+    import * as m16 from "./subfolder/";
+    import * as m17 from "./subfolder/index";
+    import * as m18 from "./subfolder2";
+    import * as m19 from "./subfolder2/";
+    import * as m20 from "./subfolder2/index";
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/index.ts (27 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ====
+    {
+    }
+==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ====
+    {
+        "type": "module"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModules1(module=node12).js b/tests/baselines/reference/nodeModules1(module=node12).js
new file mode 100644
index 0000000000000..46163abc085d0
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=node12).js
@@ -0,0 +1,696 @@
+//// [tests/cases/conformance/node/nodeModules1.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.ts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.ts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.mts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.cts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mts]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+//// [index.cts]
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+//// [index.ts]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [package.json]
+{
+}
+//// [package.json]
+{
+    "type": "module"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+// esm format file
+const x = 1;
+export { x };
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// ESM-format imports below should issue errors
+const m1 = __importStar(require("./index.js"));
+const m2 = __importStar(require("./index.mjs"));
+const m3 = __importStar(require("./index.cjs"));
+const m4 = __importStar(require("./subfolder/index.js"));
+const m5 = __importStar(require("./subfolder/index.mjs"));
+const m6 = __importStar(require("./subfolder/index.cjs"));
+const m7 = __importStar(require("./subfolder2/index.js"));
+const m8 = __importStar(require("./subfolder2/index.mjs"));
+const m9 = __importStar(require("./subfolder2/index.cjs"));
+const m10 = __importStar(require("./subfolder2/another/index.js"));
+const m11 = __importStar(require("./subfolder2/another/index.mjs"));
+const m12 = __importStar(require("./subfolder2/another/index.cjs"));
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+const m13 = __importStar(require("./"));
+const m14 = __importStar(require("./index"));
+const m15 = __importStar(require("./subfolder"));
+const m16 = __importStar(require("./subfolder/"));
+const m17 = __importStar(require("./subfolder/index"));
+const m18 = __importStar(require("./subfolder2"));
+const m19 = __importStar(require("./subfolder2/"));
+const m20 = __importStar(require("./subfolder2/index"));
+const m21 = __importStar(require("./subfolder2/another"));
+const m22 = __importStar(require("./subfolder2/another/"));
+const m23 = __importStar(require("./subfolder2/another/index"));
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = require("./");
+const m25 = require("./index");
+const m26 = require("./subfolder");
+const m27 = require("./subfolder/");
+const m28 = require("./subfolder/index");
+const m29 = require("./subfolder2");
+const m30 = require("./subfolder2/");
+const m31 = require("./subfolder2/index");
+const m32 = require("./subfolder2/another");
+const m33 = require("./subfolder2/another/");
+const m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+//// [index.mjs]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+
+
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
diff --git a/tests/baselines/reference/nodeModules1(module=node12).symbols b/tests/baselines/reference/nodeModules1(module=node12).symbols
new file mode 100644
index 0000000000000..287b1e895d1a1
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=node12).symbols
@@ -0,0 +1,817 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/index.mts ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.mts, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.mts, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.mts, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.mts, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.mts, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.mts, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.mts, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.mts, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.mts, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.mts, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.mts, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.mts, 11, 6))
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.mts, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.mts, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.mts, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.mts, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.mts, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.mts, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.mts, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.mts, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.mts, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.mts, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.mts, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.mts, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.mts, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.mts, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.mts, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.mts, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.mts, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.mts, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.mts, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.mts, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.mts, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.mts, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.mts, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.mts, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.mts, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.mts, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.mts, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.mts, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.mts, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.mts, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.mts, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.mts, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.mts, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.mts, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.mts, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.mts, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.mts, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.mts, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.mts, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.mts, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.mts, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.mts, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.mts, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.mts, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.mts, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.mts, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.mts, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.mts, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.mts, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.mts, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.mts, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.mts, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.mts, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.mts, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.mts, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.mts, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.mts, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.mts, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.mts, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.mts, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.mts, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.mts, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.mts, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.mts, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.mts, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.mts, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.mts, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 86, 5))
+
+export {x};
+>x : Symbol(m2.x, Decl(index.mts, 87, 8))
+
+=== tests/cases/conformance/node/index.cts ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.cts, 1, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.cts, 2, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.cts, 3, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.cts, 4, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.cts, 5, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.cts, 6, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.cts, 7, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.cts, 8, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.cts, 9, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.cts, 10, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.cts, 11, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.cts, 12, 6))
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.cts, 14, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.cts, 15, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.cts, 16, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.cts, 17, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.cts, 18, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.cts, 19, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.cts, 20, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.cts, 21, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.cts, 22, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.cts, 23, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.cts, 24, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.cts, 1, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.cts, 2, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.cts, 3, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.cts, 4, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.cts, 5, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.cts, 6, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.cts, 7, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.cts, 8, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.cts, 9, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.cts, 10, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.cts, 11, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.cts, 12, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.cts, 14, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.cts, 15, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.cts, 16, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.cts, 17, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.cts, 18, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.cts, 19, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.cts, 20, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.cts, 21, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.cts, 22, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.cts, 23, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.cts, 24, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.cts, 47, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.cts, 50, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.cts, 51, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.cts, 52, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.cts, 53, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.cts, 54, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.cts, 55, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.cts, 56, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.cts, 57, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.cts, 58, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.cts, 59, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.cts, 47, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.cts, 50, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.cts, 51, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.cts, 52, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.cts, 53, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.cts, 54, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.cts, 55, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.cts, 56, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.cts, 57, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.cts, 58, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.cts, 59, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.cts, 74, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.cts, 75, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.cts, 76, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.cts, 77, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.cts, 78, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.cts, 79, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.cts, 80, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.cts, 81, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.cts, 82, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.cts, 83, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.cts, 84, 5))
+
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 86, 5))
+
+export {x};
+>x : Symbol(m3.x, Decl(index.cts, 87, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.ts, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.ts, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.ts, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.ts, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.ts, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.ts, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.ts, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.ts, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.ts, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.ts, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.ts, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.ts, 11, 6))
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.ts, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.ts, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.ts, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.ts, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.ts, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.ts, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.ts, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.ts, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.ts, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.ts, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.ts, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.ts, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.ts, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.ts, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.ts, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.ts, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.ts, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.ts, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.ts, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.ts, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.ts, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.ts, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.ts, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.ts, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.ts, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.ts, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.ts, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.ts, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.ts, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.ts, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.ts, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.ts, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.ts, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.ts, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.ts, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.ts, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.ts, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.ts, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.ts, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.ts, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.ts, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.ts, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.ts, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.ts, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.ts, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.ts, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.ts, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.ts, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.ts, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.ts, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.ts, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.ts, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.ts, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.ts, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.ts, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.ts, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.ts, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.ts, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.ts, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.ts, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.ts, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.ts, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.ts, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.ts, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.ts, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.ts, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.ts, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 85, 5))
+
+export {x};
+>x : Symbol(m1.x, Decl(index.ts, 86, 8))
+
diff --git a/tests/baselines/reference/nodeModules1(module=node12).types b/tests/baselines/reference/nodeModules1(module=node12).types
new file mode 100644
index 0000000000000..3a7a0c0b9b6a3
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=node12).types
@@ -0,0 +1,997 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/index.mts ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/index.cts ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : typeof m1
+
+import * as m14 from "./index";
+>m14 : typeof m1
+
+import * as m15 from "./subfolder";
+>m15 : typeof m4
+
+import * as m16 from "./subfolder/";
+>m16 : typeof m4
+
+import * as m17 from "./subfolder/index";
+>m17 : typeof m4
+
+import * as m18 from "./subfolder2";
+>m18 : typeof m7
+
+import * as m19 from "./subfolder2/";
+>m19 : typeof m7
+
+import * as m20 from "./subfolder2/index";
+>m20 : typeof m7
+
+import * as m21 from "./subfolder2/another";
+>m21 : typeof m10
+
+import * as m22 from "./subfolder2/another/";
+>m22 : typeof m10
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : typeof m10
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : typeof m1
+
+void m14;
+>void m14 : undefined
+>m14 : typeof m1
+
+void m15;
+>void m15 : undefined
+>m15 : typeof m4
+
+void m16;
+>void m16 : undefined
+>m16 : typeof m4
+
+void m17;
+>void m17 : undefined
+>m17 : typeof m4
+
+void m18;
+>void m18 : undefined
+>m18 : typeof m7
+
+void m19;
+>void m19 : undefined
+>m19 : typeof m7
+
+void m20;
+>void m20 : undefined
+>m20 : typeof m7
+
+void m21;
+>void m21 : undefined
+>m21 : typeof m10
+
+void m22;
+>void m22 : undefined
+>m22 : typeof m10
+
+void m23;
+>void m23 : undefined
+>m23 : typeof m10
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/index.ts ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..6398640a86946
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt
@@ -0,0 +1,564 @@
+tests/cases/conformance/node/index.cts(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(75,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(76,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(77,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(78,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(79,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(80,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(81,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(82,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(83,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(84,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(85,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.mts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.ts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.cts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.mts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.cts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.mts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.mts (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.cts (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/index.mts (27 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should all fail - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/index.cts (27 errors) ====
+    // ESM-format imports below should issue errors
+    import * as m1 from "./index.js";
+                        ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m2 from "./index.mjs";
+                        ~~~~~~~~~~~~~
+!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m11 from "./subfolder2/another/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m15 from "./subfolder";
+    import * as m16 from "./subfolder/";
+    import * as m17 from "./subfolder/index";
+    import * as m18 from "./subfolder2";
+    import * as m19 from "./subfolder2/";
+    import * as m20 from "./subfolder2/index";
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/index.ts (27 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ====
+    {
+    }
+==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ====
+    {
+        "type": "module"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).js b/tests/baselines/reference/nodeModules1(module=nodenext).js
new file mode 100644
index 0000000000000..46163abc085d0
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=nodenext).js
@@ -0,0 +1,696 @@
+//// [tests/cases/conformance/node/nodeModules1.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.ts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.ts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.mts]
+// esm format file
+const x = 1;
+export {x};
+//// [index.cts]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mts]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+//// [index.cts]
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+//// [index.ts]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [package.json]
+{
+}
+//// [package.json]
+{
+    "type": "module"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+// esm format file
+const x = 1;
+export { x };
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// ESM-format imports below should issue errors
+const m1 = __importStar(require("./index.js"));
+const m2 = __importStar(require("./index.mjs"));
+const m3 = __importStar(require("./index.cjs"));
+const m4 = __importStar(require("./subfolder/index.js"));
+const m5 = __importStar(require("./subfolder/index.mjs"));
+const m6 = __importStar(require("./subfolder/index.cjs"));
+const m7 = __importStar(require("./subfolder2/index.js"));
+const m8 = __importStar(require("./subfolder2/index.mjs"));
+const m9 = __importStar(require("./subfolder2/index.cjs"));
+const m10 = __importStar(require("./subfolder2/another/index.js"));
+const m11 = __importStar(require("./subfolder2/another/index.mjs"));
+const m12 = __importStar(require("./subfolder2/another/index.cjs"));
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+const m13 = __importStar(require("./"));
+const m14 = __importStar(require("./index"));
+const m15 = __importStar(require("./subfolder"));
+const m16 = __importStar(require("./subfolder/"));
+const m17 = __importStar(require("./subfolder/index"));
+const m18 = __importStar(require("./subfolder2"));
+const m19 = __importStar(require("./subfolder2/"));
+const m20 = __importStar(require("./subfolder2/index"));
+const m21 = __importStar(require("./subfolder2/another"));
+const m22 = __importStar(require("./subfolder2/another/"));
+const m23 = __importStar(require("./subfolder2/another/index"));
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = require("./");
+const m25 = require("./index");
+const m26 = require("./subfolder");
+const m27 = require("./subfolder/");
+const m28 = require("./subfolder/index");
+const m29 = require("./subfolder2");
+const m30 = require("./subfolder2/");
+const m31 = require("./subfolder2/index");
+const m32 = require("./subfolder2/another");
+const m33 = require("./subfolder2/another/");
+const m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+//// [index.mjs]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+
+
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).symbols b/tests/baselines/reference/nodeModules1(module=nodenext).symbols
new file mode 100644
index 0000000000000..287b1e895d1a1
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=nodenext).symbols
@@ -0,0 +1,817 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/index.mts ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.mts, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.mts, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.mts, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.mts, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.mts, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.mts, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.mts, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.mts, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.mts, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.mts, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.mts, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.mts, 11, 6))
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.mts, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.mts, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.mts, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.mts, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.mts, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.mts, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.mts, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.mts, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.mts, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.mts, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.mts, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.mts, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.mts, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.mts, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.mts, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.mts, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.mts, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.mts, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.mts, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.mts, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.mts, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.mts, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.mts, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.mts, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.mts, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.mts, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.mts, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.mts, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.mts, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.mts, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.mts, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.mts, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.mts, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.mts, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.mts, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.mts, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.mts, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.mts, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.mts, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.mts, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.mts, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.mts, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.mts, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.mts, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.mts, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.mts, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.mts, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.mts, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.mts, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.mts, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.mts, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.mts, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.mts, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.mts, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.mts, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.mts, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.mts, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.mts, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.mts, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.mts, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.mts, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.mts, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.mts, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.mts, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.mts, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.mts, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.mts, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mts, 86, 5))
+
+export {x};
+>x : Symbol(m2.x, Decl(index.mts, 87, 8))
+
+=== tests/cases/conformance/node/index.cts ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.cts, 1, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.cts, 2, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.cts, 3, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.cts, 4, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.cts, 5, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.cts, 6, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.cts, 7, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.cts, 8, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.cts, 9, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.cts, 10, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.cts, 11, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.cts, 12, 6))
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.cts, 14, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.cts, 15, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.cts, 16, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.cts, 17, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.cts, 18, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.cts, 19, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.cts, 20, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.cts, 21, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.cts, 22, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.cts, 23, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.cts, 24, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.cts, 1, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.cts, 2, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.cts, 3, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.cts, 4, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.cts, 5, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.cts, 6, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.cts, 7, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.cts, 8, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.cts, 9, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.cts, 10, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.cts, 11, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.cts, 12, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.cts, 14, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.cts, 15, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.cts, 16, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.cts, 17, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.cts, 18, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.cts, 19, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.cts, 20, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.cts, 21, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.cts, 22, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.cts, 23, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.cts, 24, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.cts, 47, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.cts, 50, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.cts, 51, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.cts, 52, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.cts, 53, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.cts, 54, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.cts, 55, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.cts, 56, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.cts, 57, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.cts, 58, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.cts, 59, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.cts, 47, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.cts, 50, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.cts, 51, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.cts, 52, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.cts, 53, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.cts, 54, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.cts, 55, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.cts, 56, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.cts, 57, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.cts, 58, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.cts, 59, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.cts, 74, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.cts, 75, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.cts, 76, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.cts, 77, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.cts, 78, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.cts, 79, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.cts, 80, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.cts, 81, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.cts, 82, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.cts, 83, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.cts, 84, 5))
+
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cts, 86, 5))
+
+export {x};
+>x : Symbol(m3.x, Decl(index.cts, 87, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.ts, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.ts, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.ts, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.ts, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.ts, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.ts, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.ts, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.ts, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.ts, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.ts, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.ts, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.ts, 11, 6))
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.ts, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.ts, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.ts, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.ts, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.ts, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.ts, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.ts, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.ts, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.ts, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.ts, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.ts, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.ts, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.ts, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.ts, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.ts, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.ts, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.ts, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.ts, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.ts, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.ts, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.ts, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.ts, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.ts, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.ts, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.ts, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.ts, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.ts, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.ts, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.ts, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.ts, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.ts, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.ts, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.ts, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.ts, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.ts, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.ts, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.ts, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.ts, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.ts, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.ts, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.ts, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.ts, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.ts, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.ts, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.ts, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.ts, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.ts, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.ts, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.ts, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.ts, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.ts, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.ts, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.ts, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.ts, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.ts, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.ts, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.ts, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.ts, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.ts, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.ts, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.ts, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.ts, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.ts, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.ts, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.ts, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.ts, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.ts, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.ts, 85, 5))
+
+export {x};
+>x : Symbol(m1.x, Decl(index.ts, 86, 8))
+
diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).types b/tests/baselines/reference/nodeModules1(module=nodenext).types
new file mode 100644
index 0000000000000..3a7a0c0b9b6a3
--- /dev/null
+++ b/tests/baselines/reference/nodeModules1(module=nodenext).types
@@ -0,0 +1,997 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/index.mts ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/index.cts ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : typeof m1
+
+import * as m14 from "./index";
+>m14 : typeof m1
+
+import * as m15 from "./subfolder";
+>m15 : typeof m4
+
+import * as m16 from "./subfolder/";
+>m16 : typeof m4
+
+import * as m17 from "./subfolder/index";
+>m17 : typeof m4
+
+import * as m18 from "./subfolder2";
+>m18 : typeof m7
+
+import * as m19 from "./subfolder2/";
+>m19 : typeof m7
+
+import * as m20 from "./subfolder2/index";
+>m20 : typeof m7
+
+import * as m21 from "./subfolder2/another";
+>m21 : typeof m10
+
+import * as m22 from "./subfolder2/another/";
+>m22 : typeof m10
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : typeof m10
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : typeof m1
+
+void m14;
+>void m14 : undefined
+>m14 : typeof m1
+
+void m15;
+>void m15 : undefined
+>m15 : typeof m4
+
+void m16;
+>void m16 : undefined
+>m16 : typeof m4
+
+void m17;
+>void m17 : undefined
+>m17 : typeof m4
+
+void m18;
+>void m18 : undefined
+>m18 : typeof m7
+
+void m19;
+>void m19 : undefined
+>m19 : typeof m7
+
+void m20;
+>void m20 : undefined
+>m20 : typeof m7
+
+void m21;
+>void m21 : undefined
+>m21 : typeof m10
+
+void m22;
+>void m22 : undefined
+>m22 : typeof m10
+
+void m23;
+>void m23 : undefined
+>m23 : typeof m10
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/index.ts ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt
new file mode 100644
index 0000000000000..ff46be3295d17
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt
@@ -0,0 +1,597 @@
+tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(77,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(78,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(79,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(80,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(81,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(82,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(83,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(84,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(85,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder/index.cjs (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder/index.mjs (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/index.js (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/index.cjs (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/index.mjs (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/another/index.js (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.js (38 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m27 = require("./subfolder/");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m28 = require("./subfolder/index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m29 = require("./subfolder2");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m30 = require("./subfolder2/");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m31 = require("./subfolder2/index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m32 = require("./subfolder2/another");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.cjs (27 errors) ====
+    // ESM-format imports below should issue errors
+    import * as m1 from "./index.js";
+                        ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m2 from "./index.mjs";
+                        ~~~~~~~~~~~~~
+!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m11 from "./subfolder2/another/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m15 from "./subfolder";
+    import * as m16 from "./subfolder/";
+    import * as m17 from "./subfolder/index";
+    import * as m18 from "./subfolder2";
+    import * as m19 from "./subfolder2/";
+    import * as m20 from "./subfolder2/index";
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.mjs (27 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should all fail - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder2/package.json (0 errors) ====
+    {
+    }
+==== tests/cases/conformance/node/allowJs/subfolder2/another/package.json (0 errors) ====
+    {
+        "type": "module"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js
new file mode 100644
index 0000000000000..ec1664707e795
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js
@@ -0,0 +1,692 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts] ////
+
+//// [index.js]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+// esm format file
+const x = 1;
+export {x};
+//// [index.js]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+// esm format file
+const x = 1;
+export {x};
+//// [index.js]
+// esm format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+// esm format file
+const x = 1;
+export {x};
+//// [index.js]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [package.json]
+{
+}
+//// [package.json]
+{
+    "type": "module"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+// esm format file
+const x = 1;
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// ESM-format imports below should issue errors
+const m1 = __importStar(require("./index.js"));
+const m2 = __importStar(require("./index.mjs"));
+const m3 = __importStar(require("./index.cjs"));
+const m4 = __importStar(require("./subfolder/index.js"));
+const m5 = __importStar(require("./subfolder/index.mjs"));
+const m6 = __importStar(require("./subfolder/index.cjs"));
+const m7 = __importStar(require("./subfolder2/index.js"));
+const m8 = __importStar(require("./subfolder2/index.mjs"));
+const m9 = __importStar(require("./subfolder2/index.cjs"));
+const m10 = __importStar(require("./subfolder2/another/index.js"));
+const m11 = __importStar(require("./subfolder2/another/index.mjs"));
+const m12 = __importStar(require("./subfolder2/another/index.cjs"));
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+const m13 = __importStar(require("./"));
+const m14 = __importStar(require("./index"));
+const m15 = __importStar(require("./subfolder"));
+const m16 = __importStar(require("./subfolder/"));
+const m17 = __importStar(require("./subfolder/index"));
+const m18 = __importStar(require("./subfolder2"));
+const m19 = __importStar(require("./subfolder2/"));
+const m20 = __importStar(require("./subfolder2/index"));
+const m21 = __importStar(require("./subfolder2/another"));
+const m22 = __importStar(require("./subfolder2/another/"));
+const m23 = __importStar(require("./subfolder2/another/index"));
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = require("./");
+const m25 = require("./index");
+const m26 = require("./subfolder");
+const m27 = require("./subfolder/");
+const m28 = require("./subfolder/index");
+const m29 = require("./subfolder2");
+const m30 = require("./subfolder2/");
+const m31 = require("./subfolder2/index");
+const m32 = require("./subfolder2/another");
+const m33 = require("./subfolder2/another/");
+const m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+
+
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+export const x: 1;
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols
new file mode 100644
index 0000000000000..d874ab0c830dd
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols
@@ -0,0 +1,817 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.cjs ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.mjs ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.js ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.js, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.js, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.js, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.js, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.js, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.js, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.js, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.js, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.js, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.js, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.js, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.js, 11, 6))
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.js, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.js, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.js, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.js, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.js, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.js, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.js, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.js, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.js, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.js, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.js, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.js, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.js, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.js, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.js, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.js, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.js, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.js, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.js, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.js, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.js, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.js, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.js, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.js, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.js, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.js, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.js, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.js, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.js, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.js, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.js, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.js, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.js, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.js, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.js, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.js, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.js, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.js, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.js, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.js, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.js, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.js, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.js, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.js, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.js, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.js, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.js, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.js, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.js, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.js, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.js, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.js, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.js, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.js, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.js, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.js, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.js, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.js, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.js, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.js, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.js, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.js, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.js, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.js, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.js, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.js, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.js, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 85, 5))
+
+export {x};
+>x : Symbol(m1.x, Decl(index.js, 86, 8))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.cjs, 1, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.cjs, 2, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.cjs, 3, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.cjs, 4, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.cjs, 5, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.cjs, 6, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.cjs, 7, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.cjs, 8, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.cjs, 9, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.cjs, 10, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.cjs, 11, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.cjs, 12, 6))
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.cjs, 14, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.cjs, 15, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.cjs, 16, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.cjs, 17, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.cjs, 18, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.cjs, 19, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.cjs, 20, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.cjs, 21, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.cjs, 22, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.cjs, 23, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.cjs, 24, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.cjs, 1, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.cjs, 2, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.cjs, 3, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.cjs, 4, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.cjs, 5, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.cjs, 6, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.cjs, 7, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.cjs, 8, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.cjs, 9, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.cjs, 10, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.cjs, 11, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.cjs, 12, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.cjs, 14, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.cjs, 15, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.cjs, 16, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.cjs, 17, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.cjs, 18, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.cjs, 19, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.cjs, 20, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.cjs, 21, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.cjs, 22, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.cjs, 23, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.cjs, 24, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.cjs, 47, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.cjs, 50, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.cjs, 51, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.cjs, 52, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.cjs, 53, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.cjs, 54, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.cjs, 55, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.cjs, 56, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.cjs, 57, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.cjs, 58, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.cjs, 59, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.cjs, 47, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.cjs, 50, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.cjs, 51, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.cjs, 52, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.cjs, 53, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.cjs, 54, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.cjs, 55, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.cjs, 56, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.cjs, 57, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.cjs, 58, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.cjs, 59, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.cjs, 74, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.cjs, 75, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.cjs, 76, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.cjs, 77, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.cjs, 78, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.cjs, 79, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.cjs, 80, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.cjs, 81, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.cjs, 82, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.cjs, 83, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.cjs, 84, 5))
+
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 86, 5))
+
+export {x};
+>x : Symbol(m3.x, Decl(index.cjs, 87, 8))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.mjs, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.mjs, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.mjs, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.mjs, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.mjs, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.mjs, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.mjs, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.mjs, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.mjs, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.mjs, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.mjs, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.mjs, 11, 6))
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.mjs, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.mjs, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.mjs, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.mjs, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.mjs, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.mjs, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.mjs, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.mjs, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.mjs, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.mjs, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.mjs, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.mjs, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.mjs, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.mjs, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.mjs, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.mjs, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.mjs, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.mjs, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.mjs, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.mjs, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.mjs, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.mjs, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.mjs, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.mjs, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.mjs, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.mjs, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.mjs, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.mjs, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.mjs, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.mjs, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.mjs, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.mjs, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.mjs, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.mjs, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.mjs, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.mjs, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.mjs, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.mjs, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.mjs, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.mjs, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.mjs, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.mjs, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.mjs, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.mjs, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.mjs, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.mjs, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.mjs, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.mjs, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.mjs, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.mjs, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.mjs, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.mjs, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.mjs, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.mjs, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.mjs, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.mjs, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.mjs, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.mjs, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.mjs, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.mjs, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.mjs, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.mjs, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.mjs, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.mjs, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.mjs, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.mjs, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.mjs, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 86, 5))
+
+export {x};
+>x : Symbol(m2.x, Decl(index.mjs, 87, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types
new file mode 100644
index 0000000000000..148c55c036dde
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types
@@ -0,0 +1,997 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.cjs ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.mjs ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.js ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : typeof m1
+
+import * as m14 from "./index";
+>m14 : typeof m1
+
+import * as m15 from "./subfolder";
+>m15 : typeof m4
+
+import * as m16 from "./subfolder/";
+>m16 : typeof m4
+
+import * as m17 from "./subfolder/index";
+>m17 : typeof m4
+
+import * as m18 from "./subfolder2";
+>m18 : typeof m7
+
+import * as m19 from "./subfolder2/";
+>m19 : typeof m7
+
+import * as m20 from "./subfolder2/index";
+>m20 : typeof m7
+
+import * as m21 from "./subfolder2/another";
+>m21 : typeof m10
+
+import * as m22 from "./subfolder2/another/";
+>m22 : typeof m10
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : typeof m10
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : typeof m1
+
+void m14;
+>void m14 : undefined
+>m14 : typeof m1
+
+void m15;
+>void m15 : undefined
+>m15 : typeof m4
+
+void m16;
+>void m16 : undefined
+>m16 : typeof m4
+
+void m17;
+>void m17 : undefined
+>m17 : typeof m4
+
+void m18;
+>void m18 : undefined
+>m18 : typeof m7
+
+void m19;
+>void m19 : undefined
+>m19 : typeof m7
+
+void m20;
+>void m20 : undefined
+>m20 : typeof m7
+
+void m21;
+>void m21 : undefined
+>m21 : typeof m10
+
+void m22;
+>void m22 : undefined
+>m22 : typeof m10
+
+void m23;
+>void m23 : undefined
+>m23 : typeof m10
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..ff46be3295d17
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt
@@ -0,0 +1,597 @@
+tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(77,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(78,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(79,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(80,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(81,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(82,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(83,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(84,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(85,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(14,22): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(15,22): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(16,22): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(17,22): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(18,22): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(19,22): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(20,22): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(21,22): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(76,21): error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(77,21): error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(78,21): error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(79,21): error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(80,21): error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(81,21): error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(82,21): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(83,21): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder/index.cjs (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder/index.mjs (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/index.js (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/index.cjs (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/index.mjs (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/another/index.js (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs (0 errors) ====
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs (0 errors) ====
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.js (38 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m27 = require("./subfolder/");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m28 = require("./subfolder/index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m29 = require("./subfolder2");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m30 = require("./subfolder2/");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m31 = require("./subfolder2/index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    import m32 = require("./subfolder2/another");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.cjs (27 errors) ====
+    // ESM-format imports below should issue errors
+    import * as m1 from "./index.js";
+                        ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m2 from "./index.mjs";
+                        ~~~~~~~~~~~~~
+!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+                        ~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m11 from "./subfolder2/another/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m15 from "./subfolder";
+    import * as m16 from "./subfolder/";
+    import * as m17 from "./subfolder/index";
+    import * as m18 from "./subfolder2";
+    import * as m19 from "./subfolder2/";
+    import * as m20 from "./subfolder2/index";
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    // cjs format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.mjs (27 errors) ====
+    import * as m1 from "./index.js";
+    import * as m2 from "./index.mjs";
+    import * as m3 from "./index.cjs";
+    import * as m4 from "./subfolder/index.js";
+    import * as m5 from "./subfolder/index.mjs";
+    import * as m6 from "./subfolder/index.cjs";
+    import * as m7 from "./subfolder2/index.js";
+    import * as m8 from "./subfolder2/index.mjs";
+    import * as m9 from "./subfolder2/index.cjs";
+    import * as m10 from "./subfolder2/another/index.js";
+    import * as m11 from "./subfolder2/another/index.mjs";
+    import * as m12 from "./subfolder2/another/index.cjs";
+    // The next ones should all fail - esm format files have no index resolution or extension resolution
+    import * as m13 from "./";
+                         ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    import * as m14 from "./index";
+                         ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    import * as m15 from "./subfolder";
+                         ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    import * as m16 from "./subfolder/";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    import * as m17 from "./subfolder/index";
+                         ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    import * as m18 from "./subfolder2";
+                         ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    import * as m19 from "./subfolder2/";
+                         ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    import * as m20 from "./subfolder2/index";
+                         ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    import * as m21 from "./subfolder2/another";
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    import * as m22 from "./subfolder2/another/";
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    import * as m23 from "./subfolder2/another/index";
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    void m1;
+    void m2;
+    void m3;
+    void m4;
+    void m5;
+    void m6;
+    void m7;
+    void m8;
+    void m9;
+    void m10;
+    void m11;
+    void m12;
+    void m13;
+    void m14;
+    void m15;
+    void m16;
+    void m17;
+    void m18;
+    void m19;
+    void m20;
+    void m21;
+    void m22;
+    void m23;
+    
+    // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+    import m24 = require("./");
+                         ~~~~
+!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m25 = require("./index");
+                         ~~~~~~~~~
+!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m26 = require("./subfolder");
+    import m27 = require("./subfolder/");
+    import m28 = require("./subfolder/index");
+    import m29 = require("./subfolder2");
+    import m30 = require("./subfolder2/");
+    import m31 = require("./subfolder2/index");
+    import m32 = require("./subfolder2/another");
+                         ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m33 = require("./subfolder2/another/");
+                         ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import m34 = require("./subfolder2/another/index");
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    void m24;
+    void m25;
+    void m26;
+    void m27;
+    void m28;
+    void m29;
+    void m30;
+    void m31;
+    void m32;
+    void m33;
+    void m34;
+    
+    // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+    const _m35 = import("./");
+                        ~~~~
+!!! error TS2307: Cannot find module './' or its corresponding type declarations.
+    const _m36 = import("./index");
+                        ~~~~~~~~~
+!!! error TS2307: Cannot find module './index' or its corresponding type declarations.
+    const _m37 = import("./subfolder");
+                        ~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder' or its corresponding type declarations.
+    const _m38 = import("./subfolder/");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/' or its corresponding type declarations.
+    const _m39 = import("./subfolder/index");
+                        ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder/index' or its corresponding type declarations.
+    const _m40 = import("./subfolder2");
+                        ~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2' or its corresponding type declarations.
+    const _m41 = import("./subfolder2/");
+                        ~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/' or its corresponding type declarations.
+    const _m42 = import("./subfolder2/index");
+                        ~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/index' or its corresponding type declarations.
+    const _m43 = import("./subfolder2/another");
+                        ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
+    const _m44 = import("./subfolder2/another/");
+                        ~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
+    const _m45 = import("./subfolder2/another/index");
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
+    
+    // esm format file
+    const x = 1;
+    export {x};
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder2/package.json (0 errors) ====
+    {
+    }
+==== tests/cases/conformance/node/allowJs/subfolder2/another/package.json (0 errors) ====
+    {
+        "type": "module"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js
new file mode 100644
index 0000000000000..ec1664707e795
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js
@@ -0,0 +1,692 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts] ////
+
+//// [index.js]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+// esm format file
+const x = 1;
+export {x};
+//// [index.js]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+// esm format file
+const x = 1;
+export {x};
+//// [index.js]
+// esm format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+// esm format file
+const x = 1;
+export {x};
+//// [index.js]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+//// [index.cjs]
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+//// [index.mjs]
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [package.json]
+{
+}
+//// [package.json]
+{
+    "type": "module"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+// esm format file
+const x = 1;
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = 1;
+export { x };
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// ESM-format imports below should issue errors
+const m1 = __importStar(require("./index.js"));
+const m2 = __importStar(require("./index.mjs"));
+const m3 = __importStar(require("./index.cjs"));
+const m4 = __importStar(require("./subfolder/index.js"));
+const m5 = __importStar(require("./subfolder/index.mjs"));
+const m6 = __importStar(require("./subfolder/index.cjs"));
+const m7 = __importStar(require("./subfolder2/index.js"));
+const m8 = __importStar(require("./subfolder2/index.mjs"));
+const m9 = __importStar(require("./subfolder2/index.cjs"));
+const m10 = __importStar(require("./subfolder2/another/index.js"));
+const m11 = __importStar(require("./subfolder2/another/index.mjs"));
+const m12 = __importStar(require("./subfolder2/another/index.cjs"));
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+const m13 = __importStar(require("./"));
+const m14 = __importStar(require("./index"));
+const m15 = __importStar(require("./subfolder"));
+const m16 = __importStar(require("./subfolder/"));
+const m17 = __importStar(require("./subfolder/index"));
+const m18 = __importStar(require("./subfolder2"));
+const m19 = __importStar(require("./subfolder2/"));
+const m20 = __importStar(require("./subfolder2/index"));
+const m21 = __importStar(require("./subfolder2/another"));
+const m22 = __importStar(require("./subfolder2/another/"));
+const m23 = __importStar(require("./subfolder2/another/index"));
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = require("./");
+const m25 = require("./index");
+const m26 = require("./subfolder");
+const m27 = require("./subfolder/");
+const m28 = require("./subfolder/index");
+const m29 = require("./subfolder2");
+const m30 = require("./subfolder2/");
+const m31 = require("./subfolder2/index");
+const m32 = require("./subfolder2/another");
+const m33 = require("./subfolder2/another/");
+const m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+exports.x = x;
+//// [index.mjs]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+const m24 = __require("./");
+const m25 = __require("./index");
+const m26 = __require("./subfolder");
+const m27 = __require("./subfolder/");
+const m28 = __require("./subfolder/index");
+const m29 = __require("./subfolder2");
+const m30 = __require("./subfolder2/");
+const m31 = __require("./subfolder2/index");
+const m32 = __require("./subfolder2/another");
+const m33 = __require("./subfolder2/another/");
+const m34 = __require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export { x };
+
+
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.cts]
+declare const x = 1;
+export { x };
+//// [index.d.mts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+export const x: 1;
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols
new file mode 100644
index 0000000000000..d874ab0c830dd
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols
@@ -0,0 +1,817 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.cjs ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.mjs ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.js ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs ===
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.cjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs ===
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.mjs, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.js, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.js, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.js, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.js, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.js, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.js, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.js, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.js, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.js, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.js, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.js, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.js, 11, 6))
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.js, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.js, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.js, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.js, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.js, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.js, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.js, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.js, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.js, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.js, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.js, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.js, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.js, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.js, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.js, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.js, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.js, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.js, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.js, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.js, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.js, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.js, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.js, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.js, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.js, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.js, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.js, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.js, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.js, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.js, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.js, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.js, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.js, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.js, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.js, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.js, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.js, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.js, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.js, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.js, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.js, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.js, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.js, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.js, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.js, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.js, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.js, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.js, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.js, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.js, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.js, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.js, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.js, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.js, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.js, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.js, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.js, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.js, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.js, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.js, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.js, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.js, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.js, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.js, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.js, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.js, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.js, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.js, 85, 5))
+
+export {x};
+>x : Symbol(m1.x, Decl(index.js, 86, 8))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.cjs, 1, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.cjs, 2, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.cjs, 3, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.cjs, 4, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.cjs, 5, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.cjs, 6, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.cjs, 7, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.cjs, 8, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.cjs, 9, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.cjs, 10, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.cjs, 11, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.cjs, 12, 6))
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.cjs, 14, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.cjs, 15, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.cjs, 16, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.cjs, 17, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.cjs, 18, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.cjs, 19, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.cjs, 20, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.cjs, 21, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.cjs, 22, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.cjs, 23, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.cjs, 24, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.cjs, 1, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.cjs, 2, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.cjs, 3, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.cjs, 4, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.cjs, 5, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.cjs, 6, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.cjs, 7, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.cjs, 8, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.cjs, 9, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.cjs, 10, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.cjs, 11, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.cjs, 12, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.cjs, 14, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.cjs, 15, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.cjs, 16, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.cjs, 17, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.cjs, 18, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.cjs, 19, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.cjs, 20, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.cjs, 21, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.cjs, 22, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.cjs, 23, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.cjs, 24, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.cjs, 47, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.cjs, 50, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.cjs, 51, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.cjs, 52, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.cjs, 53, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.cjs, 54, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.cjs, 55, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.cjs, 56, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.cjs, 57, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.cjs, 58, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.cjs, 59, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.cjs, 47, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.cjs, 50, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.cjs, 51, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.cjs, 52, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.cjs, 53, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.cjs, 54, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.cjs, 55, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.cjs, 56, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.cjs, 57, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.cjs, 58, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.cjs, 59, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.cjs, 74, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.cjs, 75, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.cjs, 76, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.cjs, 77, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.cjs, 78, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.cjs, 79, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.cjs, 80, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.cjs, 81, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.cjs, 82, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.cjs, 83, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.cjs, 84, 5))
+
+// cjs format file
+const x = 1;
+>x : Symbol(x, Decl(index.cjs, 86, 5))
+
+export {x};
+>x : Symbol(m3.x, Decl(index.cjs, 87, 8))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+import * as m1 from "./index.js";
+>m1 : Symbol(m1, Decl(index.mjs, 0, 6))
+
+import * as m2 from "./index.mjs";
+>m2 : Symbol(m2, Decl(index.mjs, 1, 6))
+
+import * as m3 from "./index.cjs";
+>m3 : Symbol(m3, Decl(index.mjs, 2, 6))
+
+import * as m4 from "./subfolder/index.js";
+>m4 : Symbol(m4, Decl(index.mjs, 3, 6))
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : Symbol(m5, Decl(index.mjs, 4, 6))
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : Symbol(m6, Decl(index.mjs, 5, 6))
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : Symbol(m7, Decl(index.mjs, 6, 6))
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : Symbol(m8, Decl(index.mjs, 7, 6))
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : Symbol(m9, Decl(index.mjs, 8, 6))
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : Symbol(m10, Decl(index.mjs, 9, 6))
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : Symbol(m11, Decl(index.mjs, 10, 6))
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : Symbol(m12, Decl(index.mjs, 11, 6))
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : Symbol(m13, Decl(index.mjs, 13, 6))
+
+import * as m14 from "./index";
+>m14 : Symbol(m14, Decl(index.mjs, 14, 6))
+
+import * as m15 from "./subfolder";
+>m15 : Symbol(m15, Decl(index.mjs, 15, 6))
+
+import * as m16 from "./subfolder/";
+>m16 : Symbol(m16, Decl(index.mjs, 16, 6))
+
+import * as m17 from "./subfolder/index";
+>m17 : Symbol(m17, Decl(index.mjs, 17, 6))
+
+import * as m18 from "./subfolder2";
+>m18 : Symbol(m18, Decl(index.mjs, 18, 6))
+
+import * as m19 from "./subfolder2/";
+>m19 : Symbol(m19, Decl(index.mjs, 19, 6))
+
+import * as m20 from "./subfolder2/index";
+>m20 : Symbol(m20, Decl(index.mjs, 20, 6))
+
+import * as m21 from "./subfolder2/another";
+>m21 : Symbol(m21, Decl(index.mjs, 21, 6))
+
+import * as m22 from "./subfolder2/another/";
+>m22 : Symbol(m22, Decl(index.mjs, 22, 6))
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : Symbol(m23, Decl(index.mjs, 23, 6))
+
+void m1;
+>m1 : Symbol(m1, Decl(index.mjs, 0, 6))
+
+void m2;
+>m2 : Symbol(m2, Decl(index.mjs, 1, 6))
+
+void m3;
+>m3 : Symbol(m3, Decl(index.mjs, 2, 6))
+
+void m4;
+>m4 : Symbol(m4, Decl(index.mjs, 3, 6))
+
+void m5;
+>m5 : Symbol(m5, Decl(index.mjs, 4, 6))
+
+void m6;
+>m6 : Symbol(m6, Decl(index.mjs, 5, 6))
+
+void m7;
+>m7 : Symbol(m7, Decl(index.mjs, 6, 6))
+
+void m8;
+>m8 : Symbol(m8, Decl(index.mjs, 7, 6))
+
+void m9;
+>m9 : Symbol(m9, Decl(index.mjs, 8, 6))
+
+void m10;
+>m10 : Symbol(m10, Decl(index.mjs, 9, 6))
+
+void m11;
+>m11 : Symbol(m11, Decl(index.mjs, 10, 6))
+
+void m12;
+>m12 : Symbol(m12, Decl(index.mjs, 11, 6))
+
+void m13;
+>m13 : Symbol(m13, Decl(index.mjs, 13, 6))
+
+void m14;
+>m14 : Symbol(m14, Decl(index.mjs, 14, 6))
+
+void m15;
+>m15 : Symbol(m15, Decl(index.mjs, 15, 6))
+
+void m16;
+>m16 : Symbol(m16, Decl(index.mjs, 16, 6))
+
+void m17;
+>m17 : Symbol(m17, Decl(index.mjs, 17, 6))
+
+void m18;
+>m18 : Symbol(m18, Decl(index.mjs, 18, 6))
+
+void m19;
+>m19 : Symbol(m19, Decl(index.mjs, 19, 6))
+
+void m20;
+>m20 : Symbol(m20, Decl(index.mjs, 20, 6))
+
+void m21;
+>m21 : Symbol(m21, Decl(index.mjs, 21, 6))
+
+void m22;
+>m22 : Symbol(m22, Decl(index.mjs, 22, 6))
+
+void m23;
+>m23 : Symbol(m23, Decl(index.mjs, 23, 6))
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : Symbol(m24, Decl(index.mjs, 46, 9))
+
+import m25 = require("./index");
+>m25 : Symbol(m25, Decl(index.mjs, 49, 27))
+
+import m26 = require("./subfolder");
+>m26 : Symbol(m26, Decl(index.mjs, 50, 32))
+
+import m27 = require("./subfolder/");
+>m27 : Symbol(m27, Decl(index.mjs, 51, 36))
+
+import m28 = require("./subfolder/index");
+>m28 : Symbol(m28, Decl(index.mjs, 52, 37))
+
+import m29 = require("./subfolder2");
+>m29 : Symbol(m29, Decl(index.mjs, 53, 42))
+
+import m30 = require("./subfolder2/");
+>m30 : Symbol(m30, Decl(index.mjs, 54, 37))
+
+import m31 = require("./subfolder2/index");
+>m31 : Symbol(m31, Decl(index.mjs, 55, 38))
+
+import m32 = require("./subfolder2/another");
+>m32 : Symbol(m32, Decl(index.mjs, 56, 43))
+
+import m33 = require("./subfolder2/another/");
+>m33 : Symbol(m33, Decl(index.mjs, 57, 45))
+
+import m34 = require("./subfolder2/another/index");
+>m34 : Symbol(m34, Decl(index.mjs, 58, 46))
+
+void m24;
+>m24 : Symbol(m24, Decl(index.mjs, 46, 9))
+
+void m25;
+>m25 : Symbol(m25, Decl(index.mjs, 49, 27))
+
+void m26;
+>m26 : Symbol(m26, Decl(index.mjs, 50, 32))
+
+void m27;
+>m27 : Symbol(m27, Decl(index.mjs, 51, 36))
+
+void m28;
+>m28 : Symbol(m28, Decl(index.mjs, 52, 37))
+
+void m29;
+>m29 : Symbol(m29, Decl(index.mjs, 53, 42))
+
+void m30;
+>m30 : Symbol(m30, Decl(index.mjs, 54, 37))
+
+void m31;
+>m31 : Symbol(m31, Decl(index.mjs, 55, 38))
+
+void m32;
+>m32 : Symbol(m32, Decl(index.mjs, 56, 43))
+
+void m33;
+>m33 : Symbol(m33, Decl(index.mjs, 57, 45))
+
+void m34;
+>m34 : Symbol(m34, Decl(index.mjs, 58, 46))
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Symbol(_m35, Decl(index.mjs, 73, 5))
+
+const _m36 = import("./index");
+>_m36 : Symbol(_m36, Decl(index.mjs, 74, 5))
+
+const _m37 = import("./subfolder");
+>_m37 : Symbol(_m37, Decl(index.mjs, 75, 5))
+
+const _m38 = import("./subfolder/");
+>_m38 : Symbol(_m38, Decl(index.mjs, 76, 5))
+
+const _m39 = import("./subfolder/index");
+>_m39 : Symbol(_m39, Decl(index.mjs, 77, 5))
+
+const _m40 = import("./subfolder2");
+>_m40 : Symbol(_m40, Decl(index.mjs, 78, 5))
+
+const _m41 = import("./subfolder2/");
+>_m41 : Symbol(_m41, Decl(index.mjs, 79, 5))
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Symbol(_m42, Decl(index.mjs, 80, 5))
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Symbol(_m43, Decl(index.mjs, 81, 5))
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Symbol(_m44, Decl(index.mjs, 82, 5))
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Symbol(_m45, Decl(index.mjs, 83, 5))
+
+// esm format file
+const x = 1;
+>x : Symbol(x, Decl(index.mjs, 86, 5))
+
+export {x};
+>x : Symbol(m2.x, Decl(index.mjs, 87, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types
new file mode 100644
index 0000000000000..148c55c036dde
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types
@@ -0,0 +1,997 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.cjs ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder/index.mjs ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.js ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs ===
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs ===
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+>m13 : typeof m1
+
+import * as m14 from "./index";
+>m14 : typeof m1
+
+import * as m15 from "./subfolder";
+>m15 : typeof m4
+
+import * as m16 from "./subfolder/";
+>m16 : typeof m4
+
+import * as m17 from "./subfolder/index";
+>m17 : typeof m4
+
+import * as m18 from "./subfolder2";
+>m18 : typeof m7
+
+import * as m19 from "./subfolder2/";
+>m19 : typeof m7
+
+import * as m20 from "./subfolder2/index";
+>m20 : typeof m7
+
+import * as m21 from "./subfolder2/another";
+>m21 : typeof m10
+
+import * as m22 from "./subfolder2/another/";
+>m22 : typeof m10
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : typeof m10
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : typeof m1
+
+void m14;
+>void m14 : undefined
+>m14 : typeof m1
+
+void m15;
+>void m15 : undefined
+>m15 : typeof m4
+
+void m16;
+>void m16 : undefined
+>m16 : typeof m4
+
+void m17;
+>void m17 : undefined
+>m17 : typeof m4
+
+void m18;
+>void m18 : undefined
+>m18 : typeof m7
+
+void m19;
+>void m19 : undefined
+>m19 : typeof m7
+
+void m20;
+>void m20 : undefined
+>m20 : typeof m7
+
+void m21;
+>void m21 : undefined
+>m21 : typeof m10
+
+void m22;
+>void m22 : undefined
+>m22 : typeof m10
+
+void m23;
+>void m23 : undefined
+>m23 : typeof m10
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// cjs format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+import * as m1 from "./index.js";
+>m1 : typeof m1
+
+import * as m2 from "./index.mjs";
+>m2 : typeof m2
+
+import * as m3 from "./index.cjs";
+>m3 : typeof m3
+
+import * as m4 from "./subfolder/index.js";
+>m4 : typeof m4
+
+import * as m5 from "./subfolder/index.mjs";
+>m5 : typeof m5
+
+import * as m6 from "./subfolder/index.cjs";
+>m6 : typeof m6
+
+import * as m7 from "./subfolder2/index.js";
+>m7 : typeof m7
+
+import * as m8 from "./subfolder2/index.mjs";
+>m8 : typeof m8
+
+import * as m9 from "./subfolder2/index.cjs";
+>m9 : typeof m9
+
+import * as m10 from "./subfolder2/another/index.js";
+>m10 : typeof m10
+
+import * as m11 from "./subfolder2/another/index.mjs";
+>m11 : typeof m11
+
+import * as m12 from "./subfolder2/another/index.cjs";
+>m12 : typeof m12
+
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+>m13 : any
+
+import * as m14 from "./index";
+>m14 : any
+
+import * as m15 from "./subfolder";
+>m15 : any
+
+import * as m16 from "./subfolder/";
+>m16 : any
+
+import * as m17 from "./subfolder/index";
+>m17 : any
+
+import * as m18 from "./subfolder2";
+>m18 : any
+
+import * as m19 from "./subfolder2/";
+>m19 : any
+
+import * as m20 from "./subfolder2/index";
+>m20 : any
+
+import * as m21 from "./subfolder2/another";
+>m21 : any
+
+import * as m22 from "./subfolder2/another/";
+>m22 : any
+
+import * as m23 from "./subfolder2/another/index";
+>m23 : any
+
+void m1;
+>void m1 : undefined
+>m1 : typeof m1
+
+void m2;
+>void m2 : undefined
+>m2 : typeof m2
+
+void m3;
+>void m3 : undefined
+>m3 : typeof m3
+
+void m4;
+>void m4 : undefined
+>m4 : typeof m4
+
+void m5;
+>void m5 : undefined
+>m5 : typeof m5
+
+void m6;
+>void m6 : undefined
+>m6 : typeof m6
+
+void m7;
+>void m7 : undefined
+>m7 : typeof m7
+
+void m8;
+>void m8 : undefined
+>m8 : typeof m8
+
+void m9;
+>void m9 : undefined
+>m9 : typeof m9
+
+void m10;
+>void m10 : undefined
+>m10 : typeof m10
+
+void m11;
+>void m11 : undefined
+>m11 : typeof m11
+
+void m12;
+>void m12 : undefined
+>m12 : typeof m12
+
+void m13;
+>void m13 : undefined
+>m13 : any
+
+void m14;
+>void m14 : undefined
+>m14 : any
+
+void m15;
+>void m15 : undefined
+>m15 : any
+
+void m16;
+>void m16 : undefined
+>m16 : any
+
+void m17;
+>void m17 : undefined
+>m17 : any
+
+void m18;
+>void m18 : undefined
+>m18 : any
+
+void m19;
+>void m19 : undefined
+>m19 : any
+
+void m20;
+>void m20 : undefined
+>m20 : any
+
+void m21;
+>void m21 : undefined
+>m21 : any
+
+void m22;
+>void m22 : undefined
+>m22 : any
+
+void m23;
+>void m23 : undefined
+>m23 : any
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+>m24 : typeof m1
+
+import m25 = require("./index");
+>m25 : typeof m1
+
+import m26 = require("./subfolder");
+>m26 : typeof m4
+
+import m27 = require("./subfolder/");
+>m27 : typeof m4
+
+import m28 = require("./subfolder/index");
+>m28 : typeof m4
+
+import m29 = require("./subfolder2");
+>m29 : typeof m7
+
+import m30 = require("./subfolder2/");
+>m30 : typeof m7
+
+import m31 = require("./subfolder2/index");
+>m31 : typeof m7
+
+import m32 = require("./subfolder2/another");
+>m32 : typeof m10
+
+import m33 = require("./subfolder2/another/");
+>m33 : typeof m10
+
+import m34 = require("./subfolder2/another/index");
+>m34 : typeof m10
+
+void m24;
+>void m24 : undefined
+>m24 : typeof m1
+
+void m25;
+>void m25 : undefined
+>m25 : typeof m1
+
+void m26;
+>void m26 : undefined
+>m26 : typeof m4
+
+void m27;
+>void m27 : undefined
+>m27 : typeof m4
+
+void m28;
+>void m28 : undefined
+>m28 : typeof m4
+
+void m29;
+>void m29 : undefined
+>m29 : typeof m7
+
+void m30;
+>void m30 : undefined
+>m30 : typeof m7
+
+void m31;
+>void m31 : undefined
+>m31 : typeof m7
+
+void m32;
+>void m32 : undefined
+>m32 : typeof m10
+
+void m33;
+>void m33 : undefined
+>m33 : typeof m10
+
+void m34;
+>void m34 : undefined
+>m34 : typeof m10
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+>_m35 : Promise<any>
+>import("./") : Promise<any>
+>"./" : "./"
+
+const _m36 = import("./index");
+>_m36 : Promise<any>
+>import("./index") : Promise<any>
+>"./index" : "./index"
+
+const _m37 = import("./subfolder");
+>_m37 : Promise<any>
+>import("./subfolder") : Promise<any>
+>"./subfolder" : "./subfolder"
+
+const _m38 = import("./subfolder/");
+>_m38 : Promise<any>
+>import("./subfolder/") : Promise<any>
+>"./subfolder/" : "./subfolder/"
+
+const _m39 = import("./subfolder/index");
+>_m39 : Promise<any>
+>import("./subfolder/index") : Promise<any>
+>"./subfolder/index" : "./subfolder/index"
+
+const _m40 = import("./subfolder2");
+>_m40 : Promise<any>
+>import("./subfolder2") : Promise<any>
+>"./subfolder2" : "./subfolder2"
+
+const _m41 = import("./subfolder2/");
+>_m41 : Promise<any>
+>import("./subfolder2/") : Promise<any>
+>"./subfolder2/" : "./subfolder2/"
+
+const _m42 = import("./subfolder2/index");
+>_m42 : Promise<any>
+>import("./subfolder2/index") : Promise<any>
+>"./subfolder2/index" : "./subfolder2/index"
+
+const _m43 = import("./subfolder2/another");
+>_m43 : Promise<any>
+>import("./subfolder2/another") : Promise<any>
+>"./subfolder2/another" : "./subfolder2/another"
+
+const _m44 = import("./subfolder2/another/");
+>_m44 : Promise<any>
+>import("./subfolder2/another/") : Promise<any>
+>"./subfolder2/another/" : "./subfolder2/another/"
+
+const _m45 = import("./subfolder2/another/index");
+>_m45 : Promise<any>
+>import("./subfolder2/another/index") : Promise<any>
+>"./subfolder2/another/index" : "./subfolder2/another/index"
+
+// esm format file
+const x = 1;
+>x : 1
+>1 : 1
+
+export {x};
+>x : 1
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).errors.txt
new file mode 100644
index 0000000000000..83e50c001e74c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).errors.txt
@@ -0,0 +1,135 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/allowJs/index.cjs (2 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.cjsSource;
+    mjsi.cjsSource;
+    typei.implicitCjsSource;
+    ts.cjsSource;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const implicitCjsSource = true;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (1 errors) ====
+    // esm format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const mjsSource = true;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (0 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const cjsSource = true;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./a": {
+                "require": "./index.cjs",
+                "node": "./index.mjs"
+            },
+            "./b": {
+                "import": "./index.mjs",
+                "node": "./index.cjs"
+            },
+            ".": {
+                "import": "./index.mjs",
+                "node": "./index.js"
+            },
+            "./types": {
+                "types": {
+                    "import": "./index.d.mts",
+                    "require": "./index.d.cts",
+                },
+                "node": {
+                    "import": "./index.mjs",
+                    "require": "./index.cjs"
+                }
+            }
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).js
new file mode 100644
index 0000000000000..77df1469fbf62
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).js
@@ -0,0 +1,201 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cjs]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./a": {
+            "require": "./index.cjs",
+            "node": "./index.mjs"
+        },
+        "./b": {
+            "import": "./index.mjs",
+            "node": "./index.cjs"
+        },
+        ".": {
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+        "./types": {
+            "types": {
+                "import": "./index.d.mts",
+                "require": "./index.d.cts",
+            },
+            "node": {
+                "import": "./index.mjs",
+                "require": "./index.cjs"
+            }
+        }
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/a"));
+const mjsi = __importStar(require("inner/b"));
+const typei = __importStar(require("inner"));
+const ts = __importStar(require("inner/types"));
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).symbols
new file mode 100644
index 0000000000000..ce8944196c089
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).symbols
@@ -0,0 +1,243 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.js, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.js, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.mjs, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.mjs, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.cjs, 10, 6))
+
+cjsi.cjsSource;
+>cjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+mjsi.cjsSource;
+>mjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+>implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+ts.cjsSource;
+>ts.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>ts : Symbol(ts, Decl(index.cjs, 10, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.ts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.type.cjs, Decl(index.d.ts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.type.mjs, Decl(index.d.ts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type.type, Decl(index.d.ts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.type.ts, Decl(index.d.ts, 8, 8))
+
+export const implicitCjsSource = true;
+>implicitCjsSource : Symbol(mjs.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.mts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs, Decl(index.d.mts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.mjs, Decl(index.d.mts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type, Decl(index.d.mts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.ts, Decl(index.d.mts, 8, 8))
+
+export const mjsSource = true;
+>mjsSource : Symbol(mjs.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.cts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 6, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 7, 8))
+
+export { ts };
+>ts : Symbol(cjs.ts, Decl(index.d.cts, 8, 8))
+
+export const cjsSource = true;
+>cjsSource : Symbol(cjs.cjsSource, Decl(index.d.cts, 9, 12))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).types
new file mode 100644
index 0000000000000..7b1fe309bb0dd
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node12).types
@@ -0,0 +1,246 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi.type
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.cjsSource;
+>cjsi.cjsSource : true
+>cjsi : typeof cjsi
+>cjsSource : true
+
+mjsi.cjsSource;
+>mjsi.cjsSource : true
+>mjsi : typeof cjsi
+>cjsSource : true
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : true
+>typei : typeof cjsi.type
+>implicitCjsSource : true
+
+ts.cjsSource;
+>ts.cjsSource : true
+>ts : typeof cjsi
+>cjsSource : true
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.type
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.type
+
+export { ts };
+>ts : typeof mjs
+
+export const implicitCjsSource = true;
+>implicitCjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs
+
+export { ts };
+>ts : typeof mjs
+
+export const mjsSource = true;
+>mjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : typeof cjs
+
+import * as mjs from "inner/b";
+>mjs : typeof cjs
+
+import * as type from "inner";
+>type : typeof cjs.type
+
+import * as ts from "inner/types";
+>ts : typeof cjs
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs
+
+export { type };
+>type : typeof cjs.type
+
+export { ts };
+>ts : typeof cjs
+
+export const cjsSource = true;
+>cjsSource : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..83e50c001e74c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt
@@ -0,0 +1,135 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/allowJs/index.cjs (2 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.cjsSource;
+    mjsi.cjsSource;
+    typei.implicitCjsSource;
+    ts.cjsSource;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const implicitCjsSource = true;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (1 errors) ====
+    // esm format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const mjsSource = true;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (0 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const cjsSource = true;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./a": {
+                "require": "./index.cjs",
+                "node": "./index.mjs"
+            },
+            "./b": {
+                "import": "./index.mjs",
+                "node": "./index.cjs"
+            },
+            ".": {
+                "import": "./index.mjs",
+                "node": "./index.js"
+            },
+            "./types": {
+                "types": {
+                    "import": "./index.d.mts",
+                    "require": "./index.d.cts",
+                },
+                "node": {
+                    "import": "./index.mjs",
+                    "require": "./index.cjs"
+                }
+            }
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js
new file mode 100644
index 0000000000000..77df1469fbf62
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js
@@ -0,0 +1,201 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cjs]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./a": {
+            "require": "./index.cjs",
+            "node": "./index.mjs"
+        },
+        "./b": {
+            "import": "./index.mjs",
+            "node": "./index.cjs"
+        },
+        ".": {
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+        "./types": {
+            "types": {
+                "import": "./index.d.mts",
+                "require": "./index.d.cts",
+            },
+            "node": {
+                "import": "./index.mjs",
+                "require": "./index.cjs"
+            }
+        }
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/a"));
+const mjsi = __importStar(require("inner/b"));
+const typei = __importStar(require("inner"));
+const ts = __importStar(require("inner/types"));
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..ce8944196c089
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).symbols
@@ -0,0 +1,243 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.js, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.js, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.mjs, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.mjs, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.cjs, 10, 6))
+
+cjsi.cjsSource;
+>cjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+mjsi.cjsSource;
+>mjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+>implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+ts.cjsSource;
+>ts.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>ts : Symbol(ts, Decl(index.cjs, 10, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.ts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.type.cjs, Decl(index.d.ts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.type.mjs, Decl(index.d.ts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type.type, Decl(index.d.ts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.type.ts, Decl(index.d.ts, 8, 8))
+
+export const implicitCjsSource = true;
+>implicitCjsSource : Symbol(mjs.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.mts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs, Decl(index.d.mts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.mjs, Decl(index.d.mts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type, Decl(index.d.mts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.ts, Decl(index.d.mts, 8, 8))
+
+export const mjsSource = true;
+>mjsSource : Symbol(mjs.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.cts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 6, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 7, 8))
+
+export { ts };
+>ts : Symbol(cjs.ts, Decl(index.d.cts, 8, 8))
+
+export const cjsSource = true;
+>cjsSource : Symbol(cjs.cjsSource, Decl(index.d.cts, 9, 12))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types
new file mode 100644
index 0000000000000..7b1fe309bb0dd
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types
@@ -0,0 +1,246 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi.type
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.cjsSource;
+>cjsi.cjsSource : true
+>cjsi : typeof cjsi
+>cjsSource : true
+
+mjsi.cjsSource;
+>mjsi.cjsSource : true
+>mjsi : typeof cjsi
+>cjsSource : true
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : true
+>typei : typeof cjsi.type
+>implicitCjsSource : true
+
+ts.cjsSource;
+>ts.cjsSource : true
+>ts : typeof cjsi
+>cjsSource : true
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.type
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.type
+
+export { ts };
+>ts : typeof mjs
+
+export const implicitCjsSource = true;
+>implicitCjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs
+
+export { ts };
+>ts : typeof mjs
+
+export const mjsSource = true;
+>mjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : typeof cjs
+
+import * as mjs from "inner/b";
+>mjs : typeof cjs
+
+import * as type from "inner";
+>type : typeof cjs.type
+
+import * as ts from "inner/types";
+>ts : typeof cjs
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs
+
+export { type };
+>type : typeof cjs.type
+
+export { ts };
+>ts : typeof cjs
+
+export const cjsSource = true;
+>cjsSource : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).js
new file mode 100644
index 0000000000000..471912e1192d9
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).js
@@ -0,0 +1,45 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts] ////
+
+//// [index.js]
+// cjs format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [index.js]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.main = void 0;
+// cjs format file
+async function main() {
+    const { readFile } = await import("fs");
+}
+exports.main = main;
+//// [index.js]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+
+
+//// [index.d.ts]
+export function main(): Promise<void>;
+//// [index.d.ts]
+export function main(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).symbols
new file mode 100644
index 0000000000000..0b0c85a01f192
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export async function main() {
+>main : Symbol(main, Decl(index.js, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.js, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export async function main() {
+>main : Symbol(main, Decl(index.js, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.js, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).types
new file mode 100644
index 0000000000000..650fcf3a63733
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).types
@@ -0,0 +1,26 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).js
new file mode 100644
index 0000000000000..471912e1192d9
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).js
@@ -0,0 +1,45 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts] ////
+
+//// [index.js]
+// cjs format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [index.js]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.main = void 0;
+// cjs format file
+async function main() {
+    const { readFile } = await import("fs");
+}
+exports.main = main;
+//// [index.js]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+
+
+//// [index.d.ts]
+export function main(): Promise<void>;
+//// [index.d.ts]
+export function main(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).symbols
new file mode 100644
index 0000000000000..0b0c85a01f192
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export async function main() {
+>main : Symbol(main, Decl(index.js, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.js, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export async function main() {
+>main : Symbol(main, Decl(index.js, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.js, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).types
new file mode 100644
index 0000000000000..650fcf3a63733
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).types
@@ -0,0 +1,26 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).errors.txt
new file mode 100644
index 0000000000000..a0a3d489f44cb
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).errors.txt
@@ -0,0 +1,41 @@
+tests/cases/conformance/node/allowJs/file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
+tests/cases/conformance/node/allowJs/index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+tests/cases/conformance/node/allowJs/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ====
+    // cjs format file
+    const a = {};
+    export = a;
+    ~~~~~~~~~~~
+!!! error TS8003: 'export =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/subfolder/file.js (0 errors) ====
+    // cjs format file
+    const a = {};
+    module.exports = a;
+==== tests/cases/conformance/node/allowJs/index.js (2 errors) ====
+    // esm format file
+    const a = {};
+    export = a;
+    ~~~~~~~~~~~
+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+    ~~~~~~~~~~~
+!!! error TS8003: 'export =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/file.js (1 errors) ====
+    // esm format file
+    import "fs";
+    const a = {};
+    module.exports = a;
+    ~~~~~~
+!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).js
new file mode 100644
index 0000000000000..10d6da622e9a4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).js
@@ -0,0 +1,61 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts] ////
+
+//// [index.js]
+// cjs format file
+const a = {};
+export = a;
+//// [file.js]
+// cjs format file
+const a = {};
+module.exports = a;
+//// [index.js]
+// esm format file
+const a = {};
+export = a;
+//// [file.js]
+// esm format file
+import "fs";
+const a = {};
+module.exports = a;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+// cjs format file
+const a = {};
+module.exports = a;
+//// [file.js]
+// cjs format file
+const a = {};
+module.exports = a;
+//// [index.js]
+// esm format file
+const a = {};
+export {};
+//// [file.js]
+// esm format file
+import "fs";
+const a = {};
+module.exports = a;
+
+
+//// [index.d.ts]
+export = a;
+declare const a: {};
+//// [file.d.ts]
+export = a;
+declare const a: {};
+//// [index.d.ts]
+export = a;
+declare const a: {};
+//// [file.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).symbols
new file mode 100644
index 0000000000000..4e0e3aed1a9a6
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).symbols
@@ -0,0 +1,36 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const a = {};
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+=== tests/cases/conformance/node/allowJs/subfolder/file.js ===
+// cjs format file
+const a = {};
+>a : Symbol(a, Decl(file.js, 1, 5))
+
+module.exports = a;
+>module.exports : Symbol(module.exports, Decl(file.js, 0, 0))
+>module : Symbol(export=, Decl(file.js, 1, 13))
+>exports : Symbol(export=, Decl(file.js, 1, 13))
+>a : Symbol(a, Decl(file.js, 1, 5))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const a = {};
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+import "fs";
+const a = {};
+>a : Symbol(a, Decl(file.js, 2, 5))
+
+module.exports = a;
+>a : Symbol(a, Decl(file.js, 2, 5))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).types
new file mode 100644
index 0000000000000..e6543212f665f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).types
@@ -0,0 +1,45 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
+=== tests/cases/conformance/node/allowJs/subfolder/file.js ===
+// cjs format file
+const a = {};
+>a : {}
+>{} : {}
+
+module.exports = a;
+>module.exports = a : {}
+>module.exports : {}
+>module : { exports: {}; }
+>exports : {}
+>a : {}
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+import "fs";
+const a = {};
+>a : {}
+>{} : {}
+
+module.exports = a;
+>module.exports = a : any
+>module.exports : any
+>module : any
+>exports : any
+>a : {}
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..a0a3d489f44cb
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt
@@ -0,0 +1,41 @@
+tests/cases/conformance/node/allowJs/file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
+tests/cases/conformance/node/allowJs/index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+tests/cases/conformance/node/allowJs/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ====
+    // cjs format file
+    const a = {};
+    export = a;
+    ~~~~~~~~~~~
+!!! error TS8003: 'export =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/subfolder/file.js (0 errors) ====
+    // cjs format file
+    const a = {};
+    module.exports = a;
+==== tests/cases/conformance/node/allowJs/index.js (2 errors) ====
+    // esm format file
+    const a = {};
+    export = a;
+    ~~~~~~~~~~~
+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+    ~~~~~~~~~~~
+!!! error TS8003: 'export =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/file.js (1 errors) ====
+    // esm format file
+    import "fs";
+    const a = {};
+    module.exports = a;
+    ~~~~~~
+!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).js
new file mode 100644
index 0000000000000..10d6da622e9a4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).js
@@ -0,0 +1,61 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts] ////
+
+//// [index.js]
+// cjs format file
+const a = {};
+export = a;
+//// [file.js]
+// cjs format file
+const a = {};
+module.exports = a;
+//// [index.js]
+// esm format file
+const a = {};
+export = a;
+//// [file.js]
+// esm format file
+import "fs";
+const a = {};
+module.exports = a;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+// cjs format file
+const a = {};
+module.exports = a;
+//// [file.js]
+// cjs format file
+const a = {};
+module.exports = a;
+//// [index.js]
+// esm format file
+const a = {};
+export {};
+//// [file.js]
+// esm format file
+import "fs";
+const a = {};
+module.exports = a;
+
+
+//// [index.d.ts]
+export = a;
+declare const a: {};
+//// [file.d.ts]
+export = a;
+declare const a: {};
+//// [index.d.ts]
+export = a;
+declare const a: {};
+//// [file.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).symbols
new file mode 100644
index 0000000000000..4e0e3aed1a9a6
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).symbols
@@ -0,0 +1,36 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const a = {};
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+=== tests/cases/conformance/node/allowJs/subfolder/file.js ===
+// cjs format file
+const a = {};
+>a : Symbol(a, Decl(file.js, 1, 5))
+
+module.exports = a;
+>module.exports : Symbol(module.exports, Decl(file.js, 0, 0))
+>module : Symbol(export=, Decl(file.js, 1, 13))
+>exports : Symbol(export=, Decl(file.js, 1, 13))
+>a : Symbol(a, Decl(file.js, 1, 5))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const a = {};
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.js, 1, 5))
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+import "fs";
+const a = {};
+>a : Symbol(a, Decl(file.js, 2, 5))
+
+module.exports = a;
+>a : Symbol(a, Decl(file.js, 2, 5))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).types
new file mode 100644
index 0000000000000..e6543212f665f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).types
@@ -0,0 +1,45 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
+=== tests/cases/conformance/node/allowJs/subfolder/file.js ===
+// cjs format file
+const a = {};
+>a : {}
+>{} : {}
+
+module.exports = a;
+>module.exports = a : {}
+>module.exports : {}
+>module : { exports: {}; }
+>exports : {}
+>a : {}
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+import "fs";
+const a = {};
+>a : {}
+>{} : {}
+
+module.exports = a;
+>module.exports = a : any
+>module.exports : any
+>module : any
+>exports : any
+>a : {}
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).errors.txt
new file mode 100644
index 0000000000000..84386984bc398
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).errors.txt
@@ -0,0 +1,38 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12.
+tests/cases/conformance/node/allowJs/subfolder/index.js(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ====
+    // cjs format file
+    function require() {}
+             ~~~~~~~
+!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+    const exports = {};
+          ~~~~~~~
+!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+    class Object {}
+          ~~~~~~
+!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12.
+    export const __esModule = false;
+                 ~~~~~~~~~~
+!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+    export {require, exports, Object};
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    function require() {}
+    const exports = {};
+    class Object {}
+    export const __esModule = false;
+    export {require, exports, Object};
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).js
new file mode 100644
index 0000000000000..3900870c747d2
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).js
@@ -0,0 +1,62 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts] ////
+
+//// [index.js]
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [index.js]
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Object = exports.exports = exports.require = exports.__esModule = void 0;
+// cjs format file
+function require() { }
+exports.require = require;
+const exports = {};
+exports.exports = exports;
+class Object {
+}
+exports.Object = Object;
+exports.__esModule = false;
+//// [index.js]
+// esm format file
+function require() { }
+const exports = {};
+class Object {
+}
+export const __esModule = false;
+export { require, exports, Object };
+
+
+//// [index.d.ts]
+export const __esModule: false;
+export function require(): void;
+export const exports: {};
+export class Object {
+}
+//// [index.d.ts]
+export const __esModule: false;
+export function require(): void;
+export const exports: {};
+export class Object {
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).symbols
new file mode 100644
index 0000000000000..8565d39212c8c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).symbols
@@ -0,0 +1,38 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+function require() {}
+>require : Symbol(require, Decl(index.js, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.js, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.js, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.js, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.js, 5, 8))
+>exports : Symbol(exports, Decl(index.js, 5, 16))
+>Object : Symbol(Object, Decl(index.js, 5, 25))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+function require() {}
+>require : Symbol(require, Decl(index.js, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.js, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.js, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.js, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.js, 5, 8))
+>exports : Symbol(exports, Decl(index.js, 5, 16))
+>Object : Symbol(Object, Decl(index.js, 5, 25))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).types
new file mode 100644
index 0000000000000..a290eb3ca58e3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).types
@@ -0,0 +1,42 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..1e12bbbe4ed99
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).errors.txt
@@ -0,0 +1,38 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext.
+tests/cases/conformance/node/allowJs/subfolder/index.js(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ====
+    // cjs format file
+    function require() {}
+             ~~~~~~~
+!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+    const exports = {};
+          ~~~~~~~
+!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+    class Object {}
+          ~~~~~~
+!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext.
+    export const __esModule = false;
+                 ~~~~~~~~~~
+!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+    export {require, exports, Object};
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    function require() {}
+    const exports = {};
+    class Object {}
+    export const __esModule = false;
+    export {require, exports, Object};
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).js
new file mode 100644
index 0000000000000..3900870c747d2
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).js
@@ -0,0 +1,62 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts] ////
+
+//// [index.js]
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [index.js]
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Object = exports.exports = exports.require = exports.__esModule = void 0;
+// cjs format file
+function require() { }
+exports.require = require;
+const exports = {};
+exports.exports = exports;
+class Object {
+}
+exports.Object = Object;
+exports.__esModule = false;
+//// [index.js]
+// esm format file
+function require() { }
+const exports = {};
+class Object {
+}
+export const __esModule = false;
+export { require, exports, Object };
+
+
+//// [index.d.ts]
+export const __esModule: false;
+export function require(): void;
+export const exports: {};
+export class Object {
+}
+//// [index.d.ts]
+export const __esModule: false;
+export function require(): void;
+export const exports: {};
+export class Object {
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).symbols
new file mode 100644
index 0000000000000..8565d39212c8c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).symbols
@@ -0,0 +1,38 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+function require() {}
+>require : Symbol(require, Decl(index.js, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.js, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.js, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.js, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.js, 5, 8))
+>exports : Symbol(exports, Decl(index.js, 5, 16))
+>Object : Symbol(Object, Decl(index.js, 5, 25))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+function require() {}
+>require : Symbol(require, Decl(index.js, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.js, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.js, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.js, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.js, 5, 8))
+>exports : Symbol(exports, Decl(index.js, 5, 16))
+>Object : Symbol(Object, Decl(index.js, 5, 25))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).types
new file mode 100644
index 0000000000000..a290eb3ca58e3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).types
@@ -0,0 +1,42 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).errors.txt
new file mode 100644
index 0000000000000..bbc352d7a78d5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).errors.txt
@@ -0,0 +1,49 @@
+tests/cases/conformance/node/allowJs/file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ====
+    // cjs format file
+    import fs = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    fs.readFile;
+    export import fs2 = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/index.js (2 errors) ====
+    // esm format file
+    import fs = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    fs.readFile;
+    export import fs2 = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/file.js (2 errors) ====
+    // esm format file
+    const __require = null;
+    const _createRequire = null;
+    import fs = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    fs.readFile;
+    export import fs2 = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).js
new file mode 100644
index 0000000000000..1e97293cca863
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).js
@@ -0,0 +1,68 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts] ////
+
+//// [index.js]
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [index.js]
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [file.js]
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const fs = require("fs");
+fs.readFile;
+exports.fs2 = require("fs");
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+// esm format file
+const fs = __require("fs");
+fs.readFile;
+const fs2 = __require("fs");
+export { fs2 };
+//// [file.js]
+import { createRequire as _createRequire_1 } from "module";
+const __require_1 = _createRequire_1(import.meta.url);
+// esm format file
+const __require = null;
+const _createRequire = null;
+const fs = __require_1("fs");
+fs.readFile;
+const fs2 = __require_1("fs");
+export { fs2 };
+
+
+//// [index.d.ts]
+/// <reference path="../../tests/cases/conformance/node/allowJs/types.d.ts" />
+import fs2 = require("fs");
+//// [index.d.ts]
+/// <reference path="../tests/cases/conformance/node/allowJs/types.d.ts" />
+import fs2 = require("fs");
+//// [file.d.ts]
+/// <reference path="../tests/cases/conformance/node/allowJs/types.d.ts" />
+import fs2 = require("fs");
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).symbols
new file mode 100644
index 0000000000000..11b3047ebcd76
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).symbols
@@ -0,0 +1,43 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.js, 2, 12))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.js, 2, 12))
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+const __require = null;
+>__require : Symbol(__require, Decl(file.js, 1, 5))
+
+const _createRequire = null;
+>_createRequire : Symbol(_createRequire, Decl(file.js, 2, 5))
+
+import fs = require("fs");
+>fs : Symbol(fs, Decl(file.js, 2, 28))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(file.js, 2, 28))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(file.js, 4, 12))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).types
new file mode 100644
index 0000000000000..2720b1f1b7dc3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).types
@@ -0,0 +1,51 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+const __require = null;
+>__require : any
+>null : null
+
+const _createRequire = null;
+>_createRequire : any
+>null : null
+
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..bbc352d7a78d5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt
@@ -0,0 +1,49 @@
+tests/cases/conformance/node/allowJs/file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ====
+    // cjs format file
+    import fs = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    fs.readFile;
+    export import fs2 = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/index.js (2 errors) ====
+    // esm format file
+    import fs = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    fs.readFile;
+    export import fs2 = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/file.js (2 errors) ====
+    // esm format file
+    const __require = null;
+    const _createRequire = null;
+    import fs = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    fs.readFile;
+    export import fs2 = require("fs");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).js
new file mode 100644
index 0000000000000..1e97293cca863
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).js
@@ -0,0 +1,68 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts] ////
+
+//// [index.js]
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [index.js]
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [file.js]
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const fs = require("fs");
+fs.readFile;
+exports.fs2 = require("fs");
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+// esm format file
+const fs = __require("fs");
+fs.readFile;
+const fs2 = __require("fs");
+export { fs2 };
+//// [file.js]
+import { createRequire as _createRequire_1 } from "module";
+const __require_1 = _createRequire_1(import.meta.url);
+// esm format file
+const __require = null;
+const _createRequire = null;
+const fs = __require_1("fs");
+fs.readFile;
+const fs2 = __require_1("fs");
+export { fs2 };
+
+
+//// [index.d.ts]
+/// <reference path="../../tests/cases/conformance/node/allowJs/types.d.ts" />
+import fs2 = require("fs");
+//// [index.d.ts]
+/// <reference path="../tests/cases/conformance/node/allowJs/types.d.ts" />
+import fs2 = require("fs");
+//// [file.d.ts]
+/// <reference path="../tests/cases/conformance/node/allowJs/types.d.ts" />
+import fs2 = require("fs");
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).symbols
new file mode 100644
index 0000000000000..11b3047ebcd76
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).symbols
@@ -0,0 +1,43 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.js, 2, 12))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.js, 2, 12))
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+const __require = null;
+>__require : Symbol(__require, Decl(file.js, 1, 5))
+
+const _createRequire = null;
+>_createRequire : Symbol(_createRequire, Decl(file.js, 2, 5))
+
+import fs = require("fs");
+>fs : Symbol(fs, Decl(file.js, 2, 28))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(file.js, 2, 28))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(file.js, 4, 12))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).types
new file mode 100644
index 0000000000000..2720b1f1b7dc3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).types
@@ -0,0 +1,51 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/allowJs/file.js ===
+// esm format file
+const __require = null;
+>__require : any
+>null : null
+
+const _createRequire = null;
+>_createRequire : any
+>null : null
+
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).errors.txt
new file mode 100644
index 0000000000000..b75c1c1e6f563
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).errors.txt
@@ -0,0 +1,36 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ====
+    // cjs format file
+    import {default as _fs} from "fs";
+            ~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    _fs.readFile;
+    import * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    fs.readFile;
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import {default as _fs} from "fs";
+    _fs.readFile;
+    import * as fs from "fs";
+    fs.readFile;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).js
new file mode 100644
index 0000000000000..4001d6f471cf5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).js
@@ -0,0 +1,52 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts] ////
+
+//// [index.js]
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [index.js]
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const tslib_1 = require("tslib");
+// cjs format file
+const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
+fs_1.default.readFile;
+const fs = (0, tslib_1.__importStar)(require("fs"));
+fs.readFile;
+//// [index.js]
+// esm format file
+import { default as _fs } from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).symbols
new file mode 100644
index 0000000000000..3822c3fa16d4c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).symbols
@@ -0,0 +1,40 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).types
new file mode 100644
index 0000000000000..0b27106eae059
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).types
@@ -0,0 +1,48 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..b75c1c1e6f563
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).errors.txt
@@ -0,0 +1,36 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ====
+    // cjs format file
+    import {default as _fs} from "fs";
+            ~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    _fs.readFile;
+    import * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    fs.readFile;
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import {default as _fs} from "fs";
+    _fs.readFile;
+    import * as fs from "fs";
+    fs.readFile;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).js
new file mode 100644
index 0000000000000..4001d6f471cf5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).js
@@ -0,0 +1,52 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts] ////
+
+//// [index.js]
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [index.js]
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const tslib_1 = require("tslib");
+// cjs format file
+const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
+fs_1.default.readFile;
+const fs = (0, tslib_1.__importStar)(require("fs"));
+fs.readFile;
+//// [index.js]
+// esm format file
+import { default as _fs } from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).symbols
new file mode 100644
index 0000000000000..3822c3fa16d4c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).symbols
@@ -0,0 +1,40 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.js, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).types
new file mode 100644
index 0000000000000..0b27106eae059
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).types
@@ -0,0 +1,48 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).errors.txt
new file mode 100644
index 0000000000000..e07871859dbc2
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).errors.txt
@@ -0,0 +1,32 @@
+tests/cases/conformance/node/allowJs/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/allowJs/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    export * from "fs";
+    ~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    export * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    export * from "fs";
+    export * as fs from "fs";
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).js
new file mode 100644
index 0000000000000..e23bc86265999
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).js
@@ -0,0 +1,48 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts] ////
+
+//// [index.ts]
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+//// [index.js]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.fs = void 0;
+const tslib_1 = require("tslib");
+// cjs format file
+(0, tslib_1.__exportStar)(require("fs"), exports);
+exports.fs = (0, tslib_1.__importStar)(require("fs"));
+//// [index.js]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+
+
+//// [index.d.ts]
+export * from "fs";
+export * as fs from "fs";
+//// [index.d.ts]
+/// <reference path="../tests/cases/conformance/node/allowJs/types.d.ts" />
+export * from "fs";
+export * as fs from "fs";
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).symbols
new file mode 100644
index 0000000000000..46c533db2dc75
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 2, 6))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.js, 2, 6))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).types
new file mode 100644
index 0000000000000..bbcb3d2993101
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).types
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..e07871859dbc2
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).errors.txt
@@ -0,0 +1,32 @@
+tests/cases/conformance/node/allowJs/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/allowJs/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    export * from "fs";
+    ~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    export * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    export * from "fs";
+    export * as fs from "fs";
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).js
new file mode 100644
index 0000000000000..e23bc86265999
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).js
@@ -0,0 +1,48 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts] ////
+
+//// [index.ts]
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+//// [index.js]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.fs = void 0;
+const tslib_1 = require("tslib");
+// cjs format file
+(0, tslib_1.__exportStar)(require("fs"), exports);
+exports.fs = (0, tslib_1.__importStar)(require("fs"));
+//// [index.js]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+
+
+//// [index.d.ts]
+export * from "fs";
+export * as fs from "fs";
+//// [index.d.ts]
+/// <reference path="../tests/cases/conformance/node/allowJs/types.d.ts" />
+export * from "fs";
+export * as fs from "fs";
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).symbols
new file mode 100644
index 0000000000000..46c533db2dc75
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 2, 6))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.js, 2, 6))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).types
new file mode 100644
index 0000000000000..bbcb3d2993101
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).types
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).errors.txt
new file mode 100644
index 0000000000000..cd8457101bb44
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).errors.txt
@@ -0,0 +1,31 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ====
+    // cjs format file
+    export {default} from "fs";
+            ~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    export {default as foo} from "fs";
+    export {bar as baz} from "fs";
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    export {default} from "fs";
+    export {default as foo} from "fs";
+    export {bar as baz} from "fs";
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).js
new file mode 100644
index 0000000000000..8e07883b7276b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).js
@@ -0,0 +1,54 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts] ////
+
+//// [index.js]
+// cjs format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+//// [index.js]
+// esm format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.baz = exports.foo = exports.default = void 0;
+// cjs format file
+var fs_1 = require("fs");
+Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
+var fs_2 = require("fs");
+Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(fs_2).default; } });
+var fs_3 = require("fs");
+Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return fs_3.bar; } });
+//// [index.js]
+// esm format file
+export { default } from "fs";
+export { default as foo } from "fs";
+export { bar as baz } from "fs";
+
+
+//// [index.d.ts]
+export { default, default as foo, bar as baz } from "fs";
+//// [index.d.ts]
+export { default, default as foo, bar as baz } from "fs";
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).symbols
new file mode 100644
index 0000000000000..767be993d649b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).symbols
@@ -0,0 +1,36 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.js, 1, 8))
+
+export {default as foo} from "fs";
+>default : Symbol("fs", Decl(types.d.ts, 0, 0))
+>foo : Symbol(foo, Decl(index.js, 2, 8))
+
+export {bar as baz} from "fs";
+>bar : Symbol("fs", Decl(types.d.ts, 0, 0))
+>baz : Symbol(baz, Decl(index.js, 3, 8))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.js, 1, 8))
+
+export {default as foo} from "fs";
+>default : Symbol("fs", Decl(types.d.ts, 0, 0))
+>foo : Symbol(foo, Decl(index.js, 2, 8))
+
+export {bar as baz} from "fs";
+>bar : Symbol("fs", Decl(types.d.ts, 0, 0))
+>baz : Symbol(baz, Decl(index.js, 3, 8))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).types
new file mode 100644
index 0000000000000..b07207ec08de4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).types
@@ -0,0 +1,36 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export {default} from "fs";
+>default : any
+
+export {default as foo} from "fs";
+>default : any
+>foo : any
+
+export {bar as baz} from "fs";
+>bar : any
+>baz : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export {default} from "fs";
+>default : any
+
+export {default as foo} from "fs";
+>default : any
+>foo : any
+
+export {bar as baz} from "fs";
+>bar : any
+>baz : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..cd8457101bb44
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).errors.txt
@@ -0,0 +1,31 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ====
+    // cjs format file
+    export {default} from "fs";
+            ~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    export {default as foo} from "fs";
+    export {bar as baz} from "fs";
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    export {default} from "fs";
+    export {default as foo} from "fs";
+    export {bar as baz} from "fs";
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).js
new file mode 100644
index 0000000000000..8e07883b7276b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).js
@@ -0,0 +1,54 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts] ////
+
+//// [index.js]
+// cjs format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+//// [index.js]
+// esm format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.baz = exports.foo = exports.default = void 0;
+// cjs format file
+var fs_1 = require("fs");
+Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
+var fs_2 = require("fs");
+Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(fs_2).default; } });
+var fs_3 = require("fs");
+Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return fs_3.bar; } });
+//// [index.js]
+// esm format file
+export { default } from "fs";
+export { default as foo } from "fs";
+export { bar as baz } from "fs";
+
+
+//// [index.d.ts]
+export { default, default as foo, bar as baz } from "fs";
+//// [index.d.ts]
+export { default, default as foo, bar as baz } from "fs";
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).symbols
new file mode 100644
index 0000000000000..767be993d649b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).symbols
@@ -0,0 +1,36 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.js, 1, 8))
+
+export {default as foo} from "fs";
+>default : Symbol("fs", Decl(types.d.ts, 0, 0))
+>foo : Symbol(foo, Decl(index.js, 2, 8))
+
+export {bar as baz} from "fs";
+>bar : Symbol("fs", Decl(types.d.ts, 0, 0))
+>baz : Symbol(baz, Decl(index.js, 3, 8))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.js, 1, 8))
+
+export {default as foo} from "fs";
+>default : Symbol("fs", Decl(types.d.ts, 0, 0))
+>foo : Symbol(foo, Decl(index.js, 2, 8))
+
+export {bar as baz} from "fs";
+>bar : Symbol("fs", Decl(types.d.ts, 0, 0))
+>baz : Symbol(baz, Decl(index.js, 3, 8))
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).types
new file mode 100644
index 0000000000000..b07207ec08de4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).types
@@ -0,0 +1,36 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+export {default} from "fs";
+>default : any
+
+export {default as foo} from "fs";
+>default : any
+>foo : any
+
+export {bar as baz} from "fs";
+>bar : any
+>baz : any
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+export {default} from "fs";
+>default : any
+
+export {default as foo} from "fs";
+>default : any
+>foo : any
+
+export {bar as baz} from "fs";
+>bar : any
+>baz : any
+
+=== tests/cases/conformance/node/allowJs/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).errors.txt
new file mode 100644
index 0000000000000..7f8ce4691522c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).errors.txt
@@ -0,0 +1,23 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ====
+    // cjs format file
+    const x = import.meta.url;
+              ~~~~~~~~~~~
+!!! error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    const x = import.meta.url;
+    export {x};
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).js
new file mode 100644
index 0000000000000..7e6d01b7daf2a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).js
@@ -0,0 +1,38 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts] ////
+
+//// [index.js]
+// cjs format file
+const x = import.meta.url;
+export {x};
+//// [index.js]
+// esm format file
+const x = import.meta.url;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = import.meta.url;
+exports.x = x;
+//// [index.js]
+// esm format file
+const x = import.meta.url;
+export { x };
+
+
+//// [index.d.ts]
+export const x: string;
+//// [index.d.ts]
+export const x: string;
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).symbols
new file mode 100644
index 0000000000000..02586281af41a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.js, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.js, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).types
new file mode 100644
index 0000000000000..de6d0c96059f4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..7f8ce4691522c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).errors.txt
@@ -0,0 +1,23 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ====
+    // cjs format file
+    const x = import.meta.url;
+              ~~~~~~~~~~~
+!!! error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+    export {x};
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    const x = import.meta.url;
+    export {x};
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).js
new file mode 100644
index 0000000000000..7e6d01b7daf2a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).js
@@ -0,0 +1,38 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts] ////
+
+//// [index.js]
+// cjs format file
+const x = import.meta.url;
+export {x};
+//// [index.js]
+// esm format file
+const x = import.meta.url;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = import.meta.url;
+exports.x = x;
+//// [index.js]
+// esm format file
+const x = import.meta.url;
+export { x };
+
+
+//// [index.d.ts]
+export const x: string;
+//// [index.d.ts]
+export const x: string;
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).symbols
new file mode 100644
index 0000000000000..02586281af41a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.js, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.js, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).types
new file mode 100644
index 0000000000000..de6d0c96059f4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).errors.txt
new file mode 100644
index 0000000000000..e6f4b3ce2eb2b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).errors.txt
@@ -0,0 +1,107 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.cjs (3 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+                          ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).js
new file mode 100644
index 0000000000000..dfb76ab777867
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).js
@@ -0,0 +1,161 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/cjs"));
+const mjsi = __importStar(require("inner/mjs"));
+const typei = __importStar(require("inner"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).symbols
new file mode 100644
index 0000000000000..67cf88b744a92
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).symbols
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).types
new file mode 100644
index 0000000000000..a4138d3738e89
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node12).types
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..e6f4b3ce2eb2b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt
@@ -0,0 +1,107 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.cjs (3 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+                          ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).js
new file mode 100644
index 0000000000000..dfb76ab777867
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).js
@@ -0,0 +1,161 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/cjs"));
+const mjsi = __importStar(require("inner/mjs"));
+const typei = __importStar(require("inner"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..67cf88b744a92
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).symbols
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.js, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.js, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.js, 9, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mjs, 9, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cjs, 9, 6))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).types
new file mode 100644
index 0000000000000..a4138d3738e89
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).types
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).errors.txt
new file mode 100644
index 0000000000000..261be58f1a221
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).errors.txt
@@ -0,0 +1,44 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/allowJs/index.cjs (2 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+                         ~~~~~~
+!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js",
+        "imports": {
+            "#cjs": "./index.cjs",
+            "#mjs": "./index.mjs",
+            "#type": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).js
new file mode 100644
index 0000000000000..c6fa45d5bb7a3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).js
@@ -0,0 +1,92 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.mjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js",
+    "imports": {
+        "#cjs": "./index.cjs",
+        "#mjs": "./index.mjs",
+        "#type": "./index.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.mjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const cjs = __importStar(require("#cjs"));
+const mjs = __importStar(require("#mjs"));
+const type = __importStar(require("#type"));
+cjs;
+mjs;
+type;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).symbols
new file mode 100644
index 0000000000000..196837bc0bcf1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).symbols
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).types
new file mode 100644
index 0000000000000..6387f04fcb693
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node12).types
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..261be58f1a221
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt
@@ -0,0 +1,44 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/allowJs/index.cjs (2 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+                         ~~~~~~
+!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js",
+        "imports": {
+            "#cjs": "./index.cjs",
+            "#mjs": "./index.mjs",
+            "#type": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).js
new file mode 100644
index 0000000000000..c6fa45d5bb7a3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).js
@@ -0,0 +1,92 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.mjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js",
+    "imports": {
+        "#cjs": "./index.cjs",
+        "#mjs": "./index.mjs",
+        "#type": "./index.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.mjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const cjs = __importStar(require("#cjs"));
+const mjs = __importStar(require("#mjs"));
+const type = __importStar(require("#type"));
+cjs;
+mjs;
+type;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).symbols
new file mode 100644
index 0000000000000..196837bc0bcf1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).symbols
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.js, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.js, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cjs, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cjs, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cjs, 3, 6))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).types
new file mode 100644
index 0000000000000..6387f04fcb693
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).types
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).errors.txt
new file mode 100644
index 0000000000000..0f1999477226b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).errors.txt
@@ -0,0 +1,78 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+                          ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*": "./*.cjs",
+            "./mjs/*": "./*.mjs",
+            "./js/*": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).js
new file mode 100644
index 0000000000000..b2ef85d6e5f97
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*": "./*.cjs",
+        "./mjs/*": "./*.mjs",
+        "./js/*": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index"));
+const mjsi = __importStar(require("inner/mjs/index"));
+const typei = __importStar(require("inner/js/index"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).symbols
new file mode 100644
index 0000000000000..3b5ca0ad0c6c7
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).types
new file mode 100644
index 0000000000000..65f2fc46d87f6
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node12).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : any
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof mjs
+
+import * as type from "inner/js/index";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..0f1999477226b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).errors.txt
@@ -0,0 +1,78 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+                          ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*": "./*.cjs",
+            "./mjs/*": "./*.mjs",
+            "./js/*": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).js
new file mode 100644
index 0000000000000..b2ef85d6e5f97
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*": "./*.cjs",
+        "./mjs/*": "./*.mjs",
+        "./js/*": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index"));
+const mjsi = __importStar(require("inner/mjs/index"));
+const typei = __importStar(require("inner/js/index"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..3b5ca0ad0c6c7
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).types
new file mode 100644
index 0000000000000..65f2fc46d87f6
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : any
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof mjs
+
+import * as type from "inner/js/index";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).errors.txt
new file mode 100644
index 0000000000000..2036308bb9b9f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).errors.txt
@@ -0,0 +1,120 @@
+tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.cjs(4,24): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(2,23): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(3,23): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.js(4,24): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(2,23): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(3,23): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/index.mjs(4,24): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(2,22): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(4,23): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,22): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(3,22): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(4,23): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (3 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as typei from "inner/js/index.js";
+                           ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.mjs (3 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as typei from "inner/js/index.js";
+                           ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.cjs (3 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index.cjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as typei from "inner/js/index.js";
+                           ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (3 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as type from "inner/js/index.js";
+                          ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (3 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index.cjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as type from "inner/js/index.js";
+                          ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (3 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as type from "inner/js/index.js";
+                          ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*.cjs": "./*.cjs",
+            "./mjs/*.mjs": "./*.mjs",
+            "./js/*.js": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).js
new file mode 100644
index 0000000000000..9627f89af2bb1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*.cjs": "./*.cjs",
+        "./mjs/*.mjs": "./*.mjs",
+        "./js/*.js": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index.cjs"));
+const mjsi = __importStar(require("inner/mjs/index.mjs"));
+const typei = __importStar(require("inner/js/index.js"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).symbols
new file mode 100644
index 0000000000000..870a2298deadd
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).types
new file mode 100644
index 0000000000000..c35a6bdbf60f5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node12).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : any
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : any
+
+import * as typei from "inner/js/index.js";
+>typei : any
+
+cjsi;
+>cjsi : any
+
+mjsi;
+>mjsi : any
+
+typei;
+>typei : any
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : any
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : any
+
+import * as typei from "inner/js/index.js";
+>typei : any
+
+cjsi;
+>cjsi : any
+
+mjsi;
+>mjsi : any
+
+typei;
+>typei : any
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : any
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : any
+
+import * as typei from "inner/js/index.js";
+>typei : any
+
+cjsi;
+>cjsi : any
+
+mjsi;
+>mjsi : any
+
+typei;
+>typei : any
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : any
+
+import * as type from "inner/js/index.js";
+>type : any
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : any
+
+export { type };
+>type : any
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : any
+
+import * as type from "inner/js/index.js";
+>type : any
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : any
+
+export { type };
+>type : any
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : any
+
+import * as type from "inner/js/index.js";
+>type : any
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : any
+
+export { type };
+>type : any
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..b989016f16abe
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).errors.txt
@@ -0,0 +1,78 @@
+tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+    import * as mjsi from "inner/mjs/index.mjs";
+    import * as typei from "inner/js/index.js";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+    import * as mjsi from "inner/mjs/index.mjs";
+    import * as typei from "inner/js/index.js";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index.cjs";
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner/js/index.js";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index.js";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index.cjs";
+    import * as mjs from "inner/mjs/index.mjs";
+    import * as type from "inner/js/index.js";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index.js";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*.cjs": "./*.cjs",
+            "./mjs/*.mjs": "./*.mjs",
+            "./js/*.js": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).js
new file mode 100644
index 0000000000000..9627f89af2bb1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts] ////
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*.cjs": "./*.cjs",
+        "./mjs/*.mjs": "./*.mjs",
+        "./js/*.js": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index.cjs"));
+const mjsi = __importStar(require("inner/mjs/index.mjs"));
+const typei = __importStar(require("inner/js/index.js"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).symbols
new file mode 100644
index 0000000000000..572b5ddd1100e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.js, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cjs, 3, 6))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).types
new file mode 100644
index 0000000000000..d36dd358d8bb3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index.js";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.mjs ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index.js";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/index.cjs ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index.js";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : typeof mjs
+
+import * as type from "inner/js/index.js";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index.js";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index.js";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).errors.txt
new file mode 100644
index 0000000000000..c722192e6704e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).errors.txt
@@ -0,0 +1,55 @@
+tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ====
+    // cjs format file
+    import {h} from "../index.js";
+                    ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import mod = require("../index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f as _f} from "./index.js";
+    import mod2 = require("./index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    export async function f() {
+        const mod3 = await import ("../index.js");
+        const mod4 = await import ("./index.js");
+        h();
+    }
+==== tests/cases/conformance/node/allowJs/index.js (3 errors) ====
+    // esm format file
+    import {h as _h} from "./index.js";
+    import mod = require("./index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f} from "./subfolder/index.js";
+    import mod2 = require("./subfolder/index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    export async function h() {
+        const mod3 = await import ("./index.js");
+        const mod4 = await import ("./subfolder/index.js");
+        f();
+    }
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).js
new file mode 100644
index 0000000000000..a02ef88f1e524
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).js
@@ -0,0 +1,60 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts] ////
+
+//// [index.js]
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+    const mod3 = await import ("../index.js");
+    const mod4 = await import ("./index.js");
+    h();
+}
+//// [index.js]
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+    const mod3 = await import ("./index.js");
+    const mod4 = await import ("./subfolder/index.js");
+    f();
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+import { f } from "./subfolder/index.js";
+export async function h() {
+    const mod3 = await import("./index.js");
+    const mod4 = await import("./subfolder/index.js");
+    f();
+}
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = void 0;
+// cjs format file
+const index_js_1 = require("../index.js");
+async function f() {
+    const mod3 = await import("../index.js");
+    const mod4 = await import("./index.js");
+    (0, index_js_1.h)();
+}
+exports.f = f;
+
+
+//// [index.d.ts]
+export function h(): Promise<void>;
+//// [index.d.ts]
+export function f(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).symbols
new file mode 100644
index 0000000000000..8cbba01b82f62
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).symbols
@@ -0,0 +1,58 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {h} from "../index.js";
+>h : Symbol(h, Decl(index.js, 1, 8))
+
+import mod = require("../index.js");
+>mod : Symbol(mod, Decl(index.js, 1, 30))
+
+import {f as _f} from "./index.js";
+>f : Symbol(f, Decl(index.js, 4, 36))
+>_f : Symbol(_f, Decl(index.js, 3, 8))
+
+import mod2 = require("./index.js");
+>mod2 : Symbol(mod2, Decl(index.js, 3, 35))
+
+export async function f() {
+>f : Symbol(f, Decl(index.js, 4, 36))
+
+    const mod3 = await import ("../index.js");
+>mod3 : Symbol(mod3, Decl(index.js, 6, 9))
+>"../index.js" : Symbol(mod, Decl(index.js, 0, 0))
+
+    const mod4 = await import ("./index.js");
+>mod4 : Symbol(mod4, Decl(index.js, 7, 9))
+>"./index.js" : Symbol(mod2, Decl(index.js, 0, 0))
+
+    h();
+>h : Symbol(h, Decl(index.js, 1, 8))
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : Symbol(h, Decl(index.js, 4, 46))
+>_h : Symbol(_h, Decl(index.js, 1, 8))
+
+import mod = require("./index.js");
+>mod : Symbol(mod, Decl(index.js, 1, 35))
+
+import {f} from "./subfolder/index.js";
+>f : Symbol(f, Decl(index.js, 3, 8))
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : Symbol(mod2, Decl(index.js, 3, 39))
+
+export async function h() {
+>h : Symbol(h, Decl(index.js, 4, 46))
+
+    const mod3 = await import ("./index.js");
+>mod3 : Symbol(mod3, Decl(index.js, 6, 9))
+>"./index.js" : Symbol(mod, Decl(index.js, 0, 0))
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : Symbol(mod4, Decl(index.js, 7, 9))
+>"./subfolder/index.js" : Symbol(mod2, Decl(index.js, 0, 0))
+
+    f();
+>f : Symbol(f, Decl(index.js, 3, 8))
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).types
new file mode 100644
index 0000000000000..77061e385af3a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).types
@@ -0,0 +1,68 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {h} from "../index.js";
+>h : () => Promise<void>
+
+import mod = require("../index.js");
+>mod : typeof mod
+
+import {f as _f} from "./index.js";
+>f : () => Promise<void>
+>_f : () => Promise<void>
+
+import mod2 = require("./index.js");
+>mod2 : typeof mod2
+
+export async function f() {
+>f : () => Promise<void>
+
+    const mod3 = await import ("../index.js");
+>mod3 : typeof mod
+>await import ("../index.js") : typeof mod
+>import ("../index.js") : Promise<typeof mod>
+>"../index.js" : "../index.js"
+
+    const mod4 = await import ("./index.js");
+>mod4 : typeof mod2
+>await import ("./index.js") : typeof mod2
+>import ("./index.js") : Promise<typeof mod2>
+>"./index.js" : "./index.js"
+
+    h();
+>h() : Promise<void>
+>h : () => Promise<void>
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : () => Promise<void>
+>_h : () => Promise<void>
+
+import mod = require("./index.js");
+>mod : typeof mod
+
+import {f} from "./subfolder/index.js";
+>f : () => Promise<void>
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : typeof mod2
+
+export async function h() {
+>h : () => Promise<void>
+
+    const mod3 = await import ("./index.js");
+>mod3 : typeof mod
+>await import ("./index.js") : typeof mod
+>import ("./index.js") : Promise<typeof mod>
+>"./index.js" : "./index.js"
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : typeof mod2
+>await import ("./subfolder/index.js") : typeof mod2
+>import ("./subfolder/index.js") : Promise<typeof mod2>
+>"./subfolder/index.js" : "./subfolder/index.js"
+
+    f();
+>f() : Promise<void>
+>f : () => Promise<void>
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..c722192e6704e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt
@@ -0,0 +1,55 @@
+tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ====
+    // cjs format file
+    import {h} from "../index.js";
+                    ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import mod = require("../index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f as _f} from "./index.js";
+    import mod2 = require("./index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    export async function f() {
+        const mod3 = await import ("../index.js");
+        const mod4 = await import ("./index.js");
+        h();
+    }
+==== tests/cases/conformance/node/allowJs/index.js (3 errors) ====
+    // esm format file
+    import {h as _h} from "./index.js";
+    import mod = require("./index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+                         ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f} from "./subfolder/index.js";
+    import mod2 = require("./subfolder/index.js");
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS8002: 'import ... =' can only be used in TypeScript files.
+    export async function h() {
+        const mod3 = await import ("./index.js");
+        const mod4 = await import ("./subfolder/index.js");
+        f();
+    }
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).js
new file mode 100644
index 0000000000000..a02ef88f1e524
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).js
@@ -0,0 +1,60 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts] ////
+
+//// [index.js]
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+    const mod3 = await import ("../index.js");
+    const mod4 = await import ("./index.js");
+    h();
+}
+//// [index.js]
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+    const mod3 = await import ("./index.js");
+    const mod4 = await import ("./subfolder/index.js");
+    f();
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+import { f } from "./subfolder/index.js";
+export async function h() {
+    const mod3 = await import("./index.js");
+    const mod4 = await import("./subfolder/index.js");
+    f();
+}
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = void 0;
+// cjs format file
+const index_js_1 = require("../index.js");
+async function f() {
+    const mod3 = await import("../index.js");
+    const mod4 = await import("./index.js");
+    (0, index_js_1.h)();
+}
+exports.f = f;
+
+
+//// [index.d.ts]
+export function h(): Promise<void>;
+//// [index.d.ts]
+export function f(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).symbols
new file mode 100644
index 0000000000000..8cbba01b82f62
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).symbols
@@ -0,0 +1,58 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {h} from "../index.js";
+>h : Symbol(h, Decl(index.js, 1, 8))
+
+import mod = require("../index.js");
+>mod : Symbol(mod, Decl(index.js, 1, 30))
+
+import {f as _f} from "./index.js";
+>f : Symbol(f, Decl(index.js, 4, 36))
+>_f : Symbol(_f, Decl(index.js, 3, 8))
+
+import mod2 = require("./index.js");
+>mod2 : Symbol(mod2, Decl(index.js, 3, 35))
+
+export async function f() {
+>f : Symbol(f, Decl(index.js, 4, 36))
+
+    const mod3 = await import ("../index.js");
+>mod3 : Symbol(mod3, Decl(index.js, 6, 9))
+>"../index.js" : Symbol(mod, Decl(index.js, 0, 0))
+
+    const mod4 = await import ("./index.js");
+>mod4 : Symbol(mod4, Decl(index.js, 7, 9))
+>"./index.js" : Symbol(mod2, Decl(index.js, 0, 0))
+
+    h();
+>h : Symbol(h, Decl(index.js, 1, 8))
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : Symbol(h, Decl(index.js, 4, 46))
+>_h : Symbol(_h, Decl(index.js, 1, 8))
+
+import mod = require("./index.js");
+>mod : Symbol(mod, Decl(index.js, 1, 35))
+
+import {f} from "./subfolder/index.js";
+>f : Symbol(f, Decl(index.js, 3, 8))
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : Symbol(mod2, Decl(index.js, 3, 39))
+
+export async function h() {
+>h : Symbol(h, Decl(index.js, 4, 46))
+
+    const mod3 = await import ("./index.js");
+>mod3 : Symbol(mod3, Decl(index.js, 6, 9))
+>"./index.js" : Symbol(mod, Decl(index.js, 0, 0))
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : Symbol(mod4, Decl(index.js, 7, 9))
+>"./subfolder/index.js" : Symbol(mod2, Decl(index.js, 0, 0))
+
+    f();
+>f : Symbol(f, Decl(index.js, 3, 8))
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).types
new file mode 100644
index 0000000000000..77061e385af3a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).types
@@ -0,0 +1,68 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+import {h} from "../index.js";
+>h : () => Promise<void>
+
+import mod = require("../index.js");
+>mod : typeof mod
+
+import {f as _f} from "./index.js";
+>f : () => Promise<void>
+>_f : () => Promise<void>
+
+import mod2 = require("./index.js");
+>mod2 : typeof mod2
+
+export async function f() {
+>f : () => Promise<void>
+
+    const mod3 = await import ("../index.js");
+>mod3 : typeof mod
+>await import ("../index.js") : typeof mod
+>import ("../index.js") : Promise<typeof mod>
+>"../index.js" : "../index.js"
+
+    const mod4 = await import ("./index.js");
+>mod4 : typeof mod2
+>await import ("./index.js") : typeof mod2
+>import ("./index.js") : Promise<typeof mod2>
+>"./index.js" : "./index.js"
+
+    h();
+>h() : Promise<void>
+>h : () => Promise<void>
+}
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : () => Promise<void>
+>_h : () => Promise<void>
+
+import mod = require("./index.js");
+>mod : typeof mod
+
+import {f} from "./subfolder/index.js";
+>f : () => Promise<void>
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : typeof mod2
+
+export async function h() {
+>h : () => Promise<void>
+
+    const mod3 = await import ("./index.js");
+>mod3 : typeof mod
+>await import ("./index.js") : typeof mod
+>import ("./index.js") : Promise<typeof mod>
+>"./index.js" : "./index.js"
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : typeof mod2
+>await import ("./subfolder/index.js") : typeof mod2
+>import ("./subfolder/index.js") : Promise<typeof mod2>
+>"./subfolder/index.js" : "./subfolder/index.js"
+
+    f();
+>f() : Promise<void>
+>f : () => Promise<void>
+}
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).errors.txt
new file mode 100644
index 0000000000000..eff86eab7e9d6
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).errors.txt
@@ -0,0 +1,34 @@
+tests/cases/conformance/node/allowJs/index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/allowJs/index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ====
+    // cjs format file
+    const x = await 1;
+              ~~~~~
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+    export {x};
+    for await (const y of []) {}
+        ~~~~~
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+==== tests/cases/conformance/node/allowJs/index.js (2 errors) ====
+    // esm format file
+    const x = await 1;
+              ~~~~~
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+    export {x};
+    for await (const y of []) {}
+        ~~~~~
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).js
new file mode 100644
index 0000000000000..354fe725f0960
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).js
@@ -0,0 +1,42 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts] ////
+
+//// [index.js]
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [index.js]
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = await 1;
+exports.x = x;
+for await (const y of []) { }
+//// [index.js]
+// esm format file
+const x = await 1;
+export { x };
+for await (const y of []) { }
+
+
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.ts]
+export const x: 1;
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).symbols
new file mode 100644
index 0000000000000..09ad69c019c70
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = await 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.js, 3, 16))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = await 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.js, 3, 16))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).types
new file mode 100644
index 0000000000000..b50bdd2c107e5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).types
@@ -0,0 +1,28 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..f2b3347f94df8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt
@@ -0,0 +1,28 @@
+tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/allowJs/subfolder/index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+
+
+==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ====
+    // cjs format file
+    const x = await 1;
+              ~~~~~
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+    export {x};
+    for await (const y of []) {}
+        ~~~~~
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+==== tests/cases/conformance/node/allowJs/index.js (0 errors) ====
+    // esm format file
+    const x = await 1;
+    export {x};
+    for await (const y of []) {}
+==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).js
new file mode 100644
index 0000000000000..354fe725f0960
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).js
@@ -0,0 +1,42 @@
+//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts] ////
+
+//// [index.js]
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [index.js]
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = await 1;
+exports.x = x;
+for await (const y of []) { }
+//// [index.js]
+// esm format file
+const x = await 1;
+export { x };
+for await (const y of []) { }
+
+
+//// [index.d.ts]
+export const x: 1;
+//// [index.d.ts]
+export const x: 1;
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).symbols
new file mode 100644
index 0000000000000..09ad69c019c70
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = await 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.js, 3, 16))
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = await 1;
+>x : Symbol(x, Decl(index.js, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.js, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.js, 3, 16))
+
diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).types
new file mode 100644
index 0000000000000..b50bdd2c107e5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).types
@@ -0,0 +1,28 @@
+=== tests/cases/conformance/node/allowJs/subfolder/index.js ===
+// cjs format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
+=== tests/cases/conformance/node/allowJs/index.js ===
+// esm format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).errors.txt
new file mode 100644
index 0000000000000..7397e1e1dbd27
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).errors.txt
@@ -0,0 +1,135 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/index.cts (2 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.cjsSource;
+    mjsi.cjsSource;
+    typei.implicitCjsSource;
+    ts.cjsSource;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const implicitCjsSource = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (1 errors) ====
+    // esm format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const mjsSource = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (0 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const cjsSource = true;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./a": {
+                "require": "./index.cjs",
+                "node": "./index.mjs"
+            },
+            "./b": {
+                "import": "./index.mjs",
+                "node": "./index.cjs"
+            },
+            ".": {
+                "import": "./index.mjs",
+                "node": "./index.js"
+            },
+            "./types": {
+                "types": {
+                    "import": "./index.d.mts",
+                    "require": "./index.d.cts",
+                },
+                "node": {
+                    "import": "./index.mjs",
+                    "require": "./index.cjs"
+                }
+            }
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).js b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).js
new file mode 100644
index 0000000000000..cd984941c2c9b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).js
@@ -0,0 +1,201 @@
+//// [tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.mts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cts]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./a": {
+            "require": "./index.cjs",
+            "node": "./index.mjs"
+        },
+        "./b": {
+            "import": "./index.mjs",
+            "node": "./index.cjs"
+        },
+        ".": {
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+        "./types": {
+            "types": {
+                "import": "./index.d.mts",
+                "require": "./index.d.cts",
+            },
+            "node": {
+                "import": "./index.mjs",
+                "require": "./index.cjs"
+            }
+        }
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/a"));
+const mjsi = __importStar(require("inner/b"));
+const typei = __importStar(require("inner"));
+const ts = __importStar(require("inner/types"));
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+
+
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).symbols b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).symbols
new file mode 100644
index 0000000000000..88fdfed4eaaea
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).symbols
@@ -0,0 +1,243 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.ts, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.ts, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.mts, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.mts, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.cts, 10, 6))
+
+cjsi.cjsSource;
+>cjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+mjsi.cjsSource;
+>mjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+>implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+ts.cjsSource;
+>ts.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>ts : Symbol(ts, Decl(index.cts, 10, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.ts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.type.cjs, Decl(index.d.ts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.type.mjs, Decl(index.d.ts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type.type, Decl(index.d.ts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.type.ts, Decl(index.d.ts, 8, 8))
+
+export const implicitCjsSource = true;
+>implicitCjsSource : Symbol(mjs.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.mts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs, Decl(index.d.mts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.mjs, Decl(index.d.mts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type, Decl(index.d.mts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.ts, Decl(index.d.mts, 8, 8))
+
+export const mjsSource = true;
+>mjsSource : Symbol(mjs.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.cts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 6, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 7, 8))
+
+export { ts };
+>ts : Symbol(cjs.ts, Decl(index.d.cts, 8, 8))
+
+export const cjsSource = true;
+>cjsSource : Symbol(cjs.cjsSource, Decl(index.d.cts, 9, 12))
+
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).types b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).types
new file mode 100644
index 0000000000000..d46ce7ffa461f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node12).types
@@ -0,0 +1,246 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi.type
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.cjsSource;
+>cjsi.cjsSource : true
+>cjsi : typeof cjsi
+>cjsSource : true
+
+mjsi.cjsSource;
+>mjsi.cjsSource : true
+>mjsi : typeof cjsi
+>cjsSource : true
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : true
+>typei : typeof cjsi.type
+>implicitCjsSource : true
+
+ts.cjsSource;
+>ts.cjsSource : true
+>ts : typeof cjsi
+>cjsSource : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.type
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.type
+
+export { ts };
+>ts : typeof mjs
+
+export const implicitCjsSource = true;
+>implicitCjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs
+
+export { ts };
+>ts : typeof mjs
+
+export const mjsSource = true;
+>mjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : typeof cjs
+
+import * as mjs from "inner/b";
+>mjs : typeof cjs
+
+import * as type from "inner";
+>type : typeof cjs.type
+
+import * as ts from "inner/types";
+>ts : typeof cjs
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs
+
+export { type };
+>type : typeof cjs.type
+
+export { ts };
+>ts : typeof cjs
+
+export const cjsSource = true;
+>cjsSource : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..7397e1e1dbd27
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).errors.txt
@@ -0,0 +1,135 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.mjsSource;
+    mjsi.mjsSource;
+    typei.mjsSource;
+    ts.mjsSource;
+==== tests/cases/conformance/node/index.cts (2 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/a";
+    import * as mjsi from "inner/b";
+    import * as typei from "inner";
+    import * as ts from "inner/types";
+    cjsi.cjsSource;
+    mjsi.cjsSource;
+    typei.implicitCjsSource;
+    ts.cjsSource;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const implicitCjsSource = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (1 errors) ====
+    // esm format file
+    import * as cjs from "inner/a";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const mjsSource = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (0 errors) ====
+    // cjs format file
+    import * as cjs from "inner/a";
+    import * as mjs from "inner/b";
+    import * as type from "inner";
+    import * as ts from "inner/types";
+    export { cjs };
+    export { mjs };
+    export { type };
+    export { ts };
+    export const cjsSource = true;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./a": {
+                "require": "./index.cjs",
+                "node": "./index.mjs"
+            },
+            "./b": {
+                "import": "./index.mjs",
+                "node": "./index.cjs"
+            },
+            ".": {
+                "import": "./index.mjs",
+                "node": "./index.js"
+            },
+            "./types": {
+                "types": {
+                    "import": "./index.d.mts",
+                    "require": "./index.d.cts",
+                },
+                "node": {
+                    "import": "./index.mjs",
+                    "require": "./index.cjs"
+                }
+            }
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).js b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).js
new file mode 100644
index 0000000000000..cd984941c2c9b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).js
@@ -0,0 +1,201 @@
+//// [tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.mts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cts]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./a": {
+            "require": "./index.cjs",
+            "node": "./index.mjs"
+        },
+        "./b": {
+            "import": "./index.mjs",
+            "node": "./index.cjs"
+        },
+        ".": {
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+        "./types": {
+            "types": {
+                "import": "./index.d.mts",
+                "require": "./index.d.cts",
+            },
+            "node": {
+                "import": "./index.mjs",
+                "require": "./index.cjs"
+            }
+        }
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/a"));
+const mjsi = __importStar(require("inner/b"));
+const typei = __importStar(require("inner"));
+const ts = __importStar(require("inner/types"));
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+
+
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..88fdfed4eaaea
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).symbols
@@ -0,0 +1,243 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.ts, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.ts, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.mts, 10, 6))
+
+cjsi.mjsSource;
+>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+mjsi.mjsSource;
+>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+typei.mjsSource;
+>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+ts.mjsSource;
+>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+>ts : Symbol(ts, Decl(index.mts, 10, 6))
+>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+import * as cjsi from "inner/a";
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+import * as mjsi from "inner/b";
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.cts, 10, 6))
+
+cjsi.cjsSource;
+>cjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+mjsi.cjsSource;
+>mjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+>implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+ts.cjsSource;
+>ts.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+>ts : Symbol(ts, Decl(index.cts, 10, 6))
+>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.ts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.type.cjs, Decl(index.d.ts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.type.mjs, Decl(index.d.ts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type.type, Decl(index.d.ts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.type.ts, Decl(index.d.ts, 8, 8))
+
+export const implicitCjsSource = true;
+>implicitCjsSource : Symbol(mjs.type.implicitCjsSource, Decl(index.d.ts, 9, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.mts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs, Decl(index.d.mts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.mjs, Decl(index.d.mts, 6, 8))
+
+export { type };
+>type : Symbol(mjs.type, Decl(index.d.mts, 7, 8))
+
+export { ts };
+>ts : Symbol(mjs.ts, Decl(index.d.mts, 8, 8))
+
+export const mjsSource = true;
+>mjsSource : Symbol(mjs.mjsSource, Decl(index.d.mts, 9, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/b";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+import * as ts from "inner/types";
+>ts : Symbol(ts, Decl(index.d.cts, 4, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 5, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 6, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 7, 8))
+
+export { ts };
+>ts : Symbol(cjs.ts, Decl(index.d.cts, 8, 8))
+
+export const cjsSource = true;
+>cjsSource : Symbol(cjs.cjsSource, Decl(index.d.cts, 9, 12))
+
diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).types b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).types
new file mode 100644
index 0000000000000..d46ce7ffa461f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).types
@@ -0,0 +1,246 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.mjsSource;
+>cjsi.mjsSource : true
+>cjsi : typeof cjsi
+>mjsSource : true
+
+mjsi.mjsSource;
+>mjsi.mjsSource : true
+>mjsi : typeof cjsi
+>mjsSource : true
+
+typei.mjsSource;
+>typei.mjsSource : true
+>typei : typeof cjsi
+>mjsSource : true
+
+ts.mjsSource;
+>ts.mjsSource : true
+>ts : typeof cjsi
+>mjsSource : true
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/a";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/b";
+>mjsi : typeof cjsi
+
+import * as typei from "inner";
+>typei : typeof cjsi.type
+
+import * as ts from "inner/types";
+>ts : typeof cjsi
+
+cjsi.cjsSource;
+>cjsi.cjsSource : true
+>cjsi : typeof cjsi
+>cjsSource : true
+
+mjsi.cjsSource;
+>mjsi.cjsSource : true
+>mjsi : typeof cjsi
+>cjsSource : true
+
+typei.implicitCjsSource;
+>typei.implicitCjsSource : true
+>typei : typeof cjsi.type
+>implicitCjsSource : true
+
+ts.cjsSource;
+>ts.cjsSource : true
+>ts : typeof cjsi
+>cjsSource : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.type
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.type
+
+export { ts };
+>ts : typeof mjs
+
+export const implicitCjsSource = true;
+>implicitCjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/a";
+>cjs : any
+
+import * as mjs from "inner/b";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs
+
+import * as ts from "inner/types";
+>ts : typeof mjs
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs
+
+export { ts };
+>ts : typeof mjs
+
+export const mjsSource = true;
+>mjsSource : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/a";
+>cjs : typeof cjs
+
+import * as mjs from "inner/b";
+>mjs : typeof cjs
+
+import * as type from "inner";
+>type : typeof cjs.type
+
+import * as ts from "inner/types";
+>ts : typeof cjs
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs
+
+export { type };
+>type : typeof cjs.type
+
+export { ts };
+>ts : typeof cjs
+
+export const cjsSource = true;
+>cjsSource : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.js b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.js
new file mode 100644
index 0000000000000..a872cc70f5625
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.js
@@ -0,0 +1,286 @@
+//// [tests/cases/conformance/node/nodeModulesDeclarationEmitDynamicImportWithPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+export {};
+//// [index.mts]
+// esm format file
+export {};
+//// [index.cts]
+// cjs format file
+export {};
+//// [other.ts]
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+//// [other2.ts]
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+//// [other.mts]
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+//// [other2.mts]
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+//// [other.cts]
+// cjs format file, no TLA
+export const a = import("package/cjs");
+export const b = import("package/mjs");
+export const c = import("package");
+export const f = import("inner");
+//// [other2.cts]
+// cjs format file, no TLA
+export const d = import("inner/cjs");
+export const e = import("inner/mjs");
+//// [index.d.ts]
+// cjs format file
+export const cjsMain = true;
+//// [index.d.mts]
+// esm format file
+export const esm = true;
+//// [index.d.cts]
+// cjs format file
+export const cjsNonmain = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+
+//// [index.js]
+export {};
+//// [index.mjs]
+export {};
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+//// [other.js]
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+//// [other2.js]
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+//// [other.mjs]
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+//// [other2.mjs]
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+//// [other.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = exports.c = exports.b = exports.a = void 0;
+// cjs format file, no TLA
+exports.a = import("package/cjs");
+exports.b = import("package/mjs");
+exports.c = import("package");
+exports.f = import("inner");
+//// [other2.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.e = exports.d = void 0;
+// cjs format file, no TLA
+exports.d = import("inner/cjs");
+exports.e = import("inner/mjs");
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
+//// [other.d.ts]
+export declare const a: typeof import("package/cjs");
+export declare const b: typeof import("package/mjs");
+export declare const c: typeof import("package");
+export declare const f: {
+    default: typeof import("inner");
+    cjsMain: true;
+};
+//// [other2.d.ts]
+export declare const d: {
+    default: typeof import("inner/cjs");
+    cjsNonmain: true;
+};
+export declare const e: {
+    default: typeof import("inner/mjs");
+    esm: true;
+};
+//// [other.d.mts]
+export declare const a: typeof import("package/cjs");
+export declare const b: typeof import("package/mjs");
+export declare const c: typeof import("package");
+export declare const f: {
+    default: typeof import("inner");
+    cjsMain: true;
+};
+//// [other2.d.mts]
+export declare const d: {
+    default: typeof import("inner/cjs");
+    cjsNonmain: true;
+};
+export declare const e: {
+    default: typeof import("inner/mjs");
+    esm: true;
+};
+//// [other.d.cts]
+export declare const a: Promise<typeof import("package/cjs")>;
+export declare const b: Promise<typeof import("package/mjs")>;
+export declare const c: Promise<typeof import("package")>;
+export declare const f: Promise<{
+    default: typeof import("inner");
+    cjsMain: true;
+}>;
+//// [other2.d.cts]
+export declare const d: Promise<{
+    default: typeof import("inner/cjs");
+    cjsNonmain: true;
+}>;
+export declare const e: Promise<{
+    default: typeof import("inner/mjs");
+    esm: true;
+}>;
+
+
+//// [DtsFileErrors]
+
+
+tests/cases/conformance/node/other.d.cts(2,47): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/other.d.cts(3,47): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/other2.d.cts(6,28): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.d.ts (0 errors) ====
+    export {};
+    
+==== tests/cases/conformance/node/index.d.mts (0 errors) ====
+    export {};
+    
+==== tests/cases/conformance/node/index.d.cts (0 errors) ====
+    export {};
+    
+==== tests/cases/conformance/node/other.d.ts (0 errors) ====
+    export declare const a: typeof import("package/cjs");
+    export declare const b: typeof import("package/mjs");
+    export declare const c: typeof import("package");
+    export declare const f: {
+        default: typeof import("inner");
+        cjsMain: true;
+    };
+    
+==== tests/cases/conformance/node/other2.d.ts (0 errors) ====
+    export declare const d: {
+        default: typeof import("inner/cjs");
+        cjsNonmain: true;
+    };
+    export declare const e: {
+        default: typeof import("inner/mjs");
+        esm: true;
+    };
+    
+==== tests/cases/conformance/node/other.d.mts (0 errors) ====
+    export declare const a: typeof import("package/cjs");
+    export declare const b: typeof import("package/mjs");
+    export declare const c: typeof import("package");
+    export declare const f: {
+        default: typeof import("inner");
+        cjsMain: true;
+    };
+    
+==== tests/cases/conformance/node/other2.d.mts (0 errors) ====
+    export declare const d: {
+        default: typeof import("inner/cjs");
+        cjsNonmain: true;
+    };
+    export declare const e: {
+        default: typeof import("inner/mjs");
+        esm: true;
+    };
+    
+==== tests/cases/conformance/node/other.d.cts (2 errors) ====
+    export declare const a: Promise<typeof import("package/cjs")>;
+    export declare const b: Promise<typeof import("package/mjs")>;
+                                                  ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    export declare const c: Promise<typeof import("package")>;
+                                                  ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    export declare const f: Promise<{
+        default: typeof import("inner");
+        cjsMain: true;
+    }>;
+    
+==== tests/cases/conformance/node/other2.d.cts (1 errors) ====
+    export declare const d: Promise<{
+        default: typeof import("inner/cjs");
+        cjsNonmain: true;
+    }>;
+    export declare const e: Promise<{
+        default: typeof import("inner/mjs");
+                               ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+        esm: true;
+    }>;
+    
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (0 errors) ====
+    // cjs format file
+    export const cjsMain = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    export const esm = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (0 errors) ====
+    // cjs format file
+    export const cjsNonmain = true;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.symbols b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.symbols
new file mode 100644
index 0000000000000..67841b1be5adf
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.symbols
@@ -0,0 +1,108 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+No type information for this code.export {};
+No type information for this code.=== tests/cases/conformance/node/index.mts ===
+// esm format file
+No type information for this code.export {};
+No type information for this code.=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+No type information for this code.export {};
+No type information for this code.=== tests/cases/conformance/node/other.ts ===
+// esm format file
+export const a = await import("package/cjs");
+>a : Symbol(a, Decl(other.ts, 1, 12))
+>"package/cjs" : Symbol("tests/cases/conformance/node/index", Decl(index.cts, 0, 0))
+
+export const b = await import("package/mjs");
+>b : Symbol(b, Decl(other.ts, 2, 12))
+>"package/mjs" : Symbol("tests/cases/conformance/node/index", Decl(index.mts, 0, 0))
+
+export const c = await import("package");
+>c : Symbol(c, Decl(other.ts, 3, 12))
+>"package" : Symbol("tests/cases/conformance/node/index", Decl(index.ts, 0, 0))
+
+export const f = await import("inner");
+>f : Symbol(f, Decl(other.ts, 4, 12))
+>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0))
+
+=== tests/cases/conformance/node/other2.ts ===
+// esm format file
+export const d = await import("inner/cjs");
+>d : Symbol(d, Decl(other2.ts, 1, 12))
+>"inner/cjs" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.cts, 0, 0))
+
+export const e = await import("inner/mjs");
+>e : Symbol(e, Decl(other2.ts, 2, 12))
+>"inner/mjs" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.mts, 0, 0))
+
+=== tests/cases/conformance/node/other.mts ===
+// esm format file
+export const a = await import("package/cjs");
+>a : Symbol(a, Decl(other.mts, 1, 12))
+>"package/cjs" : Symbol("tests/cases/conformance/node/index", Decl(index.cts, 0, 0))
+
+export const b = await import("package/mjs");
+>b : Symbol(b, Decl(other.mts, 2, 12))
+>"package/mjs" : Symbol("tests/cases/conformance/node/index", Decl(index.mts, 0, 0))
+
+export const c = await import("package");
+>c : Symbol(c, Decl(other.mts, 3, 12))
+>"package" : Symbol("tests/cases/conformance/node/index", Decl(index.ts, 0, 0))
+
+export const f = await import("inner");
+>f : Symbol(f, Decl(other.mts, 4, 12))
+>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0))
+
+=== tests/cases/conformance/node/other2.mts ===
+// esm format file
+export const d = await import("inner/cjs");
+>d : Symbol(d, Decl(other2.mts, 1, 12))
+>"inner/cjs" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.cts, 0, 0))
+
+export const e = await import("inner/mjs");
+>e : Symbol(e, Decl(other2.mts, 2, 12))
+>"inner/mjs" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.mts, 0, 0))
+
+=== tests/cases/conformance/node/other.cts ===
+// cjs format file, no TLA
+export const a = import("package/cjs");
+>a : Symbol(a, Decl(other.cts, 1, 12))
+>"package/cjs" : Symbol("tests/cases/conformance/node/index", Decl(index.cts, 0, 0))
+
+export const b = import("package/mjs");
+>b : Symbol(b, Decl(other.cts, 2, 12))
+>"package/mjs" : Symbol("tests/cases/conformance/node/index", Decl(index.mts, 0, 0))
+
+export const c = import("package");
+>c : Symbol(c, Decl(other.cts, 3, 12))
+>"package" : Symbol("tests/cases/conformance/node/index", Decl(index.ts, 0, 0))
+
+export const f = import("inner");
+>f : Symbol(f, Decl(other.cts, 4, 12))
+>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0))
+
+=== tests/cases/conformance/node/other2.cts ===
+// cjs format file, no TLA
+export const d = import("inner/cjs");
+>d : Symbol(d, Decl(other2.cts, 1, 12))
+>"inner/cjs" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.cts, 0, 0))
+
+export const e = import("inner/mjs");
+>e : Symbol(e, Decl(other2.cts, 2, 12))
+>"inner/mjs" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.mts, 0, 0))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+export const cjsMain = true;
+>cjsMain : Symbol(cjsMain, Decl(index.d.ts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+export const esm = true;
+>esm : Symbol(esm, Decl(index.d.mts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+export const cjsNonmain = true;
+>cjsNonmain : Symbol(cjsNonmain, Decl(index.d.cts, 1, 12))
+
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.types b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.types
new file mode 100644
index 0000000000000..5a8030b43bb26
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.types
@@ -0,0 +1,141 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+No type information for this code.export {};
+No type information for this code.=== tests/cases/conformance/node/index.mts ===
+// esm format file
+No type information for this code.export {};
+No type information for this code.=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+No type information for this code.export {};
+No type information for this code.=== tests/cases/conformance/node/other.ts ===
+// esm format file
+export const a = await import("package/cjs");
+>a : typeof import("tests/cases/conformance/node/index")
+>await import("package/cjs") : typeof import("tests/cases/conformance/node/index")
+>import("package/cjs") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package/cjs" : "package/cjs"
+
+export const b = await import("package/mjs");
+>b : typeof import("tests/cases/conformance/node/index")
+>await import("package/mjs") : typeof import("tests/cases/conformance/node/index")
+>import("package/mjs") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package/mjs" : "package/mjs"
+
+export const c = await import("package");
+>c : typeof import("tests/cases/conformance/node/index")
+>await import("package") : typeof import("tests/cases/conformance/node/index")
+>import("package") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package" : "package"
+
+export const f = await import("inner");
+>f : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }
+>await import("inner") : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }
+>import("inner") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }>
+>"inner" : "inner"
+
+=== tests/cases/conformance/node/other2.ts ===
+// esm format file
+export const d = await import("inner/cjs");
+>d : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }
+>await import("inner/cjs") : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }
+>import("inner/cjs") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }>
+>"inner/cjs" : "inner/cjs"
+
+export const e = await import("inner/mjs");
+>e : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }
+>await import("inner/mjs") : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }
+>import("inner/mjs") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }>
+>"inner/mjs" : "inner/mjs"
+
+=== tests/cases/conformance/node/other.mts ===
+// esm format file
+export const a = await import("package/cjs");
+>a : typeof import("tests/cases/conformance/node/index")
+>await import("package/cjs") : typeof import("tests/cases/conformance/node/index")
+>import("package/cjs") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package/cjs" : "package/cjs"
+
+export const b = await import("package/mjs");
+>b : typeof import("tests/cases/conformance/node/index")
+>await import("package/mjs") : typeof import("tests/cases/conformance/node/index")
+>import("package/mjs") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package/mjs" : "package/mjs"
+
+export const c = await import("package");
+>c : typeof import("tests/cases/conformance/node/index")
+>await import("package") : typeof import("tests/cases/conformance/node/index")
+>import("package") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package" : "package"
+
+export const f = await import("inner");
+>f : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }
+>await import("inner") : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }
+>import("inner") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }>
+>"inner" : "inner"
+
+=== tests/cases/conformance/node/other2.mts ===
+// esm format file
+export const d = await import("inner/cjs");
+>d : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }
+>await import("inner/cjs") : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }
+>import("inner/cjs") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }>
+>"inner/cjs" : "inner/cjs"
+
+export const e = await import("inner/mjs");
+>e : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }
+>await import("inner/mjs") : { default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }
+>import("inner/mjs") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }>
+>"inner/mjs" : "inner/mjs"
+
+=== tests/cases/conformance/node/other.cts ===
+// cjs format file, no TLA
+export const a = import("package/cjs");
+>a : Promise<typeof import("tests/cases/conformance/node/index")>
+>import("package/cjs") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package/cjs" : "package/cjs"
+
+export const b = import("package/mjs");
+>b : Promise<typeof import("tests/cases/conformance/node/index")>
+>import("package/mjs") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package/mjs" : "package/mjs"
+
+export const c = import("package");
+>c : Promise<typeof import("tests/cases/conformance/node/index")>
+>import("package") : Promise<typeof import("tests/cases/conformance/node/index")>
+>"package" : "package"
+
+export const f = import("inner");
+>f : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }>
+>import("inner") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsMain: true; }>
+>"inner" : "inner"
+
+=== tests/cases/conformance/node/other2.cts ===
+// cjs format file, no TLA
+export const d = import("inner/cjs");
+>d : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }>
+>import("inner/cjs") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); cjsNonmain: true; }>
+>"inner/cjs" : "inner/cjs"
+
+export const e = import("inner/mjs");
+>e : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }>
+>import("inner/mjs") : Promise<{ default: typeof import("tests/cases/conformance/node/node_modules/inner/index"); esm: true; }>
+>"inner/mjs" : "inner/mjs"
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+export const cjsMain = true;
+>cjsMain : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+export const esm = true;
+>esm : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+export const cjsNonmain = true;
+>cjsNonmain : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).errors.txt
new file mode 100644
index 0000000000000..11f39b9dd9366
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).errors.txt
@@ -0,0 +1,116 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts.
+tests/cases/conformance/node/node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    export const a = cjs;
+    export const b = mjs;
+    export const c = type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    export const d = cjsi;
+    export const e = mjsi;
+    export const f = typei;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    export const a = cjs;
+    export const b = mjs;
+    export const c = type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    export const d = cjsi;
+    export const e = mjsi;
+    export const f = typei;
+==== tests/cases/conformance/node/index.cts (3 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    export const a = cjs;
+    export const b = mjs;
+    export const c = type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+                          ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner";
+    export const d = cjsi;
+    export const e = mjsi;
+    export const f = typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    cjs;
+    ~~~
+!!! error TS1036: Statements are not allowed in ambient contexts.
+    mjs;
+    type;
+    export const cjsMain = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (1 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+    import * as type from "inner";
+    cjs;
+    ~~~
+!!! error TS1036: Statements are not allowed in ambient contexts.
+    mjs;
+    type;
+    export const esm = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    cjs;
+    ~~~
+!!! error TS1036: Statements are not allowed in ambient contexts.
+    mjs;
+    type;
+    export const cjsNonmain = true;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).js b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).js
new file mode 100644
index 0000000000000..7fdb02cf02112
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).js
@@ -0,0 +1,198 @@
+//// [tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.mts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.cts]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsMain = true;
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const esm = true;
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsNonmain = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = exports.e = exports.d = exports.c = exports.b = exports.a = void 0;
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+exports.a = cjs;
+exports.b = mjs;
+exports.c = type;
+const cjsi = __importStar(require("inner/cjs"));
+const mjsi = __importStar(require("inner/mjs"));
+const typei = __importStar(require("inner"));
+exports.d = cjsi;
+exports.e = mjsi;
+exports.f = typei;
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+
+
+//// [index.d.mts]
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export declare const a: typeof cjs;
+export declare const b: typeof mjs;
+export declare const c: typeof type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export declare const d: typeof cjsi;
+export declare const e: typeof mjsi;
+export declare const f: typeof typei;
+//// [index.d.cts]
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export declare const a: typeof cjs;
+export declare const b: typeof mjs;
+export declare const c: typeof type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export declare const d: typeof cjsi;
+export declare const e: typeof mjsi;
+export declare const f: typeof typei;
+//// [index.d.ts]
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export declare const a: typeof cjs;
+export declare const b: typeof mjs;
+export declare const c: typeof type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export declare const d: typeof cjsi;
+export declare const e: typeof mjsi;
+export declare const f: typeof typei;
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).symbols b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).symbols
new file mode 100644
index 0000000000000..3af13052d296b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).symbols
@@ -0,0 +1,201 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+export const a = cjs;
+>a : Symbol(type.a, Decl(index.ts, 4, 12))
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+export const b = mjs;
+>b : Symbol(type.b, Decl(index.ts, 5, 12))
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+export const c = type;
+>c : Symbol(type.c, Decl(index.ts, 6, 12))
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+export const d = cjsi;
+>d : Symbol(type.d, Decl(index.ts, 10, 12))
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+export const e = mjsi;
+>e : Symbol(type.e, Decl(index.ts, 11, 12))
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+export const f = typei;
+>f : Symbol(type.f, Decl(index.ts, 12, 12))
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+export const a = cjs;
+>a : Symbol(mjs.a, Decl(index.mts, 4, 12))
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+export const b = mjs;
+>b : Symbol(mjs.b, Decl(index.mts, 5, 12))
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+export const c = type;
+>c : Symbol(mjs.c, Decl(index.mts, 6, 12))
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+export const d = cjsi;
+>d : Symbol(mjs.d, Decl(index.mts, 10, 12))
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+export const e = mjsi;
+>e : Symbol(mjs.e, Decl(index.mts, 11, 12))
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+export const f = typei;
+>f : Symbol(mjs.f, Decl(index.mts, 12, 12))
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+export const a = cjs;
+>a : Symbol(cjs.a, Decl(index.cts, 4, 12))
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+export const b = mjs;
+>b : Symbol(cjs.b, Decl(index.cts, 5, 12))
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+export const c = type;
+>c : Symbol(cjs.c, Decl(index.cts, 6, 12))
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+export const d = cjsi;
+>d : Symbol(cjs.d, Decl(index.cts, 10, 12))
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+export const e = mjsi;
+>e : Symbol(cjs.e, Decl(index.cts, 11, 12))
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+export const f = typei;
+>f : Symbol(cjs.f, Decl(index.cts, 12, 12))
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export const cjsMain = true;
+>cjsMain : Symbol(type.cjsMain, Decl(index.d.ts, 7, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export const esm = true;
+>esm : Symbol(mjs.esm, Decl(index.d.mts, 7, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export const cjsNonmain = true;
+>cjsNonmain : Symbol(cjs.cjsNonmain, Decl(index.d.cts, 7, 12))
+
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).types b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).types
new file mode 100644
index 0000000000000..5db63226d0814
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node12).types
@@ -0,0 +1,204 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+export const a = cjs;
+>a : typeof cjs
+>cjs : typeof cjs
+
+export const b = mjs;
+>b : typeof mjs
+>mjs : typeof mjs
+
+export const c = type;
+>c : typeof type
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof mjsi
+
+import * as typei from "inner";
+>typei : typeof typei
+
+export const d = cjsi;
+>d : typeof cjsi
+>cjsi : typeof cjsi
+
+export const e = mjsi;
+>e : typeof mjsi
+>mjsi : typeof mjsi
+
+export const f = typei;
+>f : typeof typei
+>typei : typeof typei
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+export const a = cjs;
+>a : typeof cjs
+>cjs : typeof cjs
+
+export const b = mjs;
+>b : typeof mjs
+>mjs : typeof mjs
+
+export const c = type;
+>c : typeof type
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof mjsi
+
+import * as typei from "inner";
+>typei : typeof typei
+
+export const d = cjsi;
+>d : typeof cjsi
+>cjsi : typeof cjsi
+
+export const e = mjsi;
+>e : typeof mjsi
+>mjsi : typeof mjsi
+
+export const f = typei;
+>f : typeof typei
+>typei : typeof typei
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+export const a = cjs;
+>a : typeof cjs
+>cjs : typeof cjs
+
+export const b = mjs;
+>b : typeof mjs
+>mjs : typeof mjs
+
+export const c = type;
+>c : typeof type
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof mjsi
+
+import * as typei from "inner";
+>typei : typeof typei
+
+export const d = cjsi;
+>d : typeof cjsi
+>cjsi : typeof cjsi
+
+export const e = mjsi;
+>e : typeof mjsi
+>mjsi : typeof mjsi
+
+export const f = typei;
+>f : typeof typei
+>typei : typeof typei
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+export const cjsMain = true;
+>cjsMain : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+export const esm = true;
+>esm : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+export const cjsNonmain = true;
+>cjsNonmain : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..11f39b9dd9366
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt
@@ -0,0 +1,116 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts.
+tests/cases/conformance/node/node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    export const a = cjs;
+    export const b = mjs;
+    export const c = type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    export const d = cjsi;
+    export const e = mjsi;
+    export const f = typei;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    export const a = cjs;
+    export const b = mjs;
+    export const c = type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    export const d = cjsi;
+    export const e = mjsi;
+    export const f = typei;
+==== tests/cases/conformance/node/index.cts (3 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    export const a = cjs;
+    export const b = mjs;
+    export const c = type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+                          ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner";
+    export const d = cjsi;
+    export const e = mjsi;
+    export const f = typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    cjs;
+    ~~~
+!!! error TS1036: Statements are not allowed in ambient contexts.
+    mjs;
+    type;
+    export const cjsMain = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (1 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+    import * as type from "inner";
+    cjs;
+    ~~~
+!!! error TS1036: Statements are not allowed in ambient contexts.
+    mjs;
+    type;
+    export const esm = true;
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    cjs;
+    ~~~
+!!! error TS1036: Statements are not allowed in ambient contexts.
+    mjs;
+    type;
+    export const cjsNonmain = true;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js
new file mode 100644
index 0000000000000..7fdb02cf02112
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js
@@ -0,0 +1,198 @@
+//// [tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.mts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.cts]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsMain = true;
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const esm = true;
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsNonmain = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = exports.e = exports.d = exports.c = exports.b = exports.a = void 0;
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+exports.a = cjs;
+exports.b = mjs;
+exports.c = type;
+const cjsi = __importStar(require("inner/cjs"));
+const mjsi = __importStar(require("inner/mjs"));
+const typei = __importStar(require("inner"));
+exports.d = cjsi;
+exports.e = mjsi;
+exports.f = typei;
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+
+
+//// [index.d.mts]
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export declare const a: typeof cjs;
+export declare const b: typeof mjs;
+export declare const c: typeof type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export declare const d: typeof cjsi;
+export declare const e: typeof mjsi;
+export declare const f: typeof typei;
+//// [index.d.cts]
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export declare const a: typeof cjs;
+export declare const b: typeof mjs;
+export declare const c: typeof type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export declare const d: typeof cjsi;
+export declare const e: typeof mjsi;
+export declare const f: typeof typei;
+//// [index.d.ts]
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export declare const a: typeof cjs;
+export declare const b: typeof mjs;
+export declare const c: typeof type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export declare const d: typeof cjsi;
+export declare const e: typeof mjsi;
+export declare const f: typeof typei;
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..3af13052d296b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).symbols
@@ -0,0 +1,201 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+export const a = cjs;
+>a : Symbol(type.a, Decl(index.ts, 4, 12))
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+export const b = mjs;
+>b : Symbol(type.b, Decl(index.ts, 5, 12))
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+export const c = type;
+>c : Symbol(type.c, Decl(index.ts, 6, 12))
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+export const d = cjsi;
+>d : Symbol(type.d, Decl(index.ts, 10, 12))
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+export const e = mjsi;
+>e : Symbol(type.e, Decl(index.ts, 11, 12))
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+export const f = typei;
+>f : Symbol(type.f, Decl(index.ts, 12, 12))
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+export const a = cjs;
+>a : Symbol(mjs.a, Decl(index.mts, 4, 12))
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+export const b = mjs;
+>b : Symbol(mjs.b, Decl(index.mts, 5, 12))
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+export const c = type;
+>c : Symbol(mjs.c, Decl(index.mts, 6, 12))
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+export const d = cjsi;
+>d : Symbol(mjs.d, Decl(index.mts, 10, 12))
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+export const e = mjsi;
+>e : Symbol(mjs.e, Decl(index.mts, 11, 12))
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+export const f = typei;
+>f : Symbol(mjs.f, Decl(index.mts, 12, 12))
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+export const a = cjs;
+>a : Symbol(cjs.a, Decl(index.cts, 4, 12))
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+export const b = mjs;
+>b : Symbol(cjs.b, Decl(index.cts, 5, 12))
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+export const c = type;
+>c : Symbol(cjs.c, Decl(index.cts, 6, 12))
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+export const d = cjsi;
+>d : Symbol(cjs.d, Decl(index.cts, 10, 12))
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+export const e = mjsi;
+>e : Symbol(cjs.e, Decl(index.cts, 11, 12))
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+export const f = typei;
+>f : Symbol(cjs.f, Decl(index.cts, 12, 12))
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export const cjsMain = true;
+>cjsMain : Symbol(type.cjsMain, Decl(index.d.ts, 7, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export const esm = true;
+>esm : Symbol(mjs.esm, Decl(index.d.mts, 7, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export const cjsNonmain = true;
+>cjsNonmain : Symbol(cjs.cjsNonmain, Decl(index.d.cts, 7, 12))
+
diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types
new file mode 100644
index 0000000000000..5db63226d0814
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types
@@ -0,0 +1,204 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+export const a = cjs;
+>a : typeof cjs
+>cjs : typeof cjs
+
+export const b = mjs;
+>b : typeof mjs
+>mjs : typeof mjs
+
+export const c = type;
+>c : typeof type
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof mjsi
+
+import * as typei from "inner";
+>typei : typeof typei
+
+export const d = cjsi;
+>d : typeof cjsi
+>cjsi : typeof cjsi
+
+export const e = mjsi;
+>e : typeof mjsi
+>mjsi : typeof mjsi
+
+export const f = typei;
+>f : typeof typei
+>typei : typeof typei
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+export const a = cjs;
+>a : typeof cjs
+>cjs : typeof cjs
+
+export const b = mjs;
+>b : typeof mjs
+>mjs : typeof mjs
+
+export const c = type;
+>c : typeof type
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof mjsi
+
+import * as typei from "inner";
+>typei : typeof typei
+
+export const d = cjsi;
+>d : typeof cjsi
+>cjsi : typeof cjsi
+
+export const e = mjsi;
+>e : typeof mjsi
+>mjsi : typeof mjsi
+
+export const f = typei;
+>f : typeof typei
+>typei : typeof typei
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+export const a = cjs;
+>a : typeof cjs
+>cjs : typeof cjs
+
+export const b = mjs;
+>b : typeof mjs
+>mjs : typeof mjs
+
+export const c = type;
+>c : typeof type
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof mjsi
+
+import * as typei from "inner";
+>typei : typeof typei
+
+export const d = cjsi;
+>d : typeof cjsi
+>cjsi : typeof cjsi
+
+export const e = mjsi;
+>e : typeof mjsi
+>mjsi : typeof mjsi
+
+export const f = typei;
+>f : typeof typei
+>typei : typeof typei
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+export const cjsMain = true;
+>cjsMain : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+export const esm = true;
+>esm : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+export const cjsNonmain = true;
+>cjsNonmain : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js
new file mode 100644
index 0000000000000..aceeafb8c5965
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js
@@ -0,0 +1,45 @@
+//// [tests/cases/conformance/node/nodeModulesDynamicImport.ts] ////
+
+//// [index.ts]
+// cjs format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [index.ts]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.main = void 0;
+// cjs format file
+async function main() {
+    const { readFile } = await import("fs");
+}
+exports.main = main;
+//// [index.js]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+
+
+//// [index.d.ts]
+export declare function main(): Promise<void>;
+//// [index.d.ts]
+export declare function main(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).symbols b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).symbols
new file mode 100644
index 0000000000000..69296bc3fa993
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export async function main() {
+>main : Symbol(main, Decl(index.ts, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.ts, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export async function main() {
+>main : Symbol(main, Decl(index.ts, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.ts, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).types b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).types
new file mode 100644
index 0000000000000..879fb7ca71bf8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).types
@@ -0,0 +1,26 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js
new file mode 100644
index 0000000000000..aceeafb8c5965
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js
@@ -0,0 +1,45 @@
+//// [tests/cases/conformance/node/nodeModulesDynamicImport.ts] ////
+
+//// [index.ts]
+// cjs format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [index.ts]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.main = void 0;
+// cjs format file
+async function main() {
+    const { readFile } = await import("fs");
+}
+exports.main = main;
+//// [index.js]
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+
+
+//// [index.d.ts]
+export declare function main(): Promise<void>;
+//// [index.d.ts]
+export declare function main(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).symbols b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).symbols
new file mode 100644
index 0000000000000..69296bc3fa993
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export async function main() {
+>main : Symbol(main, Decl(index.ts, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.ts, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export async function main() {
+>main : Symbol(main, Decl(index.ts, 0, 0))
+
+    const { readFile } = await import("fs");
+>readFile : Symbol(readFile, Decl(index.ts, 2, 11))
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+}
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).types b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).types
new file mode 100644
index 0000000000000..879fb7ca71bf8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).types
@@ -0,0 +1,26 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export async function main() {
+>main : () => Promise<void>
+
+    const { readFile } = await import("fs");
+>readFile : any
+>await import("fs") : any
+>import("fs") : Promise<any>
+>"fs" : "fs"
+}
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).errors.txt b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).errors.txt
new file mode 100644
index 0000000000000..cef2966380663
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).errors.txt
@@ -0,0 +1,23 @@
+tests/cases/conformance/node/index.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ====
+    // cjs format file
+    const a = {};
+    export = a;
+==== tests/cases/conformance/node/index.ts (1 errors) ====
+    // esm format file
+    const a = {};
+    export = a;
+    ~~~~~~~~~~~
+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js
new file mode 100644
index 0000000000000..2d09438ae7cd8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js
@@ -0,0 +1,38 @@
+//// [tests/cases/conformance/node/nodeModulesExportAssignments.ts] ////
+
+//// [index.ts]
+// cjs format file
+const a = {};
+export = a;
+//// [index.ts]
+// esm format file
+const a = {};
+export = a;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+// cjs format file
+const a = {};
+module.exports = a;
+//// [index.js]
+// esm format file
+const a = {};
+export {};
+
+
+//// [index.d.ts]
+declare const a: {};
+export = a;
+//// [index.d.ts]
+declare const a: {};
+export = a;
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).symbols b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).symbols
new file mode 100644
index 0000000000000..4552dd34157ab
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).symbols
@@ -0,0 +1,16 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const a = {};
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const a = {};
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).types b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).types
new file mode 100644
index 0000000000000..73f7e0869eba3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).types
@@ -0,0 +1,18 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..cef2966380663
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).errors.txt
@@ -0,0 +1,23 @@
+tests/cases/conformance/node/index.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ====
+    // cjs format file
+    const a = {};
+    export = a;
+==== tests/cases/conformance/node/index.ts (1 errors) ====
+    // esm format file
+    const a = {};
+    export = a;
+    ~~~~~~~~~~~
+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js
new file mode 100644
index 0000000000000..2d09438ae7cd8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js
@@ -0,0 +1,38 @@
+//// [tests/cases/conformance/node/nodeModulesExportAssignments.ts] ////
+
+//// [index.ts]
+// cjs format file
+const a = {};
+export = a;
+//// [index.ts]
+// esm format file
+const a = {};
+export = a;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+// cjs format file
+const a = {};
+module.exports = a;
+//// [index.js]
+// esm format file
+const a = {};
+export {};
+
+
+//// [index.d.ts]
+declare const a: {};
+export = a;
+//// [index.d.ts]
+declare const a: {};
+export = a;
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).symbols b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).symbols
new file mode 100644
index 0000000000000..4552dd34157ab
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).symbols
@@ -0,0 +1,16 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const a = {};
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const a = {};
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
+export = a;
+>a : Symbol(a, Decl(index.ts, 1, 5))
+
diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).types b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).types
new file mode 100644
index 0000000000000..73f7e0869eba3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).types
@@ -0,0 +1,18 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const a = {};
+>a : {}
+>{} : {}
+
+export = a;
+>a : {}
+
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt
new file mode 100644
index 0000000000000..984483a332e29
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt
@@ -0,0 +1,139 @@
+tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ====
+    {
+    }
+==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ====
+    {
+        "type": "module"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js
new file mode 100644
index 0000000000000..4cca6af5a58d7
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js
@@ -0,0 +1,172 @@
+//// [tests/cases/conformance/node/nodeModulesForbidenSyntax.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.ts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.ts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.ts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [package.json]
+{
+}
+//// [package.json]
+{
+    "type": "module"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.js]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.js]
+// esm format file
+const x = () => (void 0);
+export { x };
+
+
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols
new file mode 100644
index 0000000000000..1ca35d0d3e32e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types
new file mode 100644
index 0000000000000..016af4314d16b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types
@@ -0,0 +1,168 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..984483a332e29
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt
@@ -0,0 +1,139 @@
+tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/index.mts (3 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/index.cts (3 errors) ====
+    // cjs format file
+    const x = <T>() => <T><any>(void 0);
+               ~
+!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
+                       ~~~~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+                          ~~~~~~~~~~~~~
+!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
+    export {x};
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    const x = <T>() => <T><any>(void 0);
+    export {x};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ====
+    {
+    }
+==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ====
+    {
+        "type": "module"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js
new file mode 100644
index 0000000000000..4cca6af5a58d7
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js
@@ -0,0 +1,172 @@
+//// [tests/cases/conformance/node/nodeModulesForbidenSyntax.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.ts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.ts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.mts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.cts]
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [index.ts]
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [package.json]
+{
+}
+//// [package.json]
+{
+    "type": "module"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.js]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.mjs]
+// esm format file
+const x = () => (void 0);
+export { x };
+//// [index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = () => (void 0);
+exports.x = x;
+//// [index.js]
+// esm format file
+const x = () => (void 0);
+export { x };
+
+
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.mts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.cts]
+declare const x: <T>() => T;
+export { x };
+//// [index.d.ts]
+declare const x: <T>() => T;
+export { x };
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols
new file mode 100644
index 0000000000000..1ca35d0d3e32e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.mts, 1, 5))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+>T : Symbol(T, Decl(index.mts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.mts, 2, 8))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.cts, 1, 5))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+>T : Symbol(T, Decl(index.cts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.cts, 2, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+>T : Symbol(T, Decl(index.ts, 1, 11))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types
new file mode 100644
index 0000000000000..016af4314d16b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types
@@ -0,0 +1,168 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/index.ts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/another/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/another/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/subfolder2/another/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = <T>() => <T><any>(void 0);
+>x : <T>() => T
+><T>() => <T><any>(void 0) : <T>() => T
+><T><any>(void 0) : T
+><any>(void 0) : any
+>(void 0) : undefined
+>void 0 : undefined
+>0 : 0
+
+export {x};
+>x : <T>() => T
+
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).errors.txt
new file mode 100644
index 0000000000000..bcf0d1d592ca8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).errors.txt
@@ -0,0 +1,38 @@
+tests/cases/conformance/node/subfolder/index.ts(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+tests/cases/conformance/node/subfolder/index.ts(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+tests/cases/conformance/node/subfolder/index.ts(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12.
+tests/cases/conformance/node/subfolder/index.ts(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (4 errors) ====
+    // cjs format file
+    function require() {}
+             ~~~~~~~
+!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+    const exports = {};
+          ~~~~~~~
+!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+    class Object {}
+          ~~~~~~
+!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12.
+    export const __esModule = false;
+                 ~~~~~~~~~~
+!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+    export {require, exports, Object};
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    function require() {}
+    const exports = {};
+    class Object {}
+    export const __esModule = false;
+    export {require, exports, Object};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js
new file mode 100644
index 0000000000000..064128d216ee8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js
@@ -0,0 +1,64 @@
+//// [tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts] ////
+
+//// [index.ts]
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [index.ts]
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Object = exports.exports = exports.require = exports.__esModule = void 0;
+// cjs format file
+function require() { }
+exports.require = require;
+const exports = {};
+exports.exports = exports;
+class Object {
+}
+exports.Object = Object;
+exports.__esModule = false;
+//// [index.js]
+// esm format file
+function require() { }
+const exports = {};
+class Object {
+}
+export const __esModule = false;
+export { require, exports, Object };
+
+
+//// [index.d.ts]
+declare function require(): void;
+declare const exports: {};
+declare class Object {
+}
+export declare const __esModule = false;
+export { require, exports, Object };
+//// [index.d.ts]
+declare function require(): void;
+declare const exports: {};
+declare class Object {
+}
+export declare const __esModule = false;
+export { require, exports, Object };
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).symbols b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).symbols
new file mode 100644
index 0000000000000..9e967fe93b7a4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).symbols
@@ -0,0 +1,38 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+function require() {}
+>require : Symbol(require, Decl(index.ts, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.ts, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.ts, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.ts, 5, 8))
+>exports : Symbol(exports, Decl(index.ts, 5, 16))
+>Object : Symbol(Object, Decl(index.ts, 5, 25))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+function require() {}
+>require : Symbol(require, Decl(index.ts, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.ts, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.ts, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.ts, 5, 8))
+>exports : Symbol(exports, Decl(index.ts, 5, 16))
+>Object : Symbol(Object, Decl(index.ts, 5, 25))
+
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).types b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).types
new file mode 100644
index 0000000000000..094de6c869242
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).types
@@ -0,0 +1,42 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..abc62c363a23c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).errors.txt
@@ -0,0 +1,38 @@
+tests/cases/conformance/node/subfolder/index.ts(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+tests/cases/conformance/node/subfolder/index.ts(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+tests/cases/conformance/node/subfolder/index.ts(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext.
+tests/cases/conformance/node/subfolder/index.ts(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (4 errors) ====
+    // cjs format file
+    function require() {}
+             ~~~~~~~
+!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
+    const exports = {};
+          ~~~~~~~
+!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module.
+    class Object {}
+          ~~~~~~
+!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext.
+    export const __esModule = false;
+                 ~~~~~~~~~~
+!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.
+    export {require, exports, Object};
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    function require() {}
+    const exports = {};
+    class Object {}
+    export const __esModule = false;
+    export {require, exports, Object};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js
new file mode 100644
index 0000000000000..064128d216ee8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js
@@ -0,0 +1,64 @@
+//// [tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts] ////
+
+//// [index.ts]
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [index.ts]
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Object = exports.exports = exports.require = exports.__esModule = void 0;
+// cjs format file
+function require() { }
+exports.require = require;
+const exports = {};
+exports.exports = exports;
+class Object {
+}
+exports.Object = Object;
+exports.__esModule = false;
+//// [index.js]
+// esm format file
+function require() { }
+const exports = {};
+class Object {
+}
+export const __esModule = false;
+export { require, exports, Object };
+
+
+//// [index.d.ts]
+declare function require(): void;
+declare const exports: {};
+declare class Object {
+}
+export declare const __esModule = false;
+export { require, exports, Object };
+//// [index.d.ts]
+declare function require(): void;
+declare const exports: {};
+declare class Object {
+}
+export declare const __esModule = false;
+export { require, exports, Object };
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).symbols
new file mode 100644
index 0000000000000..9e967fe93b7a4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).symbols
@@ -0,0 +1,38 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+function require() {}
+>require : Symbol(require, Decl(index.ts, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.ts, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.ts, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.ts, 5, 8))
+>exports : Symbol(exports, Decl(index.ts, 5, 16))
+>Object : Symbol(Object, Decl(index.ts, 5, 25))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+function require() {}
+>require : Symbol(require, Decl(index.ts, 0, 0))
+
+const exports = {};
+>exports : Symbol(exports, Decl(index.ts, 2, 5))
+
+class Object {}
+>Object : Symbol(Object, Decl(index.ts, 2, 19))
+
+export const __esModule = false;
+>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12))
+
+export {require, exports, Object};
+>require : Symbol(require, Decl(index.ts, 5, 8))
+>exports : Symbol(exports, Decl(index.ts, 5, 16))
+>Object : Symbol(Object, Decl(index.ts, 5, 25))
+
diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).types b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).types
new file mode 100644
index 0000000000000..094de6c869242
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).types
@@ -0,0 +1,42 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+function require() {}
+>require : () => void
+
+const exports = {};
+>exports : {}
+>{} : {}
+
+class Object {}
+>Object : Object
+
+export const __esModule = false;
+>__esModule : false
+>false : false
+
+export {require, exports, Object};
+>require : () => void
+>exports : {}
+>Object : typeof Object
+
diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js
new file mode 100644
index 0000000000000..c73ff1177a58e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js
@@ -0,0 +1,65 @@
+//// [tests/cases/conformance/node/nodeModulesImportAssignments.ts] ////
+
+//// [index.ts]
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [index.ts]
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [file.ts]
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const fs = require("fs");
+fs.readFile;
+exports.fs2 = require("fs");
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+// esm format file
+const fs = __require("fs");
+fs.readFile;
+const fs2 = __require("fs");
+export { fs2 };
+//// [file.js]
+import { createRequire as _createRequire_1 } from "module";
+const __require_1 = _createRequire_1(import.meta.url);
+// esm format file
+const __require = null;
+const _createRequire = null;
+const fs = __require_1("fs");
+fs.readFile;
+const fs2 = __require_1("fs");
+export { fs2 };
+
+
+//// [index.d.ts]
+export import fs2 = require("fs");
+//// [index.d.ts]
+export import fs2 = require("fs");
+//// [file.d.ts]
+export import fs2 = require("fs");
diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).symbols b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).symbols
new file mode 100644
index 0000000000000..ae7fbc666da4c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).symbols
@@ -0,0 +1,43 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.ts, 2, 12))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.ts, 2, 12))
+
+=== tests/cases/conformance/node/file.ts ===
+// esm format file
+const __require = null;
+>__require : Symbol(__require, Decl(file.ts, 1, 5))
+
+const _createRequire = null;
+>_createRequire : Symbol(_createRequire, Decl(file.ts, 2, 5))
+
+import fs = require("fs");
+>fs : Symbol(fs, Decl(file.ts, 2, 28))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(file.ts, 2, 28))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(file.ts, 4, 12))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).types b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).types
new file mode 100644
index 0000000000000..21af2cd798f58
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).types
@@ -0,0 +1,51 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/file.ts ===
+// esm format file
+const __require = null;
+>__require : any
+>null : null
+
+const _createRequire = null;
+>_createRequire : any
+>null : null
+
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js
new file mode 100644
index 0000000000000..c73ff1177a58e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js
@@ -0,0 +1,65 @@
+//// [tests/cases/conformance/node/nodeModulesImportAssignments.ts] ////
+
+//// [index.ts]
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [index.ts]
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [file.ts]
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const fs = require("fs");
+fs.readFile;
+exports.fs2 = require("fs");
+//// [index.js]
+import { createRequire as _createRequire } from "module";
+const __require = _createRequire(import.meta.url);
+// esm format file
+const fs = __require("fs");
+fs.readFile;
+const fs2 = __require("fs");
+export { fs2 };
+//// [file.js]
+import { createRequire as _createRequire_1 } from "module";
+const __require_1 = _createRequire_1(import.meta.url);
+// esm format file
+const __require = null;
+const _createRequire = null;
+const fs = __require_1("fs");
+fs.readFile;
+const fs2 = __require_1("fs");
+export { fs2 };
+
+
+//// [index.d.ts]
+export import fs2 = require("fs");
+//// [index.d.ts]
+export import fs2 = require("fs");
+//// [file.d.ts]
+export import fs2 = require("fs");
diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).symbols
new file mode 100644
index 0000000000000..ae7fbc666da4c
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).symbols
@@ -0,0 +1,43 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.ts, 2, 12))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import fs = require("fs");
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 0, 0))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(index.ts, 2, 12))
+
+=== tests/cases/conformance/node/file.ts ===
+// esm format file
+const __require = null;
+>__require : Symbol(__require, Decl(file.ts, 1, 5))
+
+const _createRequire = null;
+>_createRequire : Symbol(_createRequire, Decl(file.ts, 2, 5))
+
+import fs = require("fs");
+>fs : Symbol(fs, Decl(file.ts, 2, 28))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(file.ts, 2, 28))
+
+export import fs2 = require("fs");
+>fs2 : Symbol(fs2, Decl(file.ts, 4, 12))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).types b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).types
new file mode 100644
index 0000000000000..21af2cd798f58
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).types
@@ -0,0 +1,51 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/file.ts ===
+// esm format file
+const __require = null;
+>__require : any
+>null : null
+
+const _createRequire = null;
+>_createRequire : any
+>null : null
+
+import fs = require("fs");
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+export import fs2 = require("fs");
+>fs2 : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).errors.txt
new file mode 100644
index 0000000000000..b4ae0ff6fb045
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).errors.txt
@@ -0,0 +1,36 @@
+tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/subfolder/index.ts(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    import {default as _fs} from "fs";
+            ~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    _fs.readFile;
+    import * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    fs.readFile;
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import {default as _fs} from "fs";
+    _fs.readFile;
+    import * as fs from "fs";
+    fs.readFile;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js
new file mode 100644
index 0000000000000..87467d9fd7e6b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js
@@ -0,0 +1,52 @@
+//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts] ////
+
+//// [index.ts]
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [index.ts]
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const tslib_1 = require("tslib");
+// cjs format file
+const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
+fs_1.default.readFile;
+const fs = (0, tslib_1.__importStar)(require("fs"));
+fs.readFile;
+//// [index.js]
+// esm format file
+import { default as _fs } from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).symbols
new file mode 100644
index 0000000000000..996840abd4e8b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).symbols
@@ -0,0 +1,40 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).types
new file mode 100644
index 0000000000000..e08e9456be9a5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).types
@@ -0,0 +1,48 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..b4ae0ff6fb045
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).errors.txt
@@ -0,0 +1,36 @@
+tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/subfolder/index.ts(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    import {default as _fs} from "fs";
+            ~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    _fs.readFile;
+    import * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    fs.readFile;
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import {default as _fs} from "fs";
+    _fs.readFile;
+    import * as fs from "fs";
+    fs.readFile;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js
new file mode 100644
index 0000000000000..87467d9fd7e6b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js
@@ -0,0 +1,52 @@
+//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts] ////
+
+//// [index.ts]
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [index.ts]
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const tslib_1 = require("tslib");
+// cjs format file
+const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
+fs_1.default.readFile;
+const fs = (0, tslib_1.__importStar)(require("fs"));
+fs.readFile;
+//// [index.js]
+// esm format file
+import { default as _fs } from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).symbols
new file mode 100644
index 0000000000000..996840abd4e8b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).symbols
@@ -0,0 +1,40 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {default as _fs} from "fs";
+>default : Symbol(_fs, Decl(types.d.ts, 0, 0))
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+_fs.readFile;
+>_fs : Symbol(_fs, Decl(index.ts, 1, 8))
+
+import * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+fs.readFile;
+>fs : Symbol(fs, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).types
new file mode 100644
index 0000000000000..e08e9456be9a5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).types
@@ -0,0 +1,48 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {default as _fs} from "fs";
+>default : any
+>_fs : any
+
+_fs.readFile;
+>_fs.readFile : any
+>_fs : any
+>readFile : any
+
+import * as fs from "fs";
+>fs : any
+
+fs.readFile;
+>fs.readFile : any
+>fs : any
+>readFile : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).errors.txt
new file mode 100644
index 0000000000000..d2f62391af269
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).errors.txt
@@ -0,0 +1,32 @@
+tests/cases/conformance/node/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    export * from "fs";
+    ~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    export * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    export * from "fs";
+    export * as fs from "fs";
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js
new file mode 100644
index 0000000000000..1cc268a7fa066
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js
@@ -0,0 +1,47 @@
+//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts] ////
+
+//// [index.ts]
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+//// [index.ts]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.fs = void 0;
+const tslib_1 = require("tslib");
+// cjs format file
+(0, tslib_1.__exportStar)(require("fs"), exports);
+exports.fs = (0, tslib_1.__importStar)(require("fs"));
+//// [index.js]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+
+
+//// [index.d.ts]
+export * from "fs";
+export * as fs from "fs";
+//// [index.d.ts]
+export * from "fs";
+export * as fs from "fs";
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).symbols
new file mode 100644
index 0000000000000..367ba59adf00f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 2, 6))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 2, 6))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).types
new file mode 100644
index 0000000000000..6a468baefa7d1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).types
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..d2f62391af269
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).errors.txt
@@ -0,0 +1,32 @@
+tests/cases/conformance/node/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+tests/cases/conformance/node/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    export * from "fs";
+    ~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+    export * as fs from "fs";
+    ~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    export * from "fs";
+    export * as fs from "fs";
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js
new file mode 100644
index 0000000000000..1cc268a7fa066
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js
@@ -0,0 +1,47 @@
+//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts] ////
+
+//// [index.ts]
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+//// [index.ts]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.fs = void 0;
+const tslib_1 = require("tslib");
+// cjs format file
+(0, tslib_1.__exportStar)(require("fs"), exports);
+exports.fs = (0, tslib_1.__importStar)(require("fs"));
+//// [index.js]
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+
+
+//// [index.d.ts]
+export * from "fs";
+export * as fs from "fs";
+//// [index.d.ts]
+export * from "fs";
+export * as fs from "fs";
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).symbols
new file mode 100644
index 0000000000000..367ba59adf00f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 2, 6))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : Symbol(fs, Decl(index.ts, 2, 6))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).types
new file mode 100644
index 0000000000000..6a468baefa7d1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).types
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+>fs : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).errors.txt
new file mode 100644
index 0000000000000..d511944f39332
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).errors.txt
@@ -0,0 +1,27 @@
+tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ====
+    // cjs format file
+    export {default} from "fs";
+            ~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    export {default} from "fs";
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js
new file mode 100644
index 0000000000000..8abf8ba9adac3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js
@@ -0,0 +1,44 @@
+//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts] ////
+
+//// [index.ts]
+// cjs format file
+export {default} from "fs";
+//// [index.ts]
+// esm format file
+export {default} from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = void 0;
+// cjs format file
+var fs_1 = require("fs");
+Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
+//// [index.js]
+// esm format file
+export { default } from "fs";
+
+
+//// [index.d.ts]
+export { default } from "fs";
+//// [index.d.ts]
+export { default } from "fs";
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).symbols
new file mode 100644
index 0000000000000..aec1d32dab1d4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).symbols
@@ -0,0 +1,20 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.ts, 1, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.ts, 1, 8))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).types
new file mode 100644
index 0000000000000..eef93356ac7bc
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).types
@@ -0,0 +1,20 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export {default} from "fs";
+>default : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export {default} from "fs";
+>default : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..d511944f39332
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).errors.txt
@@ -0,0 +1,27 @@
+tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ====
+    // cjs format file
+    export {default} from "fs";
+            ~~~~~~~
+!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    export {default} from "fs";
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
+==== tests/cases/conformance/node/types.d.ts (0 errors) ====
+    declare module "fs";
+    declare module "tslib" {
+        export {};
+        // intentionally missing all helpers
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js
new file mode 100644
index 0000000000000..8abf8ba9adac3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js
@@ -0,0 +1,44 @@
+//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts] ////
+
+//// [index.ts]
+// cjs format file
+export {default} from "fs";
+//// [index.ts]
+// esm format file
+export {default} from "fs";
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+//// [types.d.ts]
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
+
+//// [index.js]
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = void 0;
+// cjs format file
+var fs_1 = require("fs");
+Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
+//// [index.js]
+// esm format file
+export { default } from "fs";
+
+
+//// [index.d.ts]
+export { default } from "fs";
+//// [index.d.ts]
+export { default } from "fs";
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).symbols
new file mode 100644
index 0000000000000..aec1d32dab1d4
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).symbols
@@ -0,0 +1,20 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.ts, 1, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export {default} from "fs";
+>default : Symbol(default, Decl(index.ts, 1, 8))
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0))
+
+declare module "tslib" {
+>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20))
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).types
new file mode 100644
index 0000000000000..eef93356ac7bc
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).types
@@ -0,0 +1,20 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+export {default} from "fs";
+>default : any
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+export {default} from "fs";
+>default : any
+
+=== tests/cases/conformance/node/types.d.ts ===
+declare module "fs";
+>"fs" : any
+
+declare module "tslib" {
+>"tslib" : typeof import("tslib")
+
+    export {};
+    // intentionally missing all helpers
+}
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportMeta(module=node12).errors.txt
new file mode 100644
index 0000000000000..27f6e3c9e281e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).errors.txt
@@ -0,0 +1,23 @@
+tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ====
+    // cjs format file
+    const x = import.meta.url;
+              ~~~~~~~~~~~
+!!! error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+    export {x};
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    const x = import.meta.url;
+    export {x};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).js b/tests/baselines/reference/nodeModulesImportMeta(module=node12).js
new file mode 100644
index 0000000000000..aa962a90bd346
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).js
@@ -0,0 +1,40 @@
+//// [tests/cases/conformance/node/nodeModulesImportMeta.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = import.meta.url;
+export {x};
+//// [index.ts]
+// esm format file
+const x = import.meta.url;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = import.meta.url;
+exports.x = x;
+//// [index.js]
+// esm format file
+const x = import.meta.url;
+export { x };
+
+
+//// [index.d.ts]
+declare const x: string;
+export { x };
+//// [index.d.ts]
+declare const x: string;
+export { x };
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).symbols b/tests/baselines/reference/nodeModulesImportMeta(module=node12).symbols
new file mode 100644
index 0000000000000..311b12e19ce40
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).types b/tests/baselines/reference/nodeModulesImportMeta(module=node12).types
new file mode 100644
index 0000000000000..6f64dc2b5faa6
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..27f6e3c9e281e
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).errors.txt
@@ -0,0 +1,23 @@
+tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ====
+    // cjs format file
+    const x = import.meta.url;
+              ~~~~~~~~~~~
+!!! error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.
+    export {x};
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    const x = import.meta.url;
+    export {x};
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js
new file mode 100644
index 0000000000000..aa962a90bd346
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js
@@ -0,0 +1,40 @@
+//// [tests/cases/conformance/node/nodeModulesImportMeta.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = import.meta.url;
+export {x};
+//// [index.ts]
+// esm format file
+const x = import.meta.url;
+export {x};
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = import.meta.url;
+exports.x = x;
+//// [index.js]
+// esm format file
+const x = import.meta.url;
+export { x };
+
+
+//// [index.d.ts]
+declare const x: string;
+export { x };
+//// [index.d.ts]
+declare const x: string;
+export { x };
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).symbols
new file mode 100644
index 0000000000000..311b12e19ce40
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = import.meta.url;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
+>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).types b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).types
new file mode 100644
index 0000000000000..6f64dc2b5faa6
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = import.meta.url;
+>x : string
+>import.meta.url : string
+>import.meta : ImportMeta
+>meta : any
+>url : string
+
+export {x};
+>x : string
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).js b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).js
new file mode 100644
index 0000000000000..813d5046ccfbc
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).js
@@ -0,0 +1,66 @@
+//// [tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.cts]
+// esm format file
+import * as type from "#type";
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.cjs",
+    "imports": {
+        "#type": "package"
+    }
+}
+
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const type = __importStar(require("#type"));
+type;
+//// [index.js]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mjs]
+// esm format file
+import * as type from "#type";
+type;
+
+
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).symbols b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).symbols
new file mode 100644
index 0000000000000..1a0ad59fc81c0
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).types b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).types
new file mode 100644
index 0000000000000..cb05ede987ec9
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node12).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : typeof type
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : typeof type
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : typeof type
+
+type;
+>type : typeof type
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).js b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).js
new file mode 100644
index 0000000000000..813d5046ccfbc
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).js
@@ -0,0 +1,66 @@
+//// [tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.cts]
+// esm format file
+import * as type from "#type";
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.cjs",
+    "imports": {
+        "#type": "package"
+    }
+}
+
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const type = __importStar(require("#type"));
+type;
+//// [index.js]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mjs]
+// esm format file
+import * as type from "#type";
+type;
+
+
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).symbols
new file mode 100644
index 0000000000000..1a0ad59fc81c0
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).types b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).types
new file mode 100644
index 0000000000000..cb05ede987ec9
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=nodenext).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : typeof type
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : typeof type
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : typeof type
+
+type;
+>type : typeof type
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).errors.txt
new file mode 100644
index 0000000000000..c73a7a7885f63
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).errors.txt
@@ -0,0 +1,33 @@
+tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/index.ts (1 errors) ====
+    // esm format file
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS2307: Cannot find module '#type' or its corresponding type declarations.
+    type;
+==== tests/cases/conformance/node/index.mts (1 errors) ====
+    // esm format file
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS2307: Cannot find module '#type' or its corresponding type declarations.
+    type;
+==== tests/cases/conformance/node/index.cts (1 errors) ====
+    // esm format file
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS2307: Cannot find module '#type' or its corresponding type declarations.
+    type;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "package",
+        "imports": {
+            "#type": "package"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).js b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).js
new file mode 100644
index 0000000000000..ccdc459ab1a08
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).js
@@ -0,0 +1,66 @@
+//// [tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.cts]
+// esm format file
+import * as type from "#type";
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "package",
+    "imports": {
+        "#type": "package"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mjs]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const type = __importStar(require("#type"));
+type;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).symbols b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).symbols
new file mode 100644
index 0000000000000..1a0ad59fc81c0
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).types b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).types
new file mode 100644
index 0000000000000..8bfd3afd06e6a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node12).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : any
+
+type;
+>type : any
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : any
+
+type;
+>type : any
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : any
+
+type;
+>type : any
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..c73a7a7885f63
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).errors.txt
@@ -0,0 +1,33 @@
+tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/index.ts (1 errors) ====
+    // esm format file
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS2307: Cannot find module '#type' or its corresponding type declarations.
+    type;
+==== tests/cases/conformance/node/index.mts (1 errors) ====
+    // esm format file
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS2307: Cannot find module '#type' or its corresponding type declarations.
+    type;
+==== tests/cases/conformance/node/index.cts (1 errors) ====
+    // esm format file
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS2307: Cannot find module '#type' or its corresponding type declarations.
+    type;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "package",
+        "imports": {
+            "#type": "package"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).js b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).js
new file mode 100644
index 0000000000000..ccdc459ab1a08
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).js
@@ -0,0 +1,66 @@
+//// [tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mts]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.cts]
+// esm format file
+import * as type from "#type";
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "package",
+    "imports": {
+        "#type": "package"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.mjs]
+// esm format file
+import * as type from "#type";
+type;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const type = __importStar(require("#type"));
+type;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).symbols
new file mode 100644
index 0000000000000..1a0ad59fc81c0
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 1, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 1, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 1, 6))
+
diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).types b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).types
new file mode 100644
index 0000000000000..8bfd3afd06e6a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=nodenext).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as type from "#type";
+>type : any
+
+type;
+>type : any
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as type from "#type";
+>type : any
+
+type;
+>type : any
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as type from "#type";
+>type : any
+
+type;
+>type : any
+
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesPackageExports(module=node12).errors.txt
new file mode 100644
index 0000000000000..464db33f319b0
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=node12).errors.txt
@@ -0,0 +1,107 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.cts (3 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+                          ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node12).js b/tests/baselines/reference/nodeModulesPackageExports(module=node12).js
new file mode 100644
index 0000000000000..28c25e10f9ef1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=node12).js
@@ -0,0 +1,161 @@
+//// [tests/cases/conformance/node/nodeModulesPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.mts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cts]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/cjs"));
+const mjsi = __importStar(require("inner/mjs"));
+const typei = __importStar(require("inner"));
+cjsi;
+mjsi;
+typei;
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node12).symbols b/tests/baselines/reference/nodeModulesPackageExports(module=node12).symbols
new file mode 100644
index 0000000000000..8093c39582ddc
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=node12).symbols
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node12).types b/tests/baselines/reference/nodeModulesPackageExports(module=node12).types
new file mode 100644
index 0000000000000..85dad3ea25f98
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=node12).types
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..464db33f319b0
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).errors.txt
@@ -0,0 +1,107 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+    import * as type from "package";
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.cts (3 errors) ====
+    // cjs format file
+    import * as cjs from "package/cjs";
+    import * as mjs from "package/mjs";
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+    import * as cjsi from "inner/cjs";
+    import * as mjsi from "inner/mjs";
+                          ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs";
+    import * as mjs from "inner/mjs";
+                         ~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs": "./index.cjs",
+            "./mjs": "./index.mjs",
+            ".": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).js b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).js
new file mode 100644
index 0000000000000..28c25e10f9ef1
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).js
@@ -0,0 +1,161 @@
+//// [tests/cases/conformance/node/nodeModulesPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.mts]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cts]
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjs = __importStar(require("package/cjs"));
+const mjs = __importStar(require("package/mjs"));
+const type = __importStar(require("package"));
+cjs;
+mjs;
+type;
+const cjsi = __importStar(require("inner/cjs"));
+const mjsi = __importStar(require("inner/mjs"));
+const typei = __importStar(require("inner"));
+cjsi;
+mjsi;
+typei;
+//// [index.js]
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..8093c39582ddc
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).symbols
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.ts, 9, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mts, 9, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "package/mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "package";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+import * as cjsi from "inner/cjs";
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+import * as mjsi from "inner/mjs";
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+import * as typei from "inner";
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cts, 9, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).types b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).types
new file mode 100644
index 0000000000000..85dad3ea25f98
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).types
@@ -0,0 +1,174 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjs from "package/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "package/mjs";
+>mjs : typeof mjs
+
+import * as type from "package";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+import * as cjsi from "inner/cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs";
+>mjs : typeof mjs
+
+import * as type from "inner";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesPackageImports(module=node12).errors.txt
new file mode 100644
index 0000000000000..cc174f1eb7e26
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=node12).errors.txt
@@ -0,0 +1,44 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/index.cts (2 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+                         ~~~~~~
+!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js",
+        "imports": {
+            "#cjs": "./index.cjs",
+            "#mjs": "./index.mjs",
+            "#type": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node12).js b/tests/baselines/reference/nodeModulesPackageImports(module=node12).js
new file mode 100644
index 0000000000000..7fb8361dd0ac8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=node12).js
@@ -0,0 +1,92 @@
+//// [tests/cases/conformance/node/nodeModulesPackageImports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.mts]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cts]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js",
+    "imports": {
+        "#cjs": "./index.cjs",
+        "#mjs": "./index.mjs",
+        "#type": "./index.js"
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const cjs = __importStar(require("#cjs"));
+const mjs = __importStar(require("#mjs"));
+const type = __importStar(require("#type"));
+cjs;
+mjs;
+type;
+//// [index.js]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+
+
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node12).symbols b/tests/baselines/reference/nodeModulesPackageImports(module=node12).symbols
new file mode 100644
index 0000000000000..2a0fece72371f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=node12).symbols
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node12).types b/tests/baselines/reference/nodeModulesPackageImports(module=node12).types
new file mode 100644
index 0000000000000..b4ade0559239b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=node12).types
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..cc174f1eb7e26
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).errors.txt
@@ -0,0 +1,44 @@
+tests/cases/conformance/node/index.cts(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/index.cts(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+    import * as type from "#type";
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/index.cts (2 errors) ====
+    // esm format file
+    import * as cjs from "#cjs";
+    import * as mjs from "#mjs";
+                         ~~~~~~
+!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "#type";
+                          ~~~~~~~
+!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    cjs;
+    mjs;
+    type;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js",
+        "imports": {
+            "#cjs": "./index.cjs",
+            "#mjs": "./index.mjs",
+            "#type": "./index.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).js b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).js
new file mode 100644
index 0000000000000..7fb8361dd0ac8
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).js
@@ -0,0 +1,92 @@
+//// [tests/cases/conformance/node/nodeModulesPackageImports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.mts]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cts]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js",
+    "imports": {
+        "#cjs": "./index.cjs",
+        "#mjs": "./index.mjs",
+        "#type": "./index.js"
+    }
+}
+
+//// [index.mjs]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const cjs = __importStar(require("#cjs"));
+const mjs = __importStar(require("#mjs"));
+const type = __importStar(require("#type"));
+cjs;
+mjs;
+type;
+//// [index.js]
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+
+
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
+//// [index.d.ts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).symbols
new file mode 100644
index 0000000000000..2a0fece72371f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).symbols
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.ts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.ts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.mts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.mts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.mts, 3, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+import * as mjs from "#mjs";
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+import * as type from "#type";
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
+cjs;
+>cjs : Symbol(cjs, Decl(index.cts, 1, 6))
+
+mjs;
+>mjs : Symbol(mjs, Decl(index.cts, 2, 6))
+
+type;
+>type : Symbol(type, Decl(index.cts, 3, 6))
+
diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).types b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).types
new file mode 100644
index 0000000000000..b4ade0559239b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).types
@@ -0,0 +1,60 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as cjs from "#cjs";
+>cjs : typeof cjs
+
+import * as mjs from "#mjs";
+>mjs : typeof mjs
+
+import * as type from "#type";
+>type : typeof type
+
+cjs;
+>cjs : typeof cjs
+
+mjs;
+>mjs : typeof mjs
+
+type;
+>type : typeof type
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).errors.txt
new file mode 100644
index 0000000000000..0dc3774d5ef60
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).errors.txt
@@ -0,0 +1,78 @@
+tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.cts (1 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+                          ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*": "./*.cjs",
+            "./mjs/*": "./*.mjs",
+            "./js/*": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).js b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).js
new file mode 100644
index 0000000000000..982cd292396a5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/nodeModulesPackagePatternExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mts]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cts]
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*": "./*.cjs",
+        "./mjs/*": "./*.mjs",
+        "./js/*": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index"));
+const mjsi = __importStar(require("inner/mjs/index"));
+const typei = __importStar(require("inner/js/index"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).symbols b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).symbols
new file mode 100644
index 0000000000000..adbb566941d1a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).types b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).types
new file mode 100644
index 0000000000000..28015ecbd24c3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node12).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : any
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof mjs
+
+import * as type from "inner/js/index";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..0dc3774d5ef60
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).errors.txt
@@ -0,0 +1,78 @@
+tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.cts (1 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index";
+    import * as mjsi from "inner/mjs/index";
+                          ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner/js/index";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index";
+    import * as mjs from "inner/mjs/index";
+                         ~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*": "./*.cjs",
+            "./mjs/*": "./*.mjs",
+            "./js/*": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).js b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).js
new file mode 100644
index 0000000000000..982cd292396a5
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/nodeModulesPackagePatternExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mts]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cts]
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*": "./*.cjs",
+        "./mjs/*": "./*.mjs",
+        "./js/*": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index"));
+const mjsi = __importStar(require("inner/mjs/index"));
+const typei = __importStar(require("inner/js/index"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..adbb566941d1a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+import * as typei from "inner/js/index";
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).types b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).types
new file mode 100644
index 0000000000000..28015ecbd24c3
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : any
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof mjs
+
+import * as type from "inner/js/index";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).errors.txt
new file mode 100644
index 0000000000000..6c400a3f69c84
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).errors.txt
@@ -0,0 +1,120 @@
+tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(3,23): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/index.cts(4,24): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(3,23): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/index.mts(4,24): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(3,23): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/index.ts(4,24): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(2,22): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(4,23): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.mts(2,22): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.mts(3,22): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.mts(4,23): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+
+
+==== tests/cases/conformance/node/index.ts (3 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as typei from "inner/js/index.js";
+                           ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.mts (3 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as typei from "inner/js/index.js";
+                           ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.cts (3 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index.cjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as typei from "inner/js/index.js";
+                           ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (3 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as type from "inner/js/index.js";
+                          ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (3 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index.cjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as type from "inner/js/index.js";
+                          ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (3 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/cjs/index.cjs' or its corresponding type declarations.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/mjs/index.mjs' or its corresponding type declarations.
+    import * as type from "inner/js/index.js";
+                          ~~~~~~~~~~~~~~~~~~~
+!!! error TS2307: Cannot find module 'inner/js/index.js' or its corresponding type declarations.
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*.cjs": "./*.cjs",
+            "./mjs/*.mjs": "./*.mjs",
+            "./js/*.js": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).js b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).js
new file mode 100644
index 0000000000000..0e0b80d540422
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mts]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cts]
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*.cjs": "./*.cjs",
+        "./mjs/*.mjs": "./*.mjs",
+        "./js/*.js": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index.cjs"));
+const mjsi = __importStar(require("inner/mjs/index.mjs"));
+const typei = __importStar(require("inner/js/index.js"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).symbols b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).symbols
new file mode 100644
index 0000000000000..0a9b4ceb3a00d
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).types b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).types
new file mode 100644
index 0000000000000..c7f760959691f
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node12).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : any
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : any
+
+import * as typei from "inner/js/index.js";
+>typei : any
+
+cjsi;
+>cjsi : any
+
+mjsi;
+>mjsi : any
+
+typei;
+>typei : any
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : any
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : any
+
+import * as typei from "inner/js/index.js";
+>typei : any
+
+cjsi;
+>cjsi : any
+
+mjsi;
+>mjsi : any
+
+typei;
+>typei : any
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : any
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : any
+
+import * as typei from "inner/js/index.js";
+>typei : any
+
+cjsi;
+>cjsi : any
+
+mjsi;
+>mjsi : any
+
+typei;
+>typei : any
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : any
+
+import * as type from "inner/js/index.js";
+>type : any
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : any
+
+export { type };
+>type : any
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : any
+
+import * as type from "inner/js/index.js";
+>type : any
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : any
+
+export { type };
+>type : any
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : any
+
+import * as type from "inner/js/index.js";
+>type : any
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : any
+
+export { type };
+>type : any
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..9aa041ab4186a
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).errors.txt
@@ -0,0 +1,78 @@
+tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
+tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+    import * as mjsi from "inner/mjs/index.mjs";
+    import * as typei from "inner/js/index.js";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as cjsi from "inner/cjs/index.cjs";
+    import * as mjsi from "inner/mjs/index.mjs";
+    import * as typei from "inner/js/index.js";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/index.cts (1 errors) ====
+    // cjs format file
+    import * as cjsi from "inner/cjs/index.cjs";
+    import * as mjsi from "inner/mjs/index.mjs";
+                          ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as typei from "inner/js/index.js";
+    cjsi;
+    mjsi;
+    typei;
+==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+                ~~~
+!!! error TS2303: Circular definition of import alias 'cjs'.
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index.js";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
+    // esm format file
+    import * as cjs from "inner/cjs/index.cjs";
+    import * as mjs from "inner/mjs/index.mjs";
+    import * as type from "inner/js/index.js";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ====
+    // cjs format file
+    import * as cjs from "inner/cjs/index.cjs";
+    import * as mjs from "inner/mjs/index.mjs";
+                         ~~~~~~~~~~~~~~~~~~~~~
+!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import * as type from "inner/js/index.js";
+    export { cjs };
+    export { mjs };
+    export { type };
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+    }
+==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
+    {
+        "name": "inner",
+        "private": true,
+        "exports": {
+            "./cjs/*.cjs": "./*.cjs",
+            "./mjs/*.mjs": "./*.mjs",
+            "./js/*.js": "./*.js"
+        }
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).js b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).js
new file mode 100644
index 0000000000000..0e0b80d540422
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).js
@@ -0,0 +1,120 @@
+//// [tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mts]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cts]
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.d.ts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.mts]
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [index.d.cts]
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*.cjs": "./*.cjs",
+        "./mjs/*.mjs": "./*.mjs",
+        "./js/*.js": "./*.js"
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.mjs]
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const cjsi = __importStar(require("inner/cjs/index.cjs"));
+const mjsi = __importStar(require("inner/mjs/index.mjs"));
+const typei = __importStar(require("inner/js/index.js"));
+cjsi;
+mjsi;
+typei;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).symbols b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).symbols
new file mode 100644
index 0000000000000..c8c8c3a38f8ab
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).symbols
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.ts, 3, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.mts, 3, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+import * as typei from "inner/js/index.js";
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+cjsi;
+>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
+
+mjsi;
+>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
+
+typei;
+>typei : Symbol(typei, Decl(index.cts, 3, 6))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.ts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(mjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(mjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
+
+export { type };
+>type : Symbol(mjs.cjs.type.type, Decl(index.d.ts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.mts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.mjs.type, Decl(index.d.mts, 6, 8))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
+
+import * as type from "inner/js/index.js";
+>type : Symbol(type, Decl(index.d.cts, 3, 6))
+
+export { cjs };
+>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
+
+export { mjs };
+>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
+
+export { type };
+>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
+
diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).types b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).types
new file mode 100644
index 0000000000000..efc768d50a237
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).types
@@ -0,0 +1,120 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index.js";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index.js";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+>cjsi : typeof cjsi
+
+import * as mjsi from "inner/mjs/index.mjs";
+>mjsi : typeof cjsi.mjs
+
+import * as typei from "inner/js/index.js";
+>typei : typeof cjsi.mjs.type
+
+cjsi;
+>cjsi : typeof cjsi
+
+mjsi;
+>mjsi : typeof cjsi.mjs
+
+typei;
+>typei : typeof cjsi.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : any
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : typeof mjs
+
+import * as type from "inner/js/index.js";
+>type : typeof mjs.cjs.type
+
+export { cjs };
+>cjs : any
+
+export { mjs };
+>mjs : typeof mjs
+
+export { type };
+>type : typeof mjs.cjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index.js";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+>cjs : typeof cjs
+
+import * as mjs from "inner/mjs/index.mjs";
+>mjs : typeof cjs.mjs
+
+import * as type from "inner/js/index.js";
+>type : typeof cjs.mjs.type
+
+export { cjs };
+>cjs : typeof cjs
+
+export { mjs };
+>mjs : typeof cjs.mjs
+
+export { type };
+>type : typeof cjs.mjs.type
+
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).errors.txt
new file mode 100644
index 0000000000000..012ef390621c9
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).errors.txt
@@ -0,0 +1,43 @@
+tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    import {h} from "../index.js";
+                    ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import mod = require("../index.js");
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f as _f} from "./index.js";
+    import mod2 = require("./index.js");
+    export async function f() {
+        const mod3 = await import ("../index.js");
+        const mod4 = await import ("./index.js");
+        h();
+    }
+==== tests/cases/conformance/node/index.ts (1 errors) ====
+    // esm format file
+    import {h as _h} from "./index.js";
+    import mod = require("./index.js");
+                         ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f} from "./subfolder/index.js";
+    import mod2 = require("./subfolder/index.js");
+    export async function h() {
+        const mod3 = await import ("./index.js");
+        const mod4 = await import ("./subfolder/index.js");
+        f();
+    }
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js
new file mode 100644
index 0000000000000..7ac63da59146b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js
@@ -0,0 +1,60 @@
+//// [tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts] ////
+
+//// [index.ts]
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+    const mod3 = await import ("../index.js");
+    const mod4 = await import ("./index.js");
+    h();
+}
+//// [index.ts]
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+    const mod3 = await import ("./index.js");
+    const mod4 = await import ("./subfolder/index.js");
+    f();
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+import { f } from "./subfolder/index.js";
+export async function h() {
+    const mod3 = await import("./index.js");
+    const mod4 = await import("./subfolder/index.js");
+    f();
+}
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = void 0;
+// cjs format file
+const index_js_1 = require("../index.js");
+async function f() {
+    const mod3 = await import("../index.js");
+    const mod4 = await import("./index.js");
+    (0, index_js_1.h)();
+}
+exports.f = f;
+
+
+//// [index.d.ts]
+export declare function h(): Promise<void>;
+//// [index.d.ts]
+export declare function f(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).symbols b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).symbols
new file mode 100644
index 0000000000000..8b03ab0af9f41
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).symbols
@@ -0,0 +1,58 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {h} from "../index.js";
+>h : Symbol(h, Decl(index.ts, 1, 8))
+
+import mod = require("../index.js");
+>mod : Symbol(mod, Decl(index.ts, 1, 30))
+
+import {f as _f} from "./index.js";
+>f : Symbol(f, Decl(index.ts, 4, 36))
+>_f : Symbol(_f, Decl(index.ts, 3, 8))
+
+import mod2 = require("./index.js");
+>mod2 : Symbol(mod2, Decl(index.ts, 3, 35))
+
+export async function f() {
+>f : Symbol(f, Decl(index.ts, 4, 36))
+
+    const mod3 = await import ("../index.js");
+>mod3 : Symbol(mod3, Decl(index.ts, 6, 9))
+>"../index.js" : Symbol(mod, Decl(index.ts, 0, 0))
+
+    const mod4 = await import ("./index.js");
+>mod4 : Symbol(mod4, Decl(index.ts, 7, 9))
+>"./index.js" : Symbol(mod2, Decl(index.ts, 0, 0))
+
+    h();
+>h : Symbol(h, Decl(index.ts, 1, 8))
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : Symbol(h, Decl(index.ts, 4, 46))
+>_h : Symbol(_h, Decl(index.ts, 1, 8))
+
+import mod = require("./index.js");
+>mod : Symbol(mod, Decl(index.ts, 1, 35))
+
+import {f} from "./subfolder/index.js";
+>f : Symbol(f, Decl(index.ts, 3, 8))
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : Symbol(mod2, Decl(index.ts, 3, 39))
+
+export async function h() {
+>h : Symbol(h, Decl(index.ts, 4, 46))
+
+    const mod3 = await import ("./index.js");
+>mod3 : Symbol(mod3, Decl(index.ts, 6, 9))
+>"./index.js" : Symbol(mod, Decl(index.ts, 0, 0))
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : Symbol(mod4, Decl(index.ts, 7, 9))
+>"./subfolder/index.js" : Symbol(mod2, Decl(index.ts, 0, 0))
+
+    f();
+>f : Symbol(f, Decl(index.ts, 3, 8))
+}
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).types b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).types
new file mode 100644
index 0000000000000..8ca6d52152161
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).types
@@ -0,0 +1,68 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {h} from "../index.js";
+>h : () => Promise<void>
+
+import mod = require("../index.js");
+>mod : typeof mod
+
+import {f as _f} from "./index.js";
+>f : () => Promise<void>
+>_f : () => Promise<void>
+
+import mod2 = require("./index.js");
+>mod2 : typeof mod2
+
+export async function f() {
+>f : () => Promise<void>
+
+    const mod3 = await import ("../index.js");
+>mod3 : typeof mod
+>await import ("../index.js") : typeof mod
+>import ("../index.js") : Promise<typeof mod>
+>"../index.js" : "../index.js"
+
+    const mod4 = await import ("./index.js");
+>mod4 : typeof mod2
+>await import ("./index.js") : typeof mod2
+>import ("./index.js") : Promise<typeof mod2>
+>"./index.js" : "./index.js"
+
+    h();
+>h() : Promise<void>
+>h : () => Promise<void>
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : () => Promise<void>
+>_h : () => Promise<void>
+
+import mod = require("./index.js");
+>mod : typeof mod
+
+import {f} from "./subfolder/index.js";
+>f : () => Promise<void>
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : typeof mod2
+
+export async function h() {
+>h : () => Promise<void>
+
+    const mod3 = await import ("./index.js");
+>mod3 : typeof mod
+>await import ("./index.js") : typeof mod
+>import ("./index.js") : Promise<typeof mod>
+>"./index.js" : "./index.js"
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : typeof mod2
+>await import ("./subfolder/index.js") : typeof mod2
+>import ("./subfolder/index.js") : Promise<typeof mod2>
+>"./subfolder/index.js" : "./subfolder/index.js"
+
+    f();
+>f() : Promise<void>
+>f : () => Promise<void>
+}
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..012ef390621c9
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt
@@ -0,0 +1,43 @@
+tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    import {h} from "../index.js";
+                    ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import mod = require("../index.js");
+                         ~~~~~~~~~~~~~
+!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f as _f} from "./index.js";
+    import mod2 = require("./index.js");
+    export async function f() {
+        const mod3 = await import ("../index.js");
+        const mod4 = await import ("./index.js");
+        h();
+    }
+==== tests/cases/conformance/node/index.ts (1 errors) ====
+    // esm format file
+    import {h as _h} from "./index.js";
+    import mod = require("./index.js");
+                         ~~~~~~~~~~~~
+!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    import {f} from "./subfolder/index.js";
+    import mod2 = require("./subfolder/index.js");
+    export async function h() {
+        const mod3 = await import ("./index.js");
+        const mod4 = await import ("./subfolder/index.js");
+        f();
+    }
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js
new file mode 100644
index 0000000000000..7ac63da59146b
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js
@@ -0,0 +1,60 @@
+//// [tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts] ////
+
+//// [index.ts]
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+    const mod3 = await import ("../index.js");
+    const mod4 = await import ("./index.js");
+    h();
+}
+//// [index.ts]
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+    const mod3 = await import ("./index.js");
+    const mod4 = await import ("./subfolder/index.js");
+    f();
+}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+import { f } from "./subfolder/index.js";
+export async function h() {
+    const mod3 = await import("./index.js");
+    const mod4 = await import("./subfolder/index.js");
+    f();
+}
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = void 0;
+// cjs format file
+const index_js_1 = require("../index.js");
+async function f() {
+    const mod3 = await import("../index.js");
+    const mod4 = await import("./index.js");
+    (0, index_js_1.h)();
+}
+exports.f = f;
+
+
+//// [index.d.ts]
+export declare function h(): Promise<void>;
+//// [index.d.ts]
+export declare function f(): Promise<void>;
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).symbols b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).symbols
new file mode 100644
index 0000000000000..8b03ab0af9f41
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).symbols
@@ -0,0 +1,58 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {h} from "../index.js";
+>h : Symbol(h, Decl(index.ts, 1, 8))
+
+import mod = require("../index.js");
+>mod : Symbol(mod, Decl(index.ts, 1, 30))
+
+import {f as _f} from "./index.js";
+>f : Symbol(f, Decl(index.ts, 4, 36))
+>_f : Symbol(_f, Decl(index.ts, 3, 8))
+
+import mod2 = require("./index.js");
+>mod2 : Symbol(mod2, Decl(index.ts, 3, 35))
+
+export async function f() {
+>f : Symbol(f, Decl(index.ts, 4, 36))
+
+    const mod3 = await import ("../index.js");
+>mod3 : Symbol(mod3, Decl(index.ts, 6, 9))
+>"../index.js" : Symbol(mod, Decl(index.ts, 0, 0))
+
+    const mod4 = await import ("./index.js");
+>mod4 : Symbol(mod4, Decl(index.ts, 7, 9))
+>"./index.js" : Symbol(mod2, Decl(index.ts, 0, 0))
+
+    h();
+>h : Symbol(h, Decl(index.ts, 1, 8))
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : Symbol(h, Decl(index.ts, 4, 46))
+>_h : Symbol(_h, Decl(index.ts, 1, 8))
+
+import mod = require("./index.js");
+>mod : Symbol(mod, Decl(index.ts, 1, 35))
+
+import {f} from "./subfolder/index.js";
+>f : Symbol(f, Decl(index.ts, 3, 8))
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : Symbol(mod2, Decl(index.ts, 3, 39))
+
+export async function h() {
+>h : Symbol(h, Decl(index.ts, 4, 46))
+
+    const mod3 = await import ("./index.js");
+>mod3 : Symbol(mod3, Decl(index.ts, 6, 9))
+>"./index.js" : Symbol(mod, Decl(index.ts, 0, 0))
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : Symbol(mod4, Decl(index.ts, 7, 9))
+>"./subfolder/index.js" : Symbol(mod2, Decl(index.ts, 0, 0))
+
+    f();
+>f : Symbol(f, Decl(index.ts, 3, 8))
+}
diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).types b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).types
new file mode 100644
index 0000000000000..8ca6d52152161
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).types
@@ -0,0 +1,68 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+import {h} from "../index.js";
+>h : () => Promise<void>
+
+import mod = require("../index.js");
+>mod : typeof mod
+
+import {f as _f} from "./index.js";
+>f : () => Promise<void>
+>_f : () => Promise<void>
+
+import mod2 = require("./index.js");
+>mod2 : typeof mod2
+
+export async function f() {
+>f : () => Promise<void>
+
+    const mod3 = await import ("../index.js");
+>mod3 : typeof mod
+>await import ("../index.js") : typeof mod
+>import ("../index.js") : Promise<typeof mod>
+>"../index.js" : "../index.js"
+
+    const mod4 = await import ("./index.js");
+>mod4 : typeof mod2
+>await import ("./index.js") : typeof mod2
+>import ("./index.js") : Promise<typeof mod2>
+>"./index.js" : "./index.js"
+
+    h();
+>h() : Promise<void>
+>h : () => Promise<void>
+}
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import {h as _h} from "./index.js";
+>h : () => Promise<void>
+>_h : () => Promise<void>
+
+import mod = require("./index.js");
+>mod : typeof mod
+
+import {f} from "./subfolder/index.js";
+>f : () => Promise<void>
+
+import mod2 = require("./subfolder/index.js");
+>mod2 : typeof mod2
+
+export async function h() {
+>h : () => Promise<void>
+
+    const mod3 = await import ("./index.js");
+>mod3 : typeof mod
+>await import ("./index.js") : typeof mod
+>import ("./index.js") : Promise<typeof mod>
+>"./index.js" : "./index.js"
+
+    const mod4 = await import ("./subfolder/index.js");
+>mod4 : typeof mod2
+>await import ("./subfolder/index.js") : typeof mod2
+>import ("./subfolder/index.js") : Promise<typeof mod2>
+>"./subfolder/index.js" : "./subfolder/index.js"
+
+    f();
+>f() : Promise<void>
+>f : () => Promise<void>
+}
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).errors.txt
new file mode 100644
index 0000000000000..3a02a6e3d3737
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).errors.txt
@@ -0,0 +1,34 @@
+tests/cases/conformance/node/index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/subfolder/index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    const x = await 1;
+              ~~~~~
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+    export {x};
+    for await (const y of []) {}
+        ~~~~~
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+==== tests/cases/conformance/node/index.ts (2 errors) ====
+    // esm format file
+    const x = await 1;
+              ~~~~~
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+    export {x};
+    for await (const y of []) {}
+        ~~~~~
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js
new file mode 100644
index 0000000000000..8d33777f0c4e7
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js
@@ -0,0 +1,44 @@
+//// [tests/cases/conformance/node/nodeModulesTopLevelAwait.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [index.ts]
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = await 1;
+exports.x = x;
+for await (const y of []) { }
+//// [index.js]
+// esm format file
+const x = await 1;
+export { x };
+for await (const y of []) { }
+
+
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).symbols b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).symbols
new file mode 100644
index 0000000000000..624f09cb77334
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = await 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.ts, 3, 16))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = await 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.ts, 3, 16))
+
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).types b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).types
new file mode 100644
index 0000000000000..ae8108f4020a2
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).types
@@ -0,0 +1,28 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..a8fa4008492e7
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt
@@ -0,0 +1,28 @@
+tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/node/subfolder/index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+
+
+==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ====
+    // cjs format file
+    const x = await 1;
+              ~~~~~
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+    export {x};
+    for await (const y of []) {}
+        ~~~~~
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    const x = await 1;
+    export {x};
+    for await (const y of []) {}
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module"
+    }
+==== tests/cases/conformance/node/subfolder/package.json (0 errors) ====
+    {
+        "type": "commonjs"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js
new file mode 100644
index 0000000000000..8d33777f0c4e7
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js
@@ -0,0 +1,44 @@
+//// [tests/cases/conformance/node/nodeModulesTopLevelAwait.ts] ////
+
+//// [index.ts]
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [index.ts]
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+//// [package.json]
+{
+    "type": "commonjs"
+}
+
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.x = void 0;
+// cjs format file
+const x = await 1;
+exports.x = x;
+for await (const y of []) { }
+//// [index.js]
+// esm format file
+const x = await 1;
+export { x };
+for await (const y of []) { }
+
+
+//// [index.d.ts]
+declare const x = 1;
+export { x };
+//// [index.d.ts]
+declare const x = 1;
+export { x };
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).symbols b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).symbols
new file mode 100644
index 0000000000000..624f09cb77334
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).symbols
@@ -0,0 +1,22 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = await 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.ts, 3, 16))
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = await 1;
+>x : Symbol(x, Decl(index.ts, 1, 5))
+
+export {x};
+>x : Symbol(x, Decl(index.ts, 2, 8))
+
+for await (const y of []) {}
+>y : Symbol(y, Decl(index.ts, 3, 16))
+
diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).types b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).types
new file mode 100644
index 0000000000000..ae8108f4020a2
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).types
@@ -0,0 +1,28 @@
+=== tests/cases/conformance/node/subfolder/index.ts ===
+// cjs format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+const x = await 1;
+>x : 1
+>await 1 : 1
+>1 : 1
+
+export {x};
+>x : 1
+
+for await (const y of []) {}
+>y : any
+>[] : undefined[]
+
diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).js b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).js
new file mode 100644
index 0000000000000..8cb62238370ee
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).js
@@ -0,0 +1,94 @@
+//// [tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+//// [index.mts]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+//// [index.cts]
+// cjs format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+//// [index.d.ts]
+// cjs format file
+export const noConditionsApplied = true;
+//// [index.d.mts]
+// esm format file
+export const importConditionApplied = true;
+//// [index.d.cts]
+// cjs format file
+export const wrongConditionApplied = true;
+//// [old-types.d.ts]
+export const noVersionApplied = true;
+//// [new-types.d.ts]
+export const correctVersionApplied = true;
+//// [future-types.d.ts]
+export const futureVersionApplied = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        ".": {
+            "types@>=10000": "./future-types.d.ts",
+            "types@>=1": "./new-types.d.ts",
+            "types": "./old-types.d.ts",
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+//// [index.mjs]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const mod = __importStar(require("inner"));
+mod.correctVersionApplied;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).symbols b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).symbols
new file mode 100644
index 0000000000000..a9d7f0b89eedb
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).symbols
@@ -0,0 +1,57 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as mod from "inner";
+>mod : Symbol(mod, Decl(index.ts, 1, 6))
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+>mod : Symbol(mod, Decl(index.ts, 1, 6))
+>correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as mod from "inner";
+>mod : Symbol(mod, Decl(index.mts, 1, 6))
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+>mod : Symbol(mod, Decl(index.mts, 1, 6))
+>correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as mod from "inner";
+>mod : Symbol(mod, Decl(index.cts, 1, 6))
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+>mod : Symbol(mod, Decl(index.cts, 1, 6))
+>correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+export const noConditionsApplied = true;
+>noConditionsApplied : Symbol(noConditionsApplied, Decl(index.d.ts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+export const importConditionApplied = true;
+>importConditionApplied : Symbol(importConditionApplied, Decl(index.d.mts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+export const wrongConditionApplied = true;
+>wrongConditionApplied : Symbol(wrongConditionApplied, Decl(index.d.cts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/old-types.d.ts ===
+export const noVersionApplied = true;
+>noVersionApplied : Symbol(noVersionApplied, Decl(old-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/new-types.d.ts ===
+export const correctVersionApplied = true;
+>correctVersionApplied : Symbol(correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/future-types.d.ts ===
+export const futureVersionApplied = true;
+>futureVersionApplied : Symbol(futureVersionApplied, Decl(future-types.d.ts, 0, 12))
+
diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).types b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).types
new file mode 100644
index 0000000000000..fe286fd667465
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node12).types
@@ -0,0 +1,63 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as mod from "inner";
+>mod : typeof mod
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : true
+>mod : typeof mod
+>correctVersionApplied : true
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as mod from "inner";
+>mod : typeof mod
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : true
+>mod : typeof mod
+>correctVersionApplied : true
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as mod from "inner";
+>mod : typeof mod
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : true
+>mod : typeof mod
+>correctVersionApplied : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+export const noConditionsApplied = true;
+>noConditionsApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+export const importConditionApplied = true;
+>importConditionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+export const wrongConditionApplied = true;
+>wrongConditionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/old-types.d.ts ===
+export const noVersionApplied = true;
+>noVersionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/new-types.d.ts ===
+export const correctVersionApplied = true;
+>correctVersionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/future-types.d.ts ===
+export const futureVersionApplied = true;
+>futureVersionApplied : true
+>true : true
+
diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).js b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).js
new file mode 100644
index 0000000000000..8cb62238370ee
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).js
@@ -0,0 +1,94 @@
+//// [tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+//// [index.mts]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+//// [index.cts]
+// cjs format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+//// [index.d.ts]
+// cjs format file
+export const noConditionsApplied = true;
+//// [index.d.mts]
+// esm format file
+export const importConditionApplied = true;
+//// [index.d.cts]
+// cjs format file
+export const wrongConditionApplied = true;
+//// [old-types.d.ts]
+export const noVersionApplied = true;
+//// [new-types.d.ts]
+export const correctVersionApplied = true;
+//// [future-types.d.ts]
+export const futureVersionApplied = true;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+//// [package.json]
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        ".": {
+            "types@>=10000": "./future-types.d.ts",
+            "types@>=1": "./new-types.d.ts",
+            "types": "./old-types.d.ts",
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+    }
+}
+
+//// [index.js]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+//// [index.mjs]
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// cjs format file
+const mod = __importStar(require("inner"));
+mod.correctVersionApplied;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).symbols b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).symbols
new file mode 100644
index 0000000000000..a9d7f0b89eedb
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).symbols
@@ -0,0 +1,57 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as mod from "inner";
+>mod : Symbol(mod, Decl(index.ts, 1, 6))
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+>mod : Symbol(mod, Decl(index.ts, 1, 6))
+>correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as mod from "inner";
+>mod : Symbol(mod, Decl(index.mts, 1, 6))
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+>mod : Symbol(mod, Decl(index.mts, 1, 6))
+>correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as mod from "inner";
+>mod : Symbol(mod, Decl(index.cts, 1, 6))
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+>mod : Symbol(mod, Decl(index.cts, 1, 6))
+>correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+export const noConditionsApplied = true;
+>noConditionsApplied : Symbol(noConditionsApplied, Decl(index.d.ts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+export const importConditionApplied = true;
+>importConditionApplied : Symbol(importConditionApplied, Decl(index.d.mts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+export const wrongConditionApplied = true;
+>wrongConditionApplied : Symbol(wrongConditionApplied, Decl(index.d.cts, 1, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/old-types.d.ts ===
+export const noVersionApplied = true;
+>noVersionApplied : Symbol(noVersionApplied, Decl(old-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/new-types.d.ts ===
+export const correctVersionApplied = true;
+>correctVersionApplied : Symbol(correctVersionApplied, Decl(new-types.d.ts, 0, 12))
+
+=== tests/cases/conformance/node/node_modules/inner/future-types.d.ts ===
+export const futureVersionApplied = true;
+>futureVersionApplied : Symbol(futureVersionApplied, Decl(future-types.d.ts, 0, 12))
+
diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).types b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).types
new file mode 100644
index 0000000000000..fe286fd667465
--- /dev/null
+++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=nodenext).types
@@ -0,0 +1,63 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as mod from "inner";
+>mod : typeof mod
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : true
+>mod : typeof mod
+>correctVersionApplied : true
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as mod from "inner";
+>mod : typeof mod
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : true
+>mod : typeof mod
+>correctVersionApplied : true
+
+=== tests/cases/conformance/node/index.cts ===
+// cjs format file
+import * as mod from "inner";
+>mod : typeof mod
+
+mod.correctVersionApplied;
+>mod.correctVersionApplied : true
+>mod : typeof mod
+>correctVersionApplied : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
+// cjs format file
+export const noConditionsApplied = true;
+>noConditionsApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
+// esm format file
+export const importConditionApplied = true;
+>importConditionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
+// cjs format file
+export const wrongConditionApplied = true;
+>wrongConditionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/old-types.d.ts ===
+export const noVersionApplied = true;
+>noVersionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/new-types.d.ts ===
+export const correctVersionApplied = true;
+>correctVersionApplied : true
+>true : true
+
+=== tests/cases/conformance/node/node_modules/inner/future-types.d.ts ===
+export const futureVersionApplied = true;
+>futureVersionApplied : true
+>true : true
+
diff --git a/tests/baselines/reference/nodePackageSelfName(module=node12).errors.txt b/tests/baselines/reference/nodePackageSelfName(module=node12).errors.txt
new file mode 100644
index 0000000000000..c1573b8f51dd8
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=node12).errors.txt
@@ -0,0 +1,24 @@
+tests/cases/conformance/node/index.cts(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/index.cts (1 errors) ====
+    // esm format file
+    import * as self from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    self;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodePackageSelfName(module=node12).js b/tests/baselines/reference/nodePackageSelfName(module=node12).js
new file mode 100644
index 0000000000000..23c9f6f1fa067
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=node12).js
@@ -0,0 +1,63 @@
+//// [tests/cases/conformance/node/nodePackageSelfName.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mts]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cts]
+// esm format file
+import * as self from "package";
+self;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js"
+}
+
+//// [index.js]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mjs]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const self = __importStar(require("package"));
+self;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodePackageSelfName(module=node12).symbols b/tests/baselines/reference/nodePackageSelfName(module=node12).symbols
new file mode 100644
index 0000000000000..44b9566b90c93
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=node12).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.ts, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.ts, 1, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.mts, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.mts, 1, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.cts, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.cts, 1, 6))
+
diff --git a/tests/baselines/reference/nodePackageSelfName(module=node12).types b/tests/baselines/reference/nodePackageSelfName(module=node12).types
new file mode 100644
index 0000000000000..b41eef255ab89
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=node12).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
diff --git a/tests/baselines/reference/nodePackageSelfName(module=nodenext).errors.txt b/tests/baselines/reference/nodePackageSelfName(module=nodenext).errors.txt
new file mode 100644
index 0000000000000..c1573b8f51dd8
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=nodenext).errors.txt
@@ -0,0 +1,24 @@
+tests/cases/conformance/node/index.cts(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+
+==== tests/cases/conformance/node/index.ts (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/index.mts (0 errors) ====
+    // esm format file
+    import * as self from "package";
+    self;
+==== tests/cases/conformance/node/index.cts (1 errors) ====
+    // esm format file
+    import * as self from "package";
+                          ~~~~~~~~~
+!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+    self;
+==== tests/cases/conformance/node/package.json (0 errors) ====
+    {
+        "name": "package",
+        "private": true,
+        "type": "module",
+        "exports": "./index.js"
+    }
\ No newline at end of file
diff --git a/tests/baselines/reference/nodePackageSelfName(module=nodenext).js b/tests/baselines/reference/nodePackageSelfName(module=nodenext).js
new file mode 100644
index 0000000000000..23c9f6f1fa067
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=nodenext).js
@@ -0,0 +1,63 @@
+//// [tests/cases/conformance/node/nodePackageSelfName.ts] ////
+
+//// [index.ts]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mts]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cts]
+// esm format file
+import * as self from "package";
+self;
+//// [package.json]
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js"
+}
+
+//// [index.js]
+// esm format file
+import * as self from "package";
+self;
+//// [index.mjs]
+// esm format file
+import * as self from "package";
+self;
+//// [index.cjs]
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// esm format file
+const self = __importStar(require("package"));
+self;
+
+
+//// [index.d.ts]
+export {};
+//// [index.d.mts]
+export {};
+//// [index.d.cts]
+export {};
diff --git a/tests/baselines/reference/nodePackageSelfName(module=nodenext).symbols b/tests/baselines/reference/nodePackageSelfName(module=nodenext).symbols
new file mode 100644
index 0000000000000..44b9566b90c93
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=nodenext).symbols
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.ts, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.ts, 1, 6))
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.mts, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.mts, 1, 6))
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as self from "package";
+>self : Symbol(self, Decl(index.cts, 1, 6))
+
+self;
+>self : Symbol(self, Decl(index.cts, 1, 6))
+
diff --git a/tests/baselines/reference/nodePackageSelfName(module=nodenext).types b/tests/baselines/reference/nodePackageSelfName(module=nodenext).types
new file mode 100644
index 0000000000000..b41eef255ab89
--- /dev/null
+++ b/tests/baselines/reference/nodePackageSelfName(module=nodenext).types
@@ -0,0 +1,24 @@
+=== tests/cases/conformance/node/index.ts ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/index.mts ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
+=== tests/cases/conformance/node/index.cts ===
+// esm format file
+import * as self from "package";
+>self : typeof self
+
+self;
+>self : typeof self
+
diff --git a/tests/baselines/reference/parser.forAwait.es2018.errors.txt b/tests/baselines/reference/parser.forAwait.es2018.errors.txt
index cc70ef748d0a7..5969e4b6256b1 100644
--- a/tests/baselines/reference/parser.forAwait.es2018.errors.txt
+++ b/tests/baselines/reference/parser.forAwait.es2018.errors.txt
@@ -8,10 +8,10 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/inFunctionDeclWithExprIsE
 tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithDeclIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules.
 tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithExprIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules.
 tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.
-tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
 tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,23): error TS2304: Cannot find name 'y'.
 tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.
-tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
 tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,12): error TS2304: Cannot find name 'x'.
 tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'.
 
@@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.t
         ~~~~~
 !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.
         ~~~~~
-!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
                           ~
 !!! error TS2304: Cannot find name 'y'.
     }
@@ -30,7 +30,7 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.t
         ~~~~~
 !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.
         ~~~~~
-!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
                ~
 !!! error TS2304: Cannot find name 'x'.
                     ~
diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt
index 071a8c6b528bc..ce9c2a81f90ee 100644
--- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt
+++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt
@@ -1,10 +1,10 @@
 error TS6053: File 'a.ts' not found.
   The file is in the program because:
     Root file specified for compilation
-error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
   The file is in the program because:
     Root file specified for compilation
-error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
+error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
   The file is in the program because:
     Root file specified for compilation
 
@@ -12,9 +12,9 @@ error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx',
 !!! error TS6053: File 'a.ts' not found.
 !!! error TS6053:   The file is in the program because:
 !!! error TS6053:     Root file specified for compilation
-!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
 !!! error TS6054:   The file is in the program because:
 !!! error TS6054:     Root file specified for compilation
-!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
+!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
 !!! error TS6231:   The file is in the program because:
 !!! error TS6231:     Root file specified for compilation
\ No newline at end of file
diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt
index 071a8c6b528bc..ce9c2a81f90ee 100644
--- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt
+++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt
@@ -1,10 +1,10 @@
 error TS6053: File 'a.ts' not found.
   The file is in the program because:
     Root file specified for compilation
-error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
   The file is in the program because:
     Root file specified for compilation
-error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
+error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
   The file is in the program because:
     Root file specified for compilation
 
@@ -12,9 +12,9 @@ error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx',
 !!! error TS6053: File 'a.ts' not found.
 !!! error TS6053:   The file is in the program because:
 !!! error TS6053:     Root file specified for compilation
-!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
 !!! error TS6054:   The file is in the program because:
 !!! error TS6054:     Root file specified for compilation
-!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
+!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
 !!! error TS6231:   The file is in the program because:
 !!! error TS6231:     Root file specified for compilation
\ No newline at end of file
diff --git a/tests/baselines/reference/requireOfJsonFileWithAmd.errors.txt b/tests/baselines/reference/requireOfJsonFileWithAmd.errors.txt
index 43a71b9fbb590..361d1d71f0eaf 100644
--- a/tests/baselines/reference/requireOfJsonFileWithAmd.errors.txt
+++ b/tests/baselines/reference/requireOfJsonFileWithAmd.errors.txt
@@ -1,17 +1,14 @@
 error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.
 tests/cases/compiler/file1.ts(1,21): error TS2792: Cannot find module './b'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
-tests/cases/compiler/file1.ts(3,21): error TS2792: Cannot find module './b.json'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
 
 
 !!! error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.
-==== tests/cases/compiler/file1.ts (2 errors) ====
+==== tests/cases/compiler/file1.ts (1 errors) ====
     import b1 = require('./b');
                         ~~~~~
 !!! error TS2792: Cannot find module './b'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
     let x = b1.a;
     import b2 = require('./b.json');
-                        ~~~~~~~~~~
-!!! error TS2792: Cannot find module './b.json'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
     if (x) {
         let b = b2.b;
         x = (b1.b === b);
diff --git a/tests/baselines/reference/requireOfJsonFileWithAmd.js b/tests/baselines/reference/requireOfJsonFileWithAmd.js
index 6e4928174c2d8..6d02fb151c0ab 100644
--- a/tests/baselines/reference/requireOfJsonFileWithAmd.js
+++ b/tests/baselines/reference/requireOfJsonFileWithAmd.js
@@ -15,6 +15,11 @@ if (x) {
     "b": "hello"
 }
 
+//// [out/b.json]
+{
+    "a": true,
+    "b": "hello"
+}
 //// [out/file1.js]
 define(["require", "exports", "./b", "./b.json"], function (require, exports, b1, b2) {
     "use strict";
diff --git a/tests/baselines/reference/requireOfJsonFileWithAmd.symbols b/tests/baselines/reference/requireOfJsonFileWithAmd.symbols
index 1729461ef07bb..c32e6d05df4ec 100644
--- a/tests/baselines/reference/requireOfJsonFileWithAmd.symbols
+++ b/tests/baselines/reference/requireOfJsonFileWithAmd.symbols
@@ -14,7 +14,9 @@ if (x) {
 
     let b = b2.b;
 >b : Symbol(b, Decl(file1.ts, 4, 7))
+>b2.b : Symbol("b", Decl(b.json, 1, 14))
 >b2 : Symbol(b2, Decl(file1.ts, 1, 13))
+>b : Symbol("b", Decl(b.json, 1, 14))
 
     x = (b1.b === b);
 >x : Symbol(x, Decl(file1.ts, 1, 3))
@@ -22,3 +24,11 @@ if (x) {
 >b : Symbol(b, Decl(file1.ts, 4, 7))
 }
 
+=== tests/cases/compiler/b.json ===
+{
+    "a": true,
+>"a" : Symbol("a", Decl(b.json, 0, 1))
+
+    "b": "hello"
+>"b" : Symbol("b", Decl(b.json, 1, 14))
+}
diff --git a/tests/baselines/reference/requireOfJsonFileWithAmd.types b/tests/baselines/reference/requireOfJsonFileWithAmd.types
index 7984743550dae..6e06eecf0e17a 100644
--- a/tests/baselines/reference/requireOfJsonFileWithAmd.types
+++ b/tests/baselines/reference/requireOfJsonFileWithAmd.types
@@ -9,16 +9,16 @@ let x = b1.a;
 >a : any
 
 import b2 = require('./b.json');
->b2 : any
+>b2 : { a: boolean; b: string; }
 
 if (x) {
 >x : any
 
     let b = b2.b;
->b : any
->b2.b : any
->b2 : any
->b : any
+>b : string
+>b2.b : string
+>b2 : { a: boolean; b: string; }
+>b : string
 
     x = (b1.b === b);
 >x = (b1.b === b) : boolean
@@ -28,6 +28,18 @@ if (x) {
 >b1.b : any
 >b1 : any
 >b : any
->b : any
+>b : string
 }
 
+=== tests/cases/compiler/b.json ===
+{
+>{    "a": true,    "b": "hello"} : { a: boolean; b: string; }
+
+    "a": true,
+>"a" : boolean
+>true : true
+
+    "b": "hello"
+>"b" : string
+>"hello" : "hello"
+}
diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.errors.txt
index ac67223d7e6a9..6d1d5b7751429 100644
--- a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.errors.txt
+++ b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.errors.txt
@@ -1,15 +1,12 @@
 error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.
 tests/cases/compiler/file1.ts(1,1): error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'.
-tests/cases/compiler/file1.ts(1,20): error TS2792: Cannot find module './b.json'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
 
 
 !!! error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.
-==== tests/cases/compiler/file1.ts (2 errors) ====
+==== tests/cases/compiler/file1.ts (1 errors) ====
     import * as b from './b.json';
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 !!! error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'.
-                       ~~~~~~~~~~
-!!! error TS2792: Cannot find module './b.json'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
     
 ==== tests/cases/compiler/b.json (0 errors) ====
     {
diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.js b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.js
index a94bdd896dddd..ee7f0e24127c3 100644
--- a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.js
+++ b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.js
@@ -9,6 +9,11 @@ import * as b from './b.json';
     "b": "hello"
 }
 
+//// [out/b.json]
+{
+    "a": true,
+    "b": "hello"
+}
 //// [out/file1.js]
 "use strict";
 exports.__esModule = true;
diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.symbols b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.symbols
index 27f9d9d811796..827f2e674e630 100644
--- a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.symbols
+++ b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.symbols
@@ -2,3 +2,11 @@
 import * as b from './b.json';
 >b : Symbol(b, Decl(file1.ts, 0, 6))
 
+=== tests/cases/compiler/b.json ===
+{
+    "a": true,
+>"a" : Symbol("a", Decl(b.json, 0, 1))
+
+    "b": "hello"
+>"b" : Symbol("b", Decl(b.json, 1, 14))
+}
diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.types b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.types
index 999e912a291e7..20cc701340cac 100644
--- a/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.types
+++ b/tests/baselines/reference/requireOfJsonFileWithModuleEmitNone.types
@@ -1,4 +1,16 @@
 === tests/cases/compiler/file1.ts ===
 import * as b from './b.json';
->b : any
+>b : { a: boolean; b: string; }
 
+=== tests/cases/compiler/b.json ===
+{
+>{    "a": true,    "b": "hello"} : { a: boolean; b: string; }
+
+    "a": true,
+>"a" : boolean
+>true : true
+
+    "b": "hello"
+>"b" : string
+>"hello" : "hello"
+}
diff --git a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json
index a8e76904b715d..e13cc91a3da29 100644
--- a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json
+++ b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json
@@ -9,6 +9,8 @@
     "File '/node_modules/foo/bar/foobar.json.ts' does not exist.",
     "File '/node_modules/foo/bar/foobar.json.tsx' does not exist.",
     "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.",
+    "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.",
+    "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.",
     "Directory '/node_modules/foo/bar/foobar.json' does not exist, skipping all lookups in it.",
     "Trying substitution 'src/types', candidate module location: 'src/types'.",
     "Loading module as file / folder, candidate module location '/src/types', target file type 'TypeScript'.",
@@ -17,7 +19,10 @@
     "File '/node_modules/foo/bar/foobar.json.ts' does not exist.",
     "File '/node_modules/foo/bar/foobar.json.tsx' does not exist.",
     "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.",
+    "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.",
+    "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.",
     "Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
+    "File name '/node_modules/@types/foo/bar/foobar.json' has a '.json' extension - stripping it.",
     "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/bar/foobar.json'.",
     "'paths' option is specified, looking for a pattern to match module name 'foo/bar/foobar.json'.",
     "Module name 'foo/bar/foobar.json', matched pattern '*'.",
@@ -25,18 +30,7 @@
     "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.json', target file type 'JavaScript'.",
     "File '/node_modules/foo/bar/foobar.json.js' does not exist.",
     "File '/node_modules/foo/bar/foobar.json.jsx' does not exist.",
-    "Directory '/node_modules/foo/bar/foobar.json' does not exist, skipping all lookups in it.",
-    "Trying substitution 'src/types', candidate module location: 'src/types'.",
-    "Loading module as file / folder, candidate module location '/src/types', target file type 'JavaScript'.",
-    "Loading module 'foo/bar/foobar.json' from 'node_modules' folder, target file type 'JavaScript'.",
-    "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.",
-    "File '/node_modules/foo/bar/foobar.json.js' does not exist.",
-    "File '/node_modules/foo/bar/foobar.json.jsx' does not exist.",
-    "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/bar/foobar.json'.",
-    "'paths' option is specified, looking for a pattern to match module name 'foo/bar/foobar.json'.",
-    "Module name 'foo/bar/foobar.json', matched pattern '*'.",
-    "Trying substitution 'node_modules/*', candidate module location: 'node_modules/foo/bar/foobar.json'.",
-    "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.json', target file type 'Json'.",
+    "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.",
     "File '/node_modules/foo/bar/foobar.json' exist - use it as a name resolution result.",
     "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.",
     "======== Module name 'foo/bar/foobar.json' was successfully resolved to '/node_modules/foo/bar/foobar.json'. ========"
diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt
index aeea7ac641fa2..1c4b9b820b7ed 100644
--- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt
+++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt
@@ -1,13 +1,13 @@
-tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
-tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
-tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
 
 
 ==== tests/cases/conformance/externalModules/index.ts (2 errors) ====
     export const x = 1;
     await x;
     ~~~~~
-!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
     
     // reparse element access as await
     await [x];
@@ -53,7 +53,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level '
     declare const dec: any;
     @(await dec)
       ~~~~~
-!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
     class C {
     }
     
@@ -84,7 +84,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level '
     
     for await (const item of arr) {
         ~~~~~
-!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
       item;
     }
     
\ No newline at end of file
diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt
index aeea7ac641fa2..1c4b9b820b7ed 100644
--- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt
+++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt
@@ -1,13 +1,13 @@
-tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
-tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
-tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
+tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
 
 
 ==== tests/cases/conformance/externalModules/index.ts (2 errors) ====
     export const x = 1;
     await x;
     ~~~~~
-!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
     
     // reparse element access as await
     await [x];
@@ -53,7 +53,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level '
     declare const dec: any;
     @(await dec)
       ~~~~~
-!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
     class C {
     }
     
@@ -84,7 +84,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level '
     
     for await (const item of arr) {
         ~~~~~
-!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
+!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
       item;
     }
     
\ No newline at end of file
diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt
index 812f55c9be313..f4a6f8d147e63 100644
--- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt	
+++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt	
@@ -1,6 +1,6 @@
-error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 
 
-!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 ==== file.ts (0 errors) ====
     
\ No newline at end of file
diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt
index 812f55c9be313..f4a6f8d147e63 100644
--- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt	
+++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt	
@@ -1,6 +1,6 @@
-error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 
 
-!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 ==== file.ts (0 errors) ====
     
\ No newline at end of file
diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt
index 812f55c9be313..f4a6f8d147e63 100644
--- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt	
+++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt	
@@ -1,6 +1,6 @@
-error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 
 
-!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 ==== file.ts (0 errors) ====
     
\ No newline at end of file
diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt
index 812f55c9be313..f4a6f8d147e63 100644
--- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt	
+++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt	
@@ -1,6 +1,6 @@
-error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 
 
-!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
+!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.
 ==== file.ts (0 errors) ====
     
\ No newline at end of file
diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js
index 024124e902148..761d5e83e6cf7 100644
--- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js
+++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js
@@ -62,7 +62,7 @@ Output::
 [12:00:00 AM] Building project '/src/tsconfig_withFiles.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/src/hello.json
   Imported via "./hello.json" from file 'src/src/index.ts'
   Part of 'files' list in tsconfig.json
diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js
index 9eac7d6941344..a39c9a4c2fc9c 100644
--- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js
+++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js
@@ -65,7 +65,7 @@ Output::
 [12:00:00 AM] Building project '/src/tsconfig_withIncludeAndFiles.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/src/hello.json
   Part of 'files' list in tsconfig.json
   Imported via "./hello.json" from file 'src/src/index.ts'
diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js
index ee56612178f8f..a9f864eb9ce7d 100644
--- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js
+++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js
@@ -60,7 +60,7 @@ Output::
 [12:00:00 AM] Building project '/src/tsconfig_withIncludeOfJson.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/src/index.json
   Imported via "./index.json" from file 'src/src/index.ts'
   Matched by include pattern 'src/**/*.json' in 'src/tsconfig_withIncludeOfJson.json'
diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js
index 8416d4d8875ff..13c1edfb0227c 100644
--- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js
+++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js
@@ -62,7 +62,7 @@ Output::
 [12:00:00 AM] Building project '/src/tsconfig_withIncludeOfJson.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/src/hello.json
   Imported via "./hello.json" from file 'src/src/index.ts'
   Matched by include pattern 'src/**/*.json' in 'src/tsconfig_withIncludeOfJson.json'
diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js
index 8e4f275ff5480..c865691cdf6bd 100644
--- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js
+++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js
@@ -67,7 +67,7 @@ Output::
                     ~~~~~~~~~~~~~~
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/src/hello.json
   Imported via "./hello.json" from file 'src/src/index.ts'
 src/src/index.ts
diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js
index ea38f8b9f90b7..6c6c6d52e20ea 100644
--- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js
+++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js
@@ -62,7 +62,7 @@ Output::
 [12:01:00 AM] Building project '/src/tsconfig_withFiles.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/src/hello.json
   Imported via "./hello.json" from file 'src/src/index.ts'
   Part of 'files' list in tsconfig.json
diff --git a/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js b/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js
index ea560846edfb0..74c2463e3a398 100644
--- a/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js
+++ b/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js
@@ -108,7 +108,7 @@ Output::
 [12:01:00 AM] Building project '/src/core/tsconfig.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/core/anotherModule.ts
   Matched by include pattern '**/*' in 'src/core/tsconfig.json'
 src/core/index.ts
@@ -120,7 +120,7 @@ src/core/some_decl.d.ts
 [12:01:00 AM] Building project '/src/logic/tsconfig.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/core/index.d.ts
   Imported via '../core/index' from file 'src/logic/index.ts'
   File is output of project reference source 'src/core/index.ts'
@@ -134,7 +134,7 @@ src/logic/index.ts
 [12:01:00 AM] Building project '/src/tests/tsconfig.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/core/index.d.ts
   Imported via '../core/index' from file 'src/tests/index.ts'
   File is output of project reference source 'src/core/index.ts'
@@ -450,7 +450,7 @@ Output::
 [12:04:00 AM] Updating unchanged output timestamps of project '/src/core/tsconfig.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/core/anotherModule.ts
   Matched by include pattern '**/*' in 'src/core/tsconfig.json'
 src/core/index.ts
@@ -462,7 +462,7 @@ src/core/some_decl.d.ts
 [12:04:00 AM] Building project '/src/logic/tsconfig.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/core/index.d.ts
   Imported via '../core/index' from file 'src/logic/index.ts'
   File is output of project reference source 'src/core/index.ts'
@@ -476,7 +476,7 @@ src/logic/index.ts
 [12:04:00 AM] Building project '/src/tests/tsconfig.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/core/index.d.ts
   Imported via '../core/index' from file 'src/tests/index.ts'
   File is output of project reference source 'src/core/index.ts'
@@ -753,7 +753,7 @@ Output::
 [12:07:00 AM] Updating unchanged output timestamps of project '/src/core/tsconfig.json'...
 
 lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 src/core/anotherModule.ts
   Matched by include pattern '**/*' in 'src/core/tsconfig.json'
 src/core/index.ts
diff --git a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js
new file mode 100644
index 0000000000000..bb84fc7c82f8f
--- /dev/null
+++ b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js
@@ -0,0 +1,767 @@
+Input::
+//// [/user/username/projects/myproject/packages/pkg1/package.json]
+{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"module"}
+
+//// [/user/username/projects/myproject/packages/pkg1/index.ts]
+import type { TheNum } from 'pkg2'
+export const theNum: TheNum = 42;
+
+//// [/user/username/projects/myproject/packages/pkg1/tsconfig.json]
+{"compilerOptions":{"outDir":"build","module":"node12"},"references":[{"path":"../pkg2"}]}
+
+//// [/user/username/projects/myproject/packages/pkg2/const.cts]
+export type TheNum = 42;
+
+//// [/user/username/projects/myproject/packages/pkg2/index.ts]
+export type { TheNum } from './const.cjs';
+
+//// [/user/username/projects/myproject/packages/pkg2/tsconfig.json]
+{"compilerOptions":{"composite":true,"outDir":"build","module":"node12"}}
+
+//// [/user/username/projects/myproject/packages/pkg2/package.json]
+{"name":"pkg2","version":"1.0.0","main":"build/index.js","type":"module"}
+
+//// [/user/username/projects/myproject/node_modules/pkg2] symlink(/user/username/projects/myproject/packages/pkg2)
+//// [/a/lib/lib.es2020.full.d.ts]
+/// <reference no-default-lib="true"/>
+interface Boolean {}
+interface Function {}
+interface CallableFunction {}
+interface NewableFunction {}
+interface IArguments {}
+interface Number { toExponential: any; }
+interface Object {}
+interface RegExp {}
+interface String { charAt: any; }
+interface Array<T> { length: number; [n: number]: T; }
+
+
+/a/lib/tsc.js -b packages/pkg1 -w --verbose --traceResolution
+Output::
+>> Screen clear
+[12:00:41 AM] Starting compilation in watch mode...
+
+[12:00:42 AM] Projects in this build: 
+    * packages/pkg2/tsconfig.json
+    * packages/pkg1/tsconfig.json
+
+[12:00:43 AM] Project 'packages/pkg2/tsconfig.json' is out of date because output file 'packages/pkg2/build/const.cjs' does not exist
+
+[12:00:44 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'...
+
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ========
+Module resolution kind is not specified, using 'Node12'.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file type 'TypeScript'.
+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' exist - use it as a name resolution result.
+======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.cts'. ========
+File '/a/lib/package.json' does not exist.
+File '/a/package.json' does not exist.
+File '/package.json' does not exist.
+[12:01:00 AM] Project 'packages/pkg1/tsconfig.json' is out of date because output file 'packages/pkg1/build/index.js' does not exist
+
+[12:01:01 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...
+
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ========
+Module resolution kind is not specified, using 'Node12'.
+File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups.
+Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'.
+Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it.
+Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it.
+Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+'package.json' does not have a 'typings' field.
+'package.json' does not have a 'types' field.
+'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'.
+File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result.
+Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'.
+======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ========
+File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist.
+File '/user/username/projects/myproject/packages/pkg2/package.json' exists according to earlier cached lookups.
+======== 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 'Node12'.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'.
+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.
+File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result.
+======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ========
+File '/a/lib/package.json' does not exist according to earlier cached lookups.
+File '/a/package.json' does not exist according to earlier cached lookups.
+File '/package.json' does not exist according to earlier cached lookups.
+[12:01:07 AM] Found 0 errors. Watching for file changes.
+
+
+
+Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts","/user/username/projects/myproject/packages/pkg2/index.ts"]
+Program options: {"composite":true,"outDir":"/user/username/projects/myproject/packages/pkg2/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg2/tsconfig.json"}
+Program structureReused: Not
+Program files::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/const.cts
+/user/username/projects/myproject/packages/pkg2/index.ts
+
+Semantic diagnostics in builder refreshed for::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/const.cts
+/user/username/projects/myproject/packages/pkg2/index.ts
+
+Shape signatures in builder refreshed for::
+/a/lib/lib.es2020.full.d.ts (used version)
+/user/username/projects/myproject/packages/pkg2/const.cts (used version)
+/user/username/projects/myproject/packages/pkg2/index.ts (used version)
+
+Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"]
+Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"}
+Program structureReused: Not
+Program files::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/build/const.d.cts
+/user/username/projects/myproject/packages/pkg2/build/index.d.ts
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Semantic diagnostics in builder refreshed for::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/build/const.d.cts
+/user/username/projects/myproject/packages/pkg2/build/index.d.ts
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Shape signatures in builder refreshed for::
+/a/lib/lib.es2020.full.d.ts (used version)
+/user/username/projects/myproject/packages/pkg2/build/const.d.cts (used version)
+/user/username/projects/myproject/packages/pkg2/build/index.d.ts (used version)
+/user/username/projects/myproject/packages/pkg1/index.ts (used version)
+
+WatchedFiles::
+/user/username/projects/myproject/packages/pkg2/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/const.cts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+/a/lib/package.json:
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+/a/package.json:
+  {"fileName":"/a/package.json","pollingInterval":250}
+  {"fileName":"/a/package.json","pollingInterval":250}
+/package.json:
+  {"fileName":"/package.json","pollingInterval":250}
+  {"fileName":"/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/build/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/packages/pkg2:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject/packages/pkg1:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+//// [/user/username/projects/myproject/packages/pkg2/build/const.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+
+
+//// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts]
+export declare type TheNum = 42;
+
+
+//// [/user/username/projects/myproject/packages/pkg2/build/index.js]
+export {};
+
+
+//// [/user/username/projects/myproject/packages/pkg2/build/index.d.ts]
+export type { TheNum } from './const.cjs';
+
+
+//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo]
+{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
+
+//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt]
+{
+  "program": {
+    "fileNames": [
+      "../../../../../../../a/lib/lib.es2020.full.d.ts",
+      "../const.cts",
+      "../index.ts"
+    ],
+    "fileNamesList": [
+      [
+        "../const.cts"
+      ]
+    ],
+    "fileInfos": {
+      "../../../../../../../a/lib/lib.es2020.full.d.ts": {
+        "version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
+        "signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
+        "affectsGlobalScope": true,
+        "impliedFormat": 1
+      },
+      "../const.cts": {
+        "version": "-11202312776-export type TheNum = 42;",
+        "signature": "-11202312776-export type TheNum = 42;"
+      },
+      "../index.ts": {
+        "version": "-9668872159-export type { TheNum } from './const.cjs';",
+        "signature": "-9668872159-export type { TheNum } from './const.cjs';"
+      }
+    },
+    "options": {
+      "composite": true,
+      "module": 100,
+      "outDir": "./"
+    },
+    "referencedMap": {
+      "../index.ts": [
+        "../const.cts"
+      ]
+    },
+    "exportedModulesMap": {
+      "../index.ts": [
+        "../const.cts"
+      ]
+    },
+    "semanticDiagnosticsPerFile": [
+      "../../../../../../../a/lib/lib.es2020.full.d.ts",
+      "../const.cts",
+      "../index.ts"
+    ]
+  },
+  "version": "FakeTSVersion",
+  "size": 826
+}
+
+//// [/user/username/projects/myproject/packages/pkg1/build/index.js]
+export const theNum = 42;
+
+
+
+Change:: reports import errors after change to package file
+
+Input::
+//// [/user/username/projects/myproject/packages/pkg1/package.json]
+{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"commonjs"}
+
+
+Output::
+>> Screen clear
+[12:01:11 AM] File change detected. Starting incremental compilation...
+
+[12:01:12 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2'
+
+[12:01:13 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...
+
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ========
+Module resolution kind is not specified, using 'Node12'.
+File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups.
+Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'.
+Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it.
+Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it.
+Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist.
+'package.json' does not have a 'typings' field.
+'package.json' does not have a 'types' field.
+'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist.
+File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result.
+Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'.
+======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ========
+File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist.
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== 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 'Node12'.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'.
+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.
+File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result.
+======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ========
+File '/a/lib/package.json' does not exist.
+File '/a/package.json' does not exist.
+File '/package.json' does not exist.
+packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+1 import type { TheNum } from 'pkg2'
+                              ~~~~~~
+
+[12:01:14 AM] Found 1 error. Watching for file changes.
+
+
+
+Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"]
+Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"}
+Program structureReused: Not
+Program files::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/build/const.d.cts
+/user/username/projects/myproject/packages/pkg2/build/index.d.ts
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Semantic diagnostics in builder refreshed for::
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Shape signatures in builder refreshed for::
+/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts)
+
+WatchedFiles::
+/user/username/projects/myproject/packages/pkg2/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/const.cts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+/a/lib/package.json:
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+/a/package.json:
+  {"fileName":"/a/package.json","pollingInterval":250}
+  {"fileName":"/a/package.json","pollingInterval":250}
+/package.json:
+  {"fileName":"/package.json","pollingInterval":250}
+  {"fileName":"/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/build/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/packages/pkg2:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject/packages/pkg1:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+
+Change:: removes those errors when a package file is changed back
+
+Input::
+//// [/user/username/projects/myproject/packages/pkg1/package.json]
+{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"module"}
+
+
+Output::
+>> Screen clear
+[12:01:18 AM] File change detected. Starting incremental compilation...
+
+[12:01:19 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2'
+
+[12:01:20 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...
+
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ========
+Module resolution kind is not specified, using 'Node12'.
+File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups.
+Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'.
+Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it.
+Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it.
+Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+'package.json' does not have a 'typings' field.
+'package.json' does not have a 'types' field.
+'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'.
+File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result.
+Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'.
+======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ========
+File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist.
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== 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 'Node12'.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'.
+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.
+File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result.
+======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ========
+File '/a/lib/package.json' does not exist.
+File '/a/package.json' does not exist.
+File '/package.json' does not exist.
+[12:01:24 AM] Found 0 errors. Watching for file changes.
+
+
+
+Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"]
+Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"}
+Program structureReused: Not
+Program files::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/build/const.d.cts
+/user/username/projects/myproject/packages/pkg2/build/index.d.ts
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Semantic diagnostics in builder refreshed for::
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Shape signatures in builder refreshed for::
+/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts)
+
+WatchedFiles::
+/user/username/projects/myproject/packages/pkg2/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/const.cts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+/a/lib/package.json:
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+/a/package.json:
+  {"fileName":"/a/package.json","pollingInterval":250}
+  {"fileName":"/a/package.json","pollingInterval":250}
+/package.json:
+  {"fileName":"/package.json","pollingInterval":250}
+  {"fileName":"/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/build/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/packages/pkg2:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject/packages/pkg1:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+//// [/user/username/projects/myproject/packages/pkg1/build/index.js] file written with same contents
+
+Change:: reports import errors after change to package file
+
+Input::
+//// [/user/username/projects/myproject/packages/pkg1/package.json]
+{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"commonjs"}
+
+
+Output::
+>> Screen clear
+[12:01:28 AM] File change detected. Starting incremental compilation...
+
+[12:01:29 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2'
+
+[12:01:30 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...
+
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ========
+Module resolution kind is not specified, using 'Node12'.
+File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups.
+Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'.
+Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it.
+Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it.
+Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist.
+'package.json' does not have a 'typings' field.
+'package.json' does not have a 'types' field.
+'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist.
+File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist.
+File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result.
+Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'.
+======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ========
+File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist.
+Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'.
+'package.json' does not have a 'typesVersions' field.
+======== 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 'Node12'.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'.
+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.
+File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result.
+======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ========
+File '/a/lib/package.json' does not exist.
+File '/a/package.json' does not exist.
+File '/package.json' does not exist.
+packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
+
+1 import type { TheNum } from 'pkg2'
+                              ~~~~~~
+
+[12:01:31 AM] Found 1 error. Watching for file changes.
+
+
+
+Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"]
+Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"}
+Program structureReused: Not
+Program files::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/build/const.d.cts
+/user/username/projects/myproject/packages/pkg2/build/index.d.ts
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Semantic diagnostics in builder refreshed for::
+/user/username/projects/myproject/packages/pkg1/index.ts
+
+Shape signatures in builder refreshed for::
+/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts)
+
+WatchedFiles::
+/user/username/projects/myproject/packages/pkg2/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/const.cts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+/a/lib/package.json:
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+/a/package.json:
+  {"fileName":"/a/package.json","pollingInterval":250}
+  {"fileName":"/a/package.json","pollingInterval":250}
+/package.json:
+  {"fileName":"/package.json","pollingInterval":250}
+  {"fileName":"/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/build/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/packages/pkg2:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject/packages/pkg1:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+
+Change:: removes those errors when a package file is changed to cjs extensions
+
+Input::
+//// [/user/username/projects/myproject/packages/pkg2/package.json]
+{"name":"pkg2","version":"1.0.0","main":"build/index.cjs","type":"module"}
+
+//// [/user/username/projects/myproject/packages/pkg2/index.cts]
+export type { TheNum } from './const.cjs';
+
+//// [/user/username/projects/myproject/packages/pkg2/index.ts] deleted
+
+Output::
+>> Screen clear
+[12:01:38 AM] File change detected. Starting incremental compilation...
+
+[12:01:39 AM] Project 'packages/pkg2/tsconfig.json' is out of date because oldest output 'packages/pkg2/build/const.cjs' is older than newest input 'packages/pkg2/index.cts'
+
+[12:01:40 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'...
+
+======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.cts'. ========
+Module resolution kind is not specified, using 'Node12'.
+Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file type 'TypeScript'.
+File '/user/username/projects/myproject/packages/pkg2/const.cjs.ts' does not exist.
+File '/user/username/projects/myproject/packages/pkg2/const.cjs.tsx' does not exist.
+File '/user/username/projects/myproject/packages/pkg2/const.cjs.d.ts' does not exist.
+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' exist - use it as a name resolution result.
+======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.cts'. ========
+File '/a/lib/package.json' does not exist.
+File '/a/package.json' does not exist.
+File '/package.json' does not exist.
+[12:01:49 AM] Updating unchanged output timestamps of project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'...
+
+
+
+Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts","/user/username/projects/myproject/packages/pkg2/index.cts"]
+Program options: {"composite":true,"outDir":"/user/username/projects/myproject/packages/pkg2/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg2/tsconfig.json"}
+Program structureReused: Not
+Program files::
+/a/lib/lib.es2020.full.d.ts
+/user/username/projects/myproject/packages/pkg2/const.cts
+/user/username/projects/myproject/packages/pkg2/index.cts
+
+Semantic diagnostics in builder refreshed for::
+/user/username/projects/myproject/packages/pkg2/index.cts
+
+Shape signatures in builder refreshed for::
+/user/username/projects/myproject/packages/pkg2/index.cts (computed .d.ts)
+
+WatchedFiles::
+/user/username/projects/myproject/packages/pkg2/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/const.cts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250}
+/a/lib/package.json:
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+  {"fileName":"/a/lib/package.json","pollingInterval":250}
+/a/package.json:
+  {"fileName":"/a/package.json","pollingInterval":250}
+  {"fileName":"/a/package.json","pollingInterval":250}
+/package.json:
+  {"fileName":"/package.json","pollingInterval":250}
+  {"fileName":"/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/tsconfig.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/index.ts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg1/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/build/package.json:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250}
+/user/username/projects/myproject/packages/pkg2/index.cts:
+  {"fileName":"/user/username/projects/myproject/packages/pkg2/index.cts","pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/packages/pkg2:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject/packages/pkg1:
+  {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+//// [/user/username/projects/myproject/packages/pkg2/build/const.cjs] file changed its modified time
+//// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts] file changed its modified time
+//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo]
+{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},"-11202312776-export type TheNum = 42;",{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":1}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
+
+//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt]
+{
+  "program": {
+    "fileNames": [
+      "../../../../../../../a/lib/lib.es2020.full.d.ts",
+      "../const.cts",
+      "../index.cts"
+    ],
+    "fileNamesList": [
+      [
+        "../const.cts"
+      ]
+    ],
+    "fileInfos": {
+      "../../../../../../../a/lib/lib.es2020.full.d.ts": {
+        "version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
+        "signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
+        "affectsGlobalScope": true,
+        "impliedFormat": 1
+      },
+      "../const.cts": {
+        "version": "-11202312776-export type TheNum = 42;",
+        "signature": "-11202312776-export type TheNum = 42;"
+      },
+      "../index.cts": {
+        "version": "-9668872159-export type { TheNum } from './const.cjs';",
+        "signature": "-9835135925-export type { TheNum } from './const.cjs';\n",
+        "impliedFormat": 1
+      }
+    },
+    "options": {
+      "composite": true,
+      "module": 100,
+      "outDir": "./"
+    },
+    "referencedMap": {
+      "../index.cts": [
+        "../const.cts"
+      ]
+    },
+    "exportedModulesMap": {
+      "../index.cts": [
+        "../const.cts"
+      ]
+    },
+    "semanticDiagnosticsPerFile": [
+      "../../../../../../../a/lib/lib.es2020.full.d.ts",
+      "../const.cts",
+      "../index.cts"
+    ]
+  },
+  "version": "FakeTSVersion",
+  "size": 928
+}
+
+//// [/user/username/projects/myproject/packages/pkg2/build/index.cjs]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+
+
+//// [/user/username/projects/myproject/packages/pkg2/build/index.d.cts]
+export type { TheNum } from './const.cjs';
+
+
diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js
index 76887a62a286a..059bfc897ca22 100644
--- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js
+++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js
@@ -73,7 +73,7 @@ default: ES3
 
 --module, -m
 Specify what module code is generated.
-one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext
+one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext, node12, nodenext
 
 --lib
 Specify a set of bundled library declaration files that describe the target runtime environment.
diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js
index 3965dcaec9704..37915984e2233 100644
--- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js
+++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js
@@ -73,7 +73,7 @@ default: ES3
 
 --module, -m
 Specify what module code is generated.
-one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext
+one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext, node12, nodenext
 
 --lib
 Specify a set of bundled library declaration files that describe the target runtime environment.
diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js
index 3965dcaec9704..37915984e2233 100644
--- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js
+++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js
@@ -73,7 +73,7 @@ default: ES3
 
 --module, -m
 Specify what module code is generated.
-one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext
+one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext, node12, nodenext
 
 --lib
 Specify a set of bundled library declaration files that describe the target runtime environment.
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js
index 65cb101104e77..417fb08c4abc8 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js
@@ -52,7 +52,7 @@ Output::
     File is matched by 'files' list specified here.
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 node_modules/react/jsx-Runtime/index.d.ts
   Part of 'files' list in tsconfig.json
   Imported via "react/jsx-runtime" from file 'index.tsx' with packageId 'react/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js
index ba9744a17f4cb..33e472c837816 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js
@@ -36,7 +36,7 @@ Output::
 [12:00:17 AM] Starting compilation in watch mode...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 project/a.ts
   Matched by include pattern '**/*' in 'project/tsconfig.json'
   Imported via "C://project/a" from file 'project/b.ts'
@@ -119,7 +119,7 @@ Output::
 [12:00:25 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 project/a.ts
   Matched by include pattern '**/*' in 'project/tsconfig.json'
   Imported via "C://project/a" from file 'project/b.ts'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js
index ab1200f39b443..e8961da542b86 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js
@@ -36,7 +36,7 @@ Output::
 [12:00:17 AM] Starting compilation in watch mode...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 project/a.ts
   Matched by include pattern '**/*' in 'project/tsconfig.json'
   Imported via "C://project/a" from file 'project/b.ts'
@@ -119,7 +119,7 @@ Output::
 [12:00:25 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 project/a.ts
   Matched by include pattern '**/*' in 'project/tsconfig.json'
   Imported via "C://project/a" from file 'project/b.ts'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js
index bd308029095cf..634c9ca43fadb 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js
@@ -37,7 +37,7 @@ Output::
 [12:00:27 AM] Starting compilation in watch mode...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY/a.ts
   Imported via "./XY/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
@@ -147,7 +147,7 @@ Output::
 [12:00:33 AM] File change detected. Starting incremental compilation...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY/a.ts
   Imported via "./XY/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js
index 9aba67160c4de..53467069a4612 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js
@@ -37,7 +37,7 @@ Output::
 [12:00:25 AM] Starting compilation in watch mode...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./XY" from file 'b.ts'
@@ -135,7 +135,7 @@ Output::
 [12:00:35 AM] File change detected. Starting incremental compilation...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./XY" from file 'b.ts'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js
index a471f439dcc4e..b847f8fdb410d 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js
@@ -37,7 +37,7 @@ Output::
 [12:00:27 AM] Starting compilation in watch mode...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY/a.ts
   Imported via "./XY/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
@@ -147,7 +147,7 @@ Output::
 [12:00:33 AM] File change detected. Starting incremental compilation...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY/a.ts
   Imported via "./XY/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js
index 87d683f1bd9ed..094ce2ca94265 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js
@@ -37,7 +37,7 @@ Output::
 [12:00:25 AM] Starting compilation in watch mode...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./XY" from file 'b.ts'
@@ -135,7 +135,7 @@ Output::
 [12:00:35 AM] File change detected. Starting incremental compilation...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./XY" from file 'b.ts'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js
index 69b82b693d6af..c9f4403e401f2 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js
@@ -42,7 +42,7 @@ Output::
                     ~~~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 link/a.ts
   Imported via "./link/a" from file 'b.ts'
 b.ts
@@ -158,7 +158,7 @@ Output::
                     ~~~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 link/a.ts
   Imported via "./link/a" from file 'b.ts'
 b.ts
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js
index 432449b6e600c..39c9167334e37 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js
@@ -42,7 +42,7 @@ Output::
                     ~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
 link.ts
@@ -148,7 +148,7 @@ Output::
                     ~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
 link.ts
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js
index f0d6ddc84018d..a3571bb39360c 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js
@@ -45,7 +45,7 @@ Output::
                     ~~~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 Xy/a.ts
   Imported via "./Xy/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
@@ -163,7 +163,7 @@ Output::
                     ~~~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 Xy/a.ts
   Imported via "./Xy/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js
index 3f0f145845065..f0059e68a8b7b 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js
@@ -45,7 +45,7 @@ Output::
                     ~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./Xy" from file 'b.ts'
@@ -151,7 +151,7 @@ Output::
                     ~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./Xy" from file 'b.ts'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js
index d54b3f06b2648..effb28f973961 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js
@@ -45,7 +45,7 @@ Output::
                     ~~~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 Xy/a.ts
   Imported via "./Xy/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
@@ -163,7 +163,7 @@ Output::
                     ~~~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 Xy/a.ts
   Imported via "./Xy/a" from file 'b.ts'
   Matched by include pattern '**/*' in 'tsconfig.json'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js
index c62772d275d25..23c67c71ac06b 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js
@@ -45,7 +45,7 @@ Output::
                     ~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./Xy" from file 'b.ts'
@@ -151,7 +151,7 @@ Output::
                     ~~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 XY.ts
   Matched by include pattern '**/*' in 'tsconfig.json'
   Imported via "./Xy" from file 'b.ts'
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js
index 0eff5f906f7d1..481cc141c2a56 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js
@@ -59,7 +59,7 @@ Output::
     File is included via import here.
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 ModuleC.ts
   Imported via "./ModuleC" from file 'moduleA.ts'
   Imported via "./moduleC" from file 'moduleB.ts'
@@ -174,7 +174,7 @@ Output::
     File is included via import here.
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 ModuleC.ts
   Imported via "./ModuleC" from file 'moduleA.ts'
   Imported via "./moduleC" from file 'moduleB.ts'
diff --git a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js
index 38630e619acfd..ad6442b726541 100644
--- a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js
+++ b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js
@@ -58,7 +58,7 @@ export const App = () => <div propA={true}></div>;
 /a/lib/tsc.js -i --explainFiles
 Output::
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 node_modules/react/jsx-runtime/index.d.ts
   Imported via "react/jsx-runtime" from file 'index.tsx' with packageId 'react/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions
 index.tsx
@@ -172,7 +172,7 @@ Output::
                                 ~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 node_modules/preact/jsx-runtime/index.d.ts
   Imported via "preact/jsx-runtime" from file 'index.tsx' with packageId 'preact/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions
 index.tsx
diff --git a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js
index 0d39109590ffe..87dc1d5f4ca04 100644
--- a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js
+++ b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js
@@ -61,7 +61,7 @@ Output::
 [12:00:39 AM] Starting compilation in watch mode...
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 node_modules/react/jsx-runtime/index.d.ts
   Imported via "react/jsx-runtime" from file 'index.tsx' with packageId 'react/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions
 index.tsx
@@ -198,7 +198,7 @@ Output::
                                 ~~~~~
 
 ../../../../a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 node_modules/preact/jsx-runtime/index.d.ts
   Imported via "preact/jsx-runtime" from file 'index.tsx' with packageId 'preact/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions
 index.tsx
diff --git a/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js b/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js
index 4f21e9cf90663..304bbecca58b1 100644
--- a/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js
+++ b/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js
@@ -28,7 +28,7 @@ Output::
 [12:00:19 AM] Starting compilation in watch mode...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/f2.ts
   Imported via "./f2" from file 'a/b/f1.ts'
 a/b/f1.ts
@@ -105,7 +105,7 @@ Output::
 [12:00:27 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/c/f3.ts
   Imported via "../c/f3" from file 'a/b/f2.ts'
 a/b/f2.ts
diff --git a/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js b/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js
index a8912e59ee4af..a1adb29d11034 100644
--- a/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js
+++ b/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js
@@ -28,7 +28,7 @@ Output::
 [12:00:17 AM] Starting compilation in watch mode...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/commonFile1.ts
   Matched by include pattern '**/*' in 'a/b/tsconfig.json'
 a/b/commonFile2.ts
@@ -96,7 +96,7 @@ Output::
 [12:00:25 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/commonFile1.ts
   Matched by include pattern '**/*' in 'a/b/tsconfig.json'
 a/b/commonFile2.ts
@@ -159,7 +159,7 @@ Output::
 [12:00:34 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/commonFile1.ts
   Matched by include pattern '**/*' in 'a/b/tsconfig.json'
 [12:00:38 AM] Found 0 errors. Watching for file changes.
@@ -211,7 +211,7 @@ Output::
 [12:00:41 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/commonFile1.ts
   Matched by include pattern '**/*' in 'a/b/tsconfig.json'
 a/b/commonFile2.ts
diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js b/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js
index 9c2504a22196e..f645329658ee8 100644
--- a/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js
+++ b/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js
@@ -31,7 +31,7 @@ Output::
 [12:00:17 AM] Starting compilation in watch mode...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/commonFile1.ts
   Part of 'files' list in tsconfig.json
 a/b/commonFile2.ts
@@ -97,7 +97,7 @@ Output::
 [12:00:25 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/commonFile1.ts
   Part of 'files' list in tsconfig.json
 a/b/commonFile2.ts
@@ -163,7 +163,7 @@ Output::
 [12:00:36 AM] File change detected. Starting incremental compilation...
 
 a/lib/lib.d.ts
-  Default library
+  Default library for target 'es3'
 a/b/commonFile1.ts
   Part of 'files' list in tsconfig.json
 [12:00:40 AM] Found 0 errors. Watching for file changes.
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js
index 325bc051f381f..96d0a07984ea5 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js
index 337fd59507a6d..dfb62bb307403 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js
index 7702cbca6d98b..8084ad64c472d 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js
index 6bf78ae82a4c5..e5da699f3861a 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js
index 1c39c0c715d34..4336a83c99f93 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js
index c829851b74ff9..6a0eac03a9f58 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
@@ -120,7 +120,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js
index 7f69e67354d27..f96320da3a712 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js
index a667534acafff..62214db3c51e3 100644
--- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js
+++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
@@ -126,7 +126,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/bar.ts
 	  Matched by include pattern './src' in 'tsconfig.json'
 	src/foo.ts
diff --git a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js
index f01516e4e14e8..4b5747816f6be 100644
--- a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js
+++ b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js
@@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	Logger.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 	  Imported via "./Logger" from file 'another.ts'
diff --git a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js
index ed681eaf86b15..1af314f8ae86a 100644
--- a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js
+++ b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js
@@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	Logger.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 	  Imported via "./Logger" from file 'another.ts'
diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js
index 8c242cf0fecd9..c290bb78497b0 100644
--- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js
+++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js
@@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js
index 9688e4a49068f..99c6e880c5c2c 100644
--- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js
+++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js
@@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js
index 032b65c6a58a9..127e18a12073d 100644
--- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js
+++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js
@@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js
index b0684a5698ddc..f882b6b064d5a 100644
--- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js
+++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js
@@ -28,7 +28,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Part of 'files' list in tsconfig.json
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js
index 25d9ca79a925d..77afe57d1a0a2 100644
--- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js
+++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js
@@ -28,7 +28,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Part of 'files' list in tsconfig.json
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js
index b729e90e9b23c..41cfb0ff06673 100644
--- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js
+++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js
@@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js
index 921b483df6b03..64727ed96257e 100644
--- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js
+++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js
@@ -42,7 +42,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Part of 'files' list in tsconfig.json
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js b/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js
index 2bd9071b01162..a5b8f28ac9430 100644
--- a/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js
+++ b/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js
@@ -35,7 +35,7 @@ Project '/users/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	node_modules/@custom/plugin/proposed.d.ts
 	  Imported via './proposed' from file 'node_modules/@custom/plugin/index.d.ts'
 	node_modules/@custom/plugin/index.d.ts
diff --git a/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js b/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js
index b505843b86c3e..9d4011c2649fc 100644
--- a/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js
+++ b/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js
@@ -42,7 +42,7 @@ event:
 event:
     {"seq":0,"type":"event","event":"telemetry","body":{"telemetryEventName":"projectInfo","payload":{"projectId":"c56abb8c7c51bef5953613f05226da8e72cd9eafe09ab58ca2ccd81b65ba193a","fileStats":{"js":0,"jsSize":0,"jsx":0,"jsxSize":0,"ts":2,"tsSize":154,"tsx":0,"tsxSize":0,"dts":0,"dtsSize":0,"deferred":0,"deferredSize":0},"compilerOptions":{"module":"none"},"typeAcquisition":{"enable":false,"include":false,"exclude":false},"extends":false,"files":false,"include":false,"exclude":true,"compileOnSave":false,"configFileName":"tsconfig.json","projectType":"configured","languageServiceEnabled":true,"version":"FakeVersion"}}}
 event:
-    {"seq":0,"type":"event","event":"configFileDiag","body":{"triggerFile":"/a/b/projects/myproject/bar/app.ts","configFile":"/a/b/projects/myproject/tsconfig.json","diagnostics":[{"text":"File '/a/lib/lib.d.ts' not found.\n  The file is in the program because:\n    Default library","code":6053,"category":"error"},{"text":"Cannot find global type 'Array'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Boolean'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Function'.","code":2318,"category":"error"},{"text":"Cannot find global type 'IArguments'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Number'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Object'.","code":2318,"category":"error"},{"text":"Cannot find global type 'RegExp'.","code":2318,"category":"error"},{"text":"Cannot find global type 'String'.","code":2318,"category":"error"},{"start":{"line":1,"offset":37},"end":{"line":1,"offset":45},"text":"Unknown compiler option 'targer'. Did you mean 'target'?","code":5025,"category":"error","fileName":"/a/b/projects/myproject/tsconfig.json"}]}}
+    {"seq":0,"type":"event","event":"configFileDiag","body":{"triggerFile":"/a/b/projects/myproject/bar/app.ts","configFile":"/a/b/projects/myproject/tsconfig.json","diagnostics":[{"text":"File '/a/lib/lib.d.ts' not found.\n  The file is in the program because:\n    Default library for target 'es3'","code":6053,"category":"error"},{"text":"Cannot find global type 'Array'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Boolean'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Function'.","code":2318,"category":"error"},{"text":"Cannot find global type 'IArguments'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Number'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Object'.","code":2318,"category":"error"},{"text":"Cannot find global type 'RegExp'.","code":2318,"category":"error"},{"text":"Cannot find global type 'String'.","code":2318,"category":"error"},{"start":{"line":1,"offset":37},"end":{"line":1,"offset":45},"text":"Unknown compiler option 'targer'. Did you mean 'target'?","code":5025,"category":"error","fileName":"/a/b/projects/myproject/tsconfig.json"}]}}
 Project '/a/b/projects/myproject/tsconfig.json' (Configured)
 	Files (2)
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js
index 419c68f410458..584478548a45f 100644
--- a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js
+++ b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js
@@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/main.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -233,7 +233,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	node_modules/@angular/core/index.d.ts
 	  Imported via '@angular/core' from file 'src/main.ts'
 	src/main.ts
diff --git a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js
index b17e03d859139..9fb71d1254428 100644
--- a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js
+++ b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js
@@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/main.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -256,7 +256,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	node_modules/@angular/core/index.d.ts
 	  Imported via '@angular/core' from file 'src/main.ts'
 	src/main.ts
diff --git a/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js b/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js
index 789290aa830d7..0d1830af78290 100644
--- a/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js
+++ b/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js
@@ -36,7 +36,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/blabla.json
 	  Imported via "./blabla.json" from file 'src/test.ts'
 	  Matched by include pattern './src/*.json' in 'tsconfig.json'
diff --git a/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js b/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js
index 6d6136fac9911..3d897aa23e320 100644
--- a/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js
+++ b/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js
@@ -35,7 +35,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/blabla.json
 	  Imported via "./blabla.json" from file 'src/test.ts'
 	src/test.ts
diff --git a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js
index 7eae40f0de5cc..ac2b48eaed2a7 100644
--- a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js
+++ b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js
@@ -27,7 +27,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	ui.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js
index 78983bd3745bc..e7f57c4b839e2 100644
--- a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js
+++ b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js
@@ -29,7 +29,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	ui.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js
index 364821360fa61..ca2aec830655e 100644
--- a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js
+++ b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js
@@ -29,7 +29,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	ui.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js b/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js
index 8d1455b514238..98221e5c651b8 100644
--- a/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js
+++ b/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js
@@ -33,7 +33,7 @@ Project '/a/jsconfig.json' (Configured)
 
 
 	lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.js
 	  Matched by include pattern '**/*' in 'jsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js
index 45c47d45b079e..c4626262b1f57 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js
@@ -53,7 +53,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Imported via '../decls/fns' from file 'usage.ts'
 	usage.ts
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js
index 561c60b7d7d08..5ec2fe654cf39 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js
@@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Imported via '../decls/fns' from file 'usage.ts'
 	usage.ts
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js
index ec714b9f6dfef..9aac5c5526945 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js
@@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Imported via '../decls/fns' from file 'usage.ts'
 	usage.ts
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js
index da8fb9a79ca01..615d011501120 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js
@@ -53,7 +53,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Imported via '../decls/fns' from file 'usage.ts'
 	usage.ts
@@ -89,7 +89,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	fns.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js
index a650ce4c29fe1..1c9a4d1781926 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js
@@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Imported via '../decls/fns' from file 'usage.ts'
 	usage.ts
@@ -99,7 +99,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	fns.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js
index 684abf3f76755..18e76ddb5e077 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js
@@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Imported via '../decls/fns' from file 'usage.ts'
 	usage.ts
@@ -99,7 +99,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	fns.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js
index a0f7645600aa5..d54d8a8ed4c58 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js
@@ -52,7 +52,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified
 	usage.ts
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js
index 8df29aefc933e..cd4980e3517a8 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js
@@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified
 	usage.ts
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js
index 5324f46408194..0441470c96582 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js
@@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified
 	usage.ts
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js
index 46987608856db..07b7d01685ea4 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js
@@ -52,7 +52,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified
 	usage.ts
@@ -88,7 +88,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	fns.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js
index 38a5700630c27..bfd0a68ad057d 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js
@@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified
 	usage.ts
@@ -98,7 +98,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	fns.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js
index 24c278e2f9905..d9f23968cc7c8 100644
--- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js
+++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js
@@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../dependency/fns.ts
 	  Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified
 	usage.ts
@@ -98,7 +98,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	fns.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js b/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js
index c3b9c6f8d0df5..79bc5aad59d86 100644
--- a/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js
+++ b/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js
@@ -51,7 +51,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
@@ -134,7 +134,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	index.ts
 	  Part of 'files' list in tsconfig.json
 
@@ -196,7 +196,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
@@ -353,7 +353,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
@@ -383,7 +383,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	index.ts
 	  Part of 'files' list in tsconfig.json
 
@@ -401,7 +401,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js
index c257c3c0f2e73..d7b7c45b64f85 100644
--- a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js
+++ b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js
@@ -68,7 +68,7 @@ Project '/user/username/projects/myproject/app/src/program/tsconfig.json' (Confi
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../../../shared/bld/library/index.d.ts
 	  Imported via "shared" from file 'bar.ts' with packageId 'shared/bld/library/index.d.ts@1.0.0'
 	bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js
index 6f7e0f4c7773c..6d2e6ff6b9038 100644
--- a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js
@@ -67,7 +67,7 @@ Project '/user/username/projects/myproject/app/src/program/tsconfig.json' (Confi
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../../../shared/src/library/index.ts
 	  Imported via "shared" from file 'bar.ts' with packageId 'shared/bld/library/index.d.ts@1.0.0'
 	bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js
index 6f7e0f4c7773c..6d2e6ff6b9038 100644
--- a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js
+++ b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js
@@ -67,7 +67,7 @@ Project '/user/username/projects/myproject/app/src/program/tsconfig.json' (Confi
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../../../shared/src/library/index.ts
 	  Imported via "shared" from file 'bar.ts' with packageId 'shared/bld/library/index.d.ts@1.0.0'
 	bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js b/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js
index 901557f3c9ef1..1b0c0d2f7c153 100644
--- a/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js
+++ b/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js
@@ -51,7 +51,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
@@ -94,7 +94,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	index.ts
 	  Part of 'files' list in tsconfig.json
 
@@ -156,7 +156,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js
index 82ed7b753a83d..9a63c26b17209 100644
--- a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js
+++ b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js
@@ -101,7 +101,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -234,7 +234,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -355,7 +355,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
diff --git a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js
index 45020c168612c..7e48c98547aa0 100644
--- a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js
+++ b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js
@@ -81,7 +81,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -214,7 +214,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -318,7 +318,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js b/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js
index d9c6845a1a686..43b8000ef66b6 100644
--- a/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js
+++ b/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js
@@ -49,7 +49,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
@@ -90,7 +90,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../lib/index.ts
 	  Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified
 	index.ts
@@ -112,7 +112,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	index.ts
 	  Part of 'files' list in tsconfig.json
 
diff --git a/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js b/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js
index b3b922c4b2c3b..e0b4059ce9765 100644
--- a/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js
+++ b/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js
@@ -32,7 +32,7 @@ Project '/user/username/projects/solution/compiler/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	types.ts
 	  Part of 'files' list in tsconfig.json
 	program.ts
@@ -117,7 +117,7 @@ Project '/user/username/projects/solution/services/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../compiler/types.ts
 	  Source from referenced project '../compiler/tsconfig.json' included because '--module' is specified as 'none'
 	../compiler/program.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js
index f969c5b84e566..a9013a77c9bf3 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via 'b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js
index e60b86b81078d..04e4eb883df31 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via 'b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js
index f969c5b84e566..a9013a77c9bf3 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via 'b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js
index e60b86b81078d..04e4eb883df31 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via 'b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js
index 8b26d25ed154a..2f1e96760ad2a 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via '@issue/b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js
index 66046c4b53eb7..ef0145096da1f 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via '@issue/b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js
index 8b26d25ed154a..2f1e96760ad2a 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via '@issue/b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js
index 66046c4b53eb7..ef0145096da1f 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/index.ts
 	  Imported via '@issue/b' from file 'src/index.ts'
 	../B/src/bar.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js
index 7726579e91a68..9a61dfad25320 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via 'b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js
index f22cf5c905156..f6845aa802776 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via 'b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js
index 7726579e91a68..9a61dfad25320 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via 'b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js
index f22cf5c905156..f6845aa802776 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via 'b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js
index 85a0c966f68a0..a77a219fa9442 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via '@issue/b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js
index 1ff4238c7230d..8cd1d9f315d28 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via '@issue/b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js
index 85a0c966f68a0..a77a219fa9442 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js
@@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via '@issue/b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js
index 1ff4238c7230d..8cd1d9f315d28 100644
--- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js
+++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js
@@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../B/src/foo.ts
 	  Imported via '@issue/b/lib/foo' from file 'src/test.ts'
 	../B/src/bar/foo.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js
index 6067b76e4445c..33ff2899bb102 100644
--- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js
+++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js
@@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	class2.ts
@@ -119,7 +119,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	../project1/class3.d.ts
@@ -171,7 +171,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	class2.ts
@@ -216,7 +216,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	../project1/class3.d.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js
index b49dd3463821d..b7dd8d659e8cd 100644
--- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js
+++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js
@@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.ts
 	  Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	class2.ts
@@ -88,7 +88,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.ts
 	  Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	../project1/class3.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js
index e17a9ec7915e3..7f2d161a7d719 100644
--- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js
+++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js
@@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	class2.ts
@@ -92,7 +92,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	class1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -136,7 +136,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	class1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 	class3.ts
@@ -193,7 +193,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	../project1/class3.d.ts
@@ -257,7 +257,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	class2.ts
@@ -314,7 +314,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.d.ts
 	  Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	../project1/class3.d.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js
index 6d615c5d9cca1..e599b581ce232 100644
--- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js
+++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js
@@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.ts
 	  Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	class2.ts
@@ -92,7 +92,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	class1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -132,7 +132,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../project1/class1.ts
 	  Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none'
 	../project1/class3.ts
@@ -152,7 +152,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	class1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 	class3.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js b/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js
index 0491fc90397c8..733f44198e166 100644
--- a/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js
+++ b/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js
@@ -60,7 +60,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -201,7 +201,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -281,7 +281,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -537,7 +537,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../target/src/helpers/functions.d.ts
 	  Imported via 'helpers/functions' from file '../target/src/main.d.ts'
 	../target/src/main.d.ts
@@ -571,7 +571,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -668,7 +668,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
diff --git a/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js b/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js
index 1fc3aca66dd00..f98f0ac84e7ad 100644
--- a/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js
+++ b/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js
@@ -100,7 +100,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -243,7 +243,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -363,7 +363,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -606,7 +606,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -637,7 +637,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -743,7 +743,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../target/src/helpers/functions.d.ts
 	  Imported via 'helpers/functions' from file '../target/src/main.d.ts'
 	../target/src/main.d.ts
@@ -777,7 +777,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -797,7 +797,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -819,7 +819,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -960,7 +960,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -996,7 +996,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -1025,7 +1025,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js
index 0730f12780e09..7b780c70d9461 100644
--- a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js
+++ b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js
@@ -39,7 +39,7 @@ Project '/user/username/projects/project/src/common/tsconfig.json' (Configured)
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	input/keyboard.ts
 	  Imported via 'common/input/keyboard' from file 'input/keyboard.test.ts'
 	  Matched by include pattern './**/*' in 'tsconfig.json'
@@ -116,7 +116,7 @@ Project '/user/username/projects/project/src/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../out/input/keyboard.d.ts
 	  Imported via 'common/input/keyboard' from file 'terminal.ts'
 	  Imported via 'common/input/keyboard' from file 'common/input/keyboard.test.ts'
diff --git a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js
index 6c9ab0042f3ae..087b11925fd3f 100644
--- a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js
+++ b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js
@@ -39,7 +39,7 @@ Project '/user/username/projects/project/src/common/tsconfig.json' (Configured)
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	input/keyboard.ts
 	  Imported via 'common/input/keyboard' from file 'input/keyboard.test.ts'
 	  Matched by include pattern './**/*' in 'tsconfig.json'
@@ -115,7 +115,7 @@ Project '/user/username/projects/project/src/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	common/input/keyboard.ts
 	  Imported via 'common/input/keyboard' from file 'terminal.ts'
 	  Imported via 'common/input/keyboard' from file 'common/input/keyboard.test.ts'
diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js
index 409f4ec3ab500..9ccdf36a3e7d8 100644
--- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js
+++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js
@@ -96,7 +96,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -127,7 +127,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -250,7 +250,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -275,7 +275,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -395,7 +395,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -424,7 +424,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js
index 657f545b7bd0b..3ff42e8c78ea1 100644
--- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js
+++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js
@@ -74,7 +74,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -106,7 +106,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -230,7 +230,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -254,7 +254,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -354,7 +354,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -384,7 +384,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js
index 7bacd99ea0871..777ac2ad63b24 100644
--- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js
+++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js
@@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -161,7 +161,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -240,7 +240,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js
index 5e41243f1dbdc..557538b6f45e1 100644
--- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js
+++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js
@@ -53,7 +53,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -82,7 +82,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -214,7 +214,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -235,7 +235,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -311,7 +311,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -338,7 +338,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -612,7 +612,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../target/src/helpers/functions.d.ts
 	  Imported via 'helpers/functions' from file '../target/src/main.d.ts'
 	../target/src/main.d.ts
@@ -637,7 +637,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -658,7 +658,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -751,7 +751,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -778,7 +778,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js
index ae073122bf4a7..172371c9136b7 100644
--- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js
+++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js
@@ -95,7 +95,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -126,7 +126,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -259,7 +259,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -284,7 +284,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -403,7 +403,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -432,7 +432,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -696,7 +696,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -735,7 +735,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -841,7 +841,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../target/src/helpers/functions.d.ts
 	  Imported via 'helpers/functions' from file '../target/src/main.d.ts'
 	../target/src/main.d.ts
@@ -867,7 +867,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -890,7 +890,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -910,7 +910,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -932,7 +932,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -1071,7 +1071,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -1100,7 +1100,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	  Matched by include pattern './src/**/*' in 'tsconfig-src.json'
@@ -1135,7 +1135,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
@@ -1164,7 +1164,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/helpers/functions.ts
 	  Imported via 'helpers/functions' from file 'src/main.ts'
 	src/main.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js
index 4952ad577f57a..05dbc65c8940c 100644
--- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js
+++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js
@@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/server.ts'
 	src/server.ts
@@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/index.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/app.ts'
 	src/app.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js
index a38fee1014521..002fd13a1027c 100644
--- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js
+++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js
@@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/server.ts'
 	src/server.ts
@@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/index.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js
index 9d7bd0466e250..94d141350d905 100644
--- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js
+++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js
@@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/server.ts'
 	src/server.ts
@@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/index.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/app.ts'
 	src/app.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js
index 08ead42ba29b1..90ba1f57746a1 100644
--- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js
+++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js
@@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/server.ts'
 	src/server.ts
@@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/index.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/app.ts'
 	src/app.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js
index 4bad4c371a6fa..08dfbe0bb76f3 100644
--- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js
+++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js
@@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/server.ts'
 	src/server.ts
@@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/index.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../shared/src/index.ts
 	  Imported via "../../shared/dist" from file 'src/app.ts'
 	src/app.ts
diff --git a/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js b/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js
index 4c42d2445d25b..f4b045872292a 100644
--- a/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js
+++ b/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js
@@ -242,7 +242,7 @@ Project '/user/username/projects/myproject/main/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -275,7 +275,7 @@ Project '/user/username/projects/myproject/core/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -313,7 +313,7 @@ Project '/user/username/projects/myproject/indirect/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -334,7 +334,7 @@ Project '/user/username/projects/myproject/coreRef1/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -355,7 +355,7 @@ Project '/user/username/projects/myproject/indirectDisabledChildLoad1/tsconfig.j
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -376,7 +376,7 @@ Project '/user/username/projects/myproject/indirectDisabledChildLoad2/tsconfig.j
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -397,7 +397,7 @@ Project '/user/username/projects/myproject/refToCoreRef3/tsconfig.json' (Configu
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -418,7 +418,7 @@ Project '/user/username/projects/myproject/coreRef3/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/file1.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js b/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js
index 37b36b07abe29..dc9685be6c87c 100644
--- a/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js
+++ b/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js
@@ -70,7 +70,7 @@ Project '/user/username/projects/myproject/packages/consumer/tsconfig.json' (Con
 
 
 	../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../emit-composite/src/testModule.js
 	  Imported via './testModule' from file '../emit-composite/src/index.js'
 	../emit-composite/src/index.js
diff --git a/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js b/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js
index af244659e889f..c979a5b84dd6f 100644
--- a/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js
+++ b/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js
@@ -33,7 +33,7 @@ Project '/user/username/projects/solution/compiler/tsconfig.json' (Configured)
 
 
 	../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	types.ts
 	  Part of 'files' list in tsconfig.json
 	program.ts
diff --git a/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js b/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js
index ab3c92b0b9a1d..d80fa072de0c4 100644
--- a/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js
+++ b/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js
@@ -27,7 +27,7 @@ Project '/a/b/tsconfig.json' (Configured)
 
 
 	../lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	app.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js b/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js
index 306fe238706cd..fddcb0fa0e0c3 100644
--- a/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js
+++ b/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js
@@ -32,7 +32,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	b.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 	sub/a.ts
@@ -101,7 +101,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	b.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 	a.ts
@@ -167,7 +167,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	b.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 
@@ -273,7 +273,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	b.ts
 	  Matched by include pattern '**/*' in 'tsconfig.json'
 	sub/a.ts
diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js
index a77bb2e51b5fe..cb3c63b45f1cb 100644
--- a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js
+++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js
@@ -45,7 +45,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/datetime/baseDate.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -103,7 +103,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../recognizers-text/dist/types/recognizers-text.d.ts
 	  Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts'
 	src/datetime/baseDate.ts
diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js
index e34260a45bdb2..73d3cc01ddeed 100644
--- a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js
+++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js
@@ -45,7 +45,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/datetime/baseDate.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js
index 8358625f4853e..8135d10fc6a27 100644
--- a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js
+++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js
@@ -41,7 +41,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../recognizers-text/dist/types/recognizers-text.d.ts
 	  Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts'
 	src/datetime/baseDate.ts
@@ -93,7 +93,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/datetime/baseDate.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js
index 170cbacc4d17f..d7f9852e16033 100644
--- a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js
+++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js
@@ -57,7 +57,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/datetime/baseDate.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -128,7 +128,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../recognizers-text/dist/types/recognizers-text.d.ts
 	  Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts'
 	src/datetime/baseDate.ts
diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js
index cd7d0a69f8dfb..c0d72dafd98fb 100644
--- a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js
+++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js
@@ -57,7 +57,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/datetime/baseDate.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -120,7 +120,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../recognizers-text/dist/types/recognizers-text.d.ts
 	  Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts'
 	src/datetime/baseDate.ts
diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js
index b170b793afd68..03d1e2e66885c 100644
--- a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js
+++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js
@@ -47,7 +47,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../recognizers-text/dist/types/recognizers-text.d.ts
 	  Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts'
 	src/datetime/baseDate.ts
@@ -105,7 +105,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	src/datetime/baseDate.ts
 	  Matched by include pattern 'src' in 'tsconfig.json'
 
@@ -176,7 +176,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date
 
 
 	../../../../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	../recognizers-text/dist/types/recognizers-text.d.ts
 	  Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts'
 	src/datetime/baseDate.ts
diff --git a/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js b/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js
index 4911e8dd31f46..8c65341cf397e 100644
--- a/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js
+++ b/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js
@@ -31,7 +31,7 @@ Project '/users/username/projects/a/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	c/fc.ts
 	  Imported via "./c/fc" from file 'a.ts'
 	  Matched by include pattern '**/*' in 'tsconfig.json'
@@ -78,7 +78,7 @@ Project '/users/username/projects/b/tsconfig.json' (Configured)
 
 
 	../../../../a/lib/lib.d.ts
-	  Default library
+	  Default library for target 'es3'
 	c/fc.ts
 	  Imported via "./c/fc" from file 'b.ts'
 	  Matched by include pattern '**/*' in 'tsconfig.json'
diff --git a/tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts b/tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts
new file mode 100644
index 0000000000000..a19a7104ae127
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.mjs
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.cjs
+// esm format file
+import * as self from "package";
+self;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts
new file mode 100644
index 0000000000000..113c1fdeb8a62
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts
@@ -0,0 +1,324 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.cjs
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.mjs
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.js
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.cjs
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.mjs
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.js
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.cjs
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.mjs
+// esm format file
+const x = 1;
+export {x};
+// @filename: index.js
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+// @filename: index.cjs
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+// @filename: index.mjs
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: subfolder2/package.json
+{
+}
+// @filename: subfolder2/another/package.json
+{
+    "type": "module"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts
new file mode 100644
index 0000000000000..1020812d5aeb2
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts
@@ -0,0 +1,126 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.mjs
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.cjs
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./a": {
+            "require": "./index.cjs",
+            "node": "./index.mjs"
+        },
+        "./b": {
+            "import": "./index.mjs",
+            "node": "./index.cjs"
+        },
+        ".": {
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+        "./types": {
+            "types": {
+                "import": "./index.d.mts",
+                "require": "./index.d.cts",
+            },
+            "node": {
+                "import": "./index.mjs",
+                "require": "./index.cjs"
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts
new file mode 100644
index 0000000000000..d7032c648b46c
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts
@@ -0,0 +1,27 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+// @filename: index.js
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts
new file mode 100644
index 0000000000000..f7d5aaf822a30
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts
@@ -0,0 +1,32 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const a = {};
+export = a;
+// @filename: subfolder/file.js
+// cjs format file
+const a = {};
+module.exports = a;
+// @filename: index.js
+// esm format file
+const a = {};
+export = a;
+// @filename: file.js
+// esm format file
+import "fs";
+const a = {};
+module.exports = a;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts
new file mode 100644
index 0000000000000..14783731bf9a2
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts
@@ -0,0 +1,29 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: index.js
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts
new file mode 100644
index 0000000000000..53e6b9445002b
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts
@@ -0,0 +1,34 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: index.js
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: file.js
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts
new file mode 100644
index 0000000000000..d5727a3dc787e
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts
@@ -0,0 +1,34 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: index.js
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts
new file mode 100644
index 0000000000000..032290f78bafd
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts
@@ -0,0 +1,30 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.ts
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: index.js
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts
new file mode 100644
index 0000000000000..9452e2003a66c
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts
@@ -0,0 +1,32 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+// @filename: index.js
+// esm format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts
new file mode 100644
index 0000000000000..a8708434b93ae
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts
@@ -0,0 +1,23 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const x = import.meta.url;
+export {x};
+// @filename: index.js
+// esm format file
+const x = import.meta.url;
+export {x};
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts
new file mode 100644
index 0000000000000..65e5721b0bb75
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts
@@ -0,0 +1,92 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mjs
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cjs
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts
new file mode 100644
index 0000000000000..b9d6027f5d791
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts
@@ -0,0 +1,41 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.mjs
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.cjs
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js",
+    "imports": {
+        "#cjs": "./index.cjs",
+        "#mjs": "./index.mjs",
+        "#type": "./index.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts
new file mode 100644
index 0000000000000..2691885690b1b
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts
@@ -0,0 +1,69 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mjs
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cjs
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*": "./*.cjs",
+        "./mjs/*": "./*.mjs",
+        "./js/*": "./*.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts
new file mode 100644
index 0000000000000..6b96f3475834d
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts
@@ -0,0 +1,69 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mjs
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cjs
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*.cjs": "./*.cjs",
+        "./mjs/*.mjs": "./*.mjs",
+        "./js/*.js": "./*.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts
new file mode 100644
index 0000000000000..15892edbe32c5
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts
@@ -0,0 +1,37 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+    const mod3 = await import ("../index.js");
+    const mod4 = await import ("./index.js");
+    h();
+}
+// @filename: index.js
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+    const mod3 = await import ("./index.js");
+    const mod4 = await import ("./subfolder/index.js");
+    f();
+}
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts
new file mode 100644
index 0000000000000..872cad71c91d5
--- /dev/null
+++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts
@@ -0,0 +1,25 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: index.js
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModules1.ts b/tests/cases/conformance/node/nodeModules1.ts
new file mode 100644
index 0000000000000..698a6efec1e24
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModules1.ts
@@ -0,0 +1,321 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.cts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.mts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.ts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.cts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.mts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.ts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.mts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.cts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: index.mts
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+// @filename: index.cts
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+// @filename: index.ts
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: subfolder2/package.json
+{
+}
+// @filename: subfolder2/another/package.json
+{
+    "type": "module"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts b/tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts
new file mode 100644
index 0000000000000..07bf9d9724c34
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts
@@ -0,0 +1,124 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.mts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.cts
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./a": {
+            "require": "./index.cjs",
+            "node": "./index.mjs"
+        },
+        "./b": {
+            "import": "./index.mjs",
+            "node": "./index.cjs"
+        },
+        ".": {
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+        "./types": {
+            "types": {
+                "import": "./index.d.mts",
+                "require": "./index.d.cts",
+            },
+            "node": {
+                "import": "./index.mjs",
+                "require": "./index.cjs"
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesDeclarationEmitDynamicImportWithPackageExports.ts b/tests/cases/conformance/node/nodeModulesDeclarationEmitDynamicImportWithPackageExports.ts
new file mode 100644
index 0000000000000..3f8bae7ffc404
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesDeclarationEmitDynamicImportWithPackageExports.ts
@@ -0,0 +1,71 @@
+// @module: nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+export {};
+// @filename: index.mts
+// esm format file
+export {};
+// @filename: index.cts
+// cjs format file
+export {};
+// @filename: other.ts
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+// @filename: other2.ts
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+// @filename: other.mts
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+// @filename: other2.mts
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+// @filename: other.cts
+// cjs format file, no TLA
+export const a = import("package/cjs");
+export const b = import("package/mjs");
+export const c = import("package");
+export const f = import("inner");
+// @filename: other2.cts
+// cjs format file, no TLA
+export const d = import("inner/cjs");
+export const e = import("inner/mjs");
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+export const cjsMain = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+export const esm = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+export const cjsNonmain = true;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts b/tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts
new file mode 100644
index 0000000000000..2599ff429ff93
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts
@@ -0,0 +1,93 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+// @filename: index.mts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+// @filename: index.cts
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsMain = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const esm = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsNonmain = true;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesDynamicImport.ts b/tests/cases/conformance/node/nodeModulesDynamicImport.ts
new file mode 100644
index 0000000000000..46b317ca52da7
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesDynamicImport.ts
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+// @filename: index.ts
+// esm format file
+export async function main() {
+    const { readFile } = await import("fs");
+}
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesExportAssignments.ts b/tests/cases/conformance/node/nodeModulesExportAssignments.ts
new file mode 100644
index 0000000000000..7cbcd200d9699
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesExportAssignments.ts
@@ -0,0 +1,20 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const a = {};
+export = a;
+// @filename: index.ts
+// esm format file
+const a = {};
+export = a;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts
new file mode 100644
index 0000000000000..d441627d7d0c4
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts
@@ -0,0 +1,67 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder/index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder/index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/index.ts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/another/index.ts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/another/index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/another/index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: index.ts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: subfolder2/package.json
+{
+}
+// @filename: subfolder2/another/package.json
+{
+    "type": "module"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts
new file mode 100644
index 0000000000000..e9a9b9d9eddc3
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts
@@ -0,0 +1,26 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: index.ts
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesImportAssignments.ts b/tests/cases/conformance/node/nodeModulesImportAssignments.ts
new file mode 100644
index 0000000000000..6c22fe83e000d
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesImportAssignments.ts
@@ -0,0 +1,31 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: index.ts
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: file.ts
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts
new file mode 100644
index 0000000000000..103b58371243f
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts
@@ -0,0 +1,31 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @filename: subfolder/index.ts
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: index.ts
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts
new file mode 100644
index 0000000000000..7f90947a5fbcf
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts
@@ -0,0 +1,27 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @filename: subfolder/index.ts
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: index.ts
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts
new file mode 100644
index 0000000000000..5f6984ad1fb8b
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts
@@ -0,0 +1,25 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @filename: subfolder/index.ts
+// cjs format file
+export {default} from "fs";
+// @filename: index.ts
+// esm format file
+export {default} from "fs";
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+    export {};
+    // intentionally missing all helpers
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesImportMeta.ts b/tests/cases/conformance/node/nodeModulesImportMeta.ts
new file mode 100644
index 0000000000000..d684c7b5cb26b
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesImportMeta.ts
@@ -0,0 +1,20 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = import.meta.url;
+export {x};
+// @filename: index.ts
+// esm format file
+const x = import.meta.url;
+export {x};
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts b/tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts
new file mode 100644
index 0000000000000..2a407b2bc680f
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.mts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.cts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.cjs",
+    "imports": {
+        "#type": "package"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts b/tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts
new file mode 100644
index 0000000000000..c0482c86ec292
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.mts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.cts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "package",
+    "imports": {
+        "#type": "package"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesPackageExports.ts b/tests/cases/conformance/node/nodeModulesPackageExports.ts
new file mode 100644
index 0000000000000..897d01b07d73b
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesPackageExports.ts
@@ -0,0 +1,90 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cts
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs": "./index.cjs",
+        "./mjs": "./index.mjs",
+        ".": "./index.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesPackageImports.ts b/tests/cases/conformance/node/nodeModulesPackageImports.ts
new file mode 100644
index 0000000000000..cccf930098ec7
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesPackageImports.ts
@@ -0,0 +1,38 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.mts
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.cts
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js",
+    "imports": {
+        "#cjs": "./index.cjs",
+        "#mjs": "./index.mjs",
+        "#type": "./index.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesPackagePatternExports.ts b/tests/cases/conformance/node/nodeModulesPackagePatternExports.ts
new file mode 100644
index 0000000000000..e22e497a94207
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesPackagePatternExports.ts
@@ -0,0 +1,67 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mts
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cts
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs/index";
+import * as mjs from "inner/mjs/index";
+import * as type from "inner/js/index";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*": "./*.cjs",
+        "./mjs/*": "./*.mjs",
+        "./js/*": "./*.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts b/tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts
new file mode 100644
index 0000000000000..3abe36e0d691e
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts
@@ -0,0 +1,67 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mts
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cts
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        "./cjs/*.cjs": "./*.cjs",
+        "./mjs/*.mjs": "./*.mjs",
+        "./js/*.js": "./*.js"
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts
new file mode 100644
index 0000000000000..78aa93ee17c0c
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts
@@ -0,0 +1,34 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+    const mod3 = await import ("../index.js");
+    const mod4 = await import ("./index.js");
+    h();
+}
+// @filename: index.ts
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+    const mod3 = await import ("./index.js");
+    const mod4 = await import ("./subfolder/index.js");
+    f();
+}
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts
new file mode 100644
index 0000000000000..2fbd5d3b0cd28
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts
@@ -0,0 +1,22 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: index.ts
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module"
+}
+// @filename: subfolder/package.json
+{
+    "type": "commonjs"
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts b/tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts
new file mode 100644
index 0000000000000..52cda091b3276
--- /dev/null
+++ b/tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts
@@ -0,0 +1,53 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+// @filename: index.mts
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+// @filename: index.cts
+// cjs format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+export const noConditionsApplied = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+export const importConditionApplied = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+export const wrongConditionApplied = true;
+// @filename: node_modules/inner/old-types.d.ts
+export const noVersionApplied = true;
+// @filename: node_modules/inner/new-types.d.ts
+export const correctVersionApplied = true;
+// @filename: node_modules/inner/future-types.d.ts
+export const futureVersionApplied = true;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+}
+// @filename: node_modules/inner/package.json
+{
+    "name": "inner",
+    "private": true,
+    "exports": {
+        ".": {
+            "types@>=10000": "./future-types.d.ts",
+            "types@>=1": "./new-types.d.ts",
+            "types": "./old-types.d.ts",
+            "import": "./index.mjs",
+            "node": "./index.js"
+        },
+    }
+}
\ No newline at end of file
diff --git a/tests/cases/conformance/node/nodePackageSelfName.ts b/tests/cases/conformance/node/nodePackageSelfName.ts
new file mode 100644
index 0000000000000..099d9c424e13e
--- /dev/null
+++ b/tests/cases/conformance/node/nodePackageSelfName.ts
@@ -0,0 +1,21 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.mts
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.cts
+// esm format file
+import * as self from "package";
+self;
+// @filename: package.json
+{
+    "name": "package",
+    "private": true,
+    "type": "module",
+    "exports": "./index.js"
+}
\ No newline at end of file
diff --git a/tests/cases/fourslash/moduleNodeNextAutoImport1.ts b/tests/cases/fourslash/moduleNodeNextAutoImport1.ts
new file mode 100644
index 0000000000000..1d951ae07cd58
--- /dev/null
+++ b/tests/cases/fourslash/moduleNodeNextAutoImport1.ts
@@ -0,0 +1,21 @@
+/// <reference path="fourslash.ts" />
+
+// @Filename: /tsconfig.json
+//// { "compilerOptions": { "module": "nodenext" } }
+
+// @Filename: /package.json
+//// { "type": "module" }
+
+// @Filename: /mobx.d.ts
+//// export declare function autorun(): void;
+
+// @Filename: /index.ts
+//// autorun/**/
+
+// @Filename: /utils.ts
+//// import "./mobx.js";
+
+goTo.marker("");
+verify.importFixAtPosition([`import { autorun } from "./mobx.js";
+
+autorun`]);
diff --git a/tests/cases/fourslash/moduleNodeNextAutoImport2.ts b/tests/cases/fourslash/moduleNodeNextAutoImport2.ts
new file mode 100644
index 0000000000000..66346f8e88ab7
--- /dev/null
+++ b/tests/cases/fourslash/moduleNodeNextAutoImport2.ts
@@ -0,0 +1,21 @@
+/// <reference path="fourslash.ts" />
+
+// @Filename: /tsconfig.json
+//// { "compilerOptions": { "module": "nodenext" } }
+
+// @Filename: /package.json
+//// { "type": "module" }
+
+// @Filename: /mobx.d.cts
+//// export declare function autorun(): void;
+
+// @Filename: /index.ts
+//// autorun/**/
+
+// @Filename: /utils.ts
+//// import "./mobx.cjs";
+
+goTo.marker("");
+verify.importFixAtPosition([`import { autorun } from "./mobx.cjs";
+
+autorun`]);
diff --git a/tests/cases/fourslash/moduleNodeNextAutoImport3.ts b/tests/cases/fourslash/moduleNodeNextAutoImport3.ts
new file mode 100644
index 0000000000000..cf092bdc093d9
--- /dev/null
+++ b/tests/cases/fourslash/moduleNodeNextAutoImport3.ts
@@ -0,0 +1,21 @@
+/// <reference path="fourslash.ts" />
+
+// @Filename: /tsconfig.json
+//// { "compilerOptions": { "module": "nodenext" } }
+
+// @Filename: /package.json
+//// { "type": "module" }
+
+// @Filename: /mobx.d.mts
+//// export declare function autorun(): void;
+
+// @Filename: /index.ts
+//// autorun/**/
+
+// @Filename: /utils.ts
+//// import "./mobx.mjs";
+
+goTo.marker("");
+verify.importFixAtPosition([`import { autorun } from "./mobx.mjs";
+
+autorun`]);
diff --git a/tests/cases/fourslash/moduleNodeNextImportFix.ts b/tests/cases/fourslash/moduleNodeNextImportFix.ts
new file mode 100644
index 0000000000000..74edf7daff314
--- /dev/null
+++ b/tests/cases/fourslash/moduleNodeNextImportFix.ts
@@ -0,0 +1,27 @@
+/// <reference path="fourslash.ts" />
+
+// @Filename: package.json
+////{
+////    "type": "module"
+////}
+// @Filename: tsconfig.json
+////{
+////    "compilerOptions": {
+////        "outDir": "./dist",
+////        "module": "node12",
+////        "target": "esnext"
+////    },
+////    "include": ["./src"]
+////}
+// @Filename: src/index.mts
+////import { util } from /*import*/'./deps.mts'
+////export function main() {
+////    util()
+////}
+// @Filename: src/deps.mts
+////export function util() {}
+
+verify.baselineSyntacticAndSemanticDiagnostics();
+goTo.marker("import");
+edit.replace(test.markers()[0].position, "'./deps.mts'".length, "'./deps.mjs'");
+verify.noErrors();
\ No newline at end of file
diff --git a/tests/cases/fourslash/nodeModulesFileEditStillAllowsResolutionsToWork.ts b/tests/cases/fourslash/nodeModulesFileEditStillAllowsResolutionsToWork.ts
new file mode 100644
index 0000000000000..d3c8153d93565
--- /dev/null
+++ b/tests/cases/fourslash/nodeModulesFileEditStillAllowsResolutionsToWork.ts
@@ -0,0 +1,19 @@
+/// <reference path="fourslash.ts" />
+
+// @Filename: /tsconfig.json
+//// { "compilerOptions": { "module": "nodenext", "strict": true } }
+
+// @Filename: /package.json
+//// { "type": "module", "imports": { "#foo": "./foo.cjs" } }
+
+// @Filename: /foo.cts
+//// export const x = 1;
+
+// @Filename: /index.ts
+//// import * as mod from "#foo";
+//// /**/
+
+goTo.marker("");
+edit.insert("mod.x");
+verify.noErrors();
+verify.getSuggestionDiagnostics([]);
diff --git a/tests/cases/fourslash/nodeModulesImportCompletions1.ts b/tests/cases/fourslash/nodeModulesImportCompletions1.ts
new file mode 100644
index 0000000000000..b2356088b0391
--- /dev/null
+++ b/tests/cases/fourslash/nodeModulesImportCompletions1.ts
@@ -0,0 +1,48 @@
+/// <reference path="fourslash.ts" />
+// @allowJs: true
+// @module: nodenext
+// @Filename: /src/module.mts
+//// export {}
+// @Filename: /src/module.cts
+//// export {}
+// @Filename: /src/module.js
+//// export {}
+// @Filename: /src/decl.d.mts
+//// export {}
+// @Filename: /src/decl.d.cts
+//// export {}
+// @Filename: /src/decl.d.ts
+//// export {}
+// @Filename: /src/js.mjs
+//// export {}
+// @Filename: /src/js.cjs
+//// export {}
+// @Filename: /src/js.js
+//// export {}
+
+// @Filename: /main.mts
+//// import {} from "./src//*1*/";
+//// import mod = require("./src//*2*/");
+//// const m = import("./src//*3*/");
+
+// @Filename: /main.cts
+//// import {} from "./src//*4*/";
+//// import mod = require("./src//*5*/");
+//// const m = import("./src//*6*/");
+
+// @Filename: /main.ts
+//// import {} from "./src//*7*/";
+//// import mod = require("./src//*8*/");
+//// const m = import("./src//*9*/");
+
+verify.completions({
+    marker: ["1", "3", "6", "9"],
+    exact: ["decl.cjs", "decl.mjs", "decl.js", "js.cjs", "js.js", "js.mjs", "module.cjs", "module.js", "module.mjs"],
+    isNewIdentifierLocation: true,
+});
+
+verify.completions({
+    marker: ["2", "4", "5", "7", "8"],
+    exact: ["decl.cjs", "decl.mjs", "decl", "js.cjs", "js", "js.mjs", "module.cjs", "module", "module.mjs"],
+    isNewIdentifierLocation: true,
+});
\ No newline at end of file