Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions internal/core/compileroptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,11 @@ func (options *CompilerOptions) GetEmitModuleDetectionKind() ModuleDetectionKind
if options.ModuleDetection != ModuleDetectionKindNone {
return options.ModuleDetection
}
switch options.GetEmitModuleKind() {
case ModuleKindNode16, ModuleKindNode20, ModuleKindNodeNext:
moduleKind := options.GetEmitModuleKind()
if ModuleKindNode16 <= moduleKind && moduleKind <= ModuleKindNodeNext {
return ModuleDetectionKindForce
default:
return ModuleDetectionKindAuto
}
return ModuleDetectionKindAuto
}

func (options *CompilerOptions) GetResolvePackageJsonExports() bool {
Expand Down
2 changes: 1 addition & 1 deletion internal/transformers/moduletransforms/commonjsmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (tx *CommonJSModuleTransformer) visitSourceFile(node *ast.SourceFile) *ast.
func (tx *CommonJSModuleTransformer) shouldEmitUnderscoreUnderscoreESModule() bool {
if tspath.FileExtensionIsOneOf(tx.currentSourceFile.FileName(), tspath.SupportedJSExtensionsFlat) &&
tx.currentSourceFile.CommonJSModuleIndicator != nil &&
(tx.currentSourceFile.ExternalModuleIndicator == nil /*|| tx.currentSourceFile.ExternalModuleIndicator == true*/) { // !!!
(tx.currentSourceFile.ExternalModuleIndicator == nil || tx.currentSourceFile.ExternalModuleIndicator.Kind == ast.KindSourceFile) {
return false
}
if tx.currentModuleInfo.exportEquals == nil && ast.IsExternalModule(tx.currentSourceFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ interface GlobalThing { a: number }
const a: GlobalThing = { a: 0 };

//// [usage.js]
"use strict";
/// <reference types="pkg" />
Object.defineProperty(exports, "__esModule", { value: true });
const a = { a: 0 };

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const a = {};
module.exports = a;
//// [file.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// cjs format file
const a = {};
module.exports = a;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
--- old.nodeModulesAllowJsExportAssignment(module=node16).js
+++ new.nodeModulesAllowJsExportAssignment(module=node16).js
@@= skipped -34, +34 lines =@@
module.exports = a;
//// [file.js]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
// cjs format file
const a = {};
module.exports = a;
@@= skipped -15, +16 lines =@@
@@= skipped -49, +49 lines =@@


//// [index.d.ts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = a;
const a = {};
module.exports = a;
//// [file.js]
"use strict";
// cjs format file
const a = {};
module.exports = a;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
--- old.nodeModulesAllowJsExportAssignment(module=node18).js
+++ new.nodeModulesAllowJsExportAssignment(module=node18).js
@@= skipped -33, +33 lines =@@
const a = {};
module.exports = a;
//// [file.js]
-"use strict";
// cjs format file
const a = {};
module.exports = a;
@@= skipped -16, +15 lines =@@
@@= skipped -49, +49 lines =@@


//// [index.d.ts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const a = {};
module.exports = a;
//// [file.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// cjs format file
const a = {};
module.exports = a;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
--- old.nodeModulesAllowJsExportAssignment(module=node20).js
+++ new.nodeModulesAllowJsExportAssignment(module=node20).js
@@= skipped -34, +34 lines =@@
module.exports = a;
//// [file.js]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
// cjs format file
const a = {};
module.exports = a;
@@= skipped -15, +16 lines =@@
@@= skipped -49, +49 lines =@@


//// [index.d.ts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const a = {};
module.exports = a;
//// [file.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// cjs format file
const a = {};
module.exports = a;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
--- old.nodeModulesAllowJsExportAssignment(module=nodenext).js
+++ new.nodeModulesAllowJsExportAssignment(module=nodenext).js
@@= skipped -34, +34 lines =@@
module.exports = a;
//// [file.js]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
// cjs format file
const a = {};
module.exports = a;
@@= skipped -15, +16 lines =@@
@@= skipped -49, +49 lines =@@


//// [index.d.ts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ three.foo;

//// [1.cjs]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = {};
//// [2.cjs]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export var foo = 0;
exports.foo = 0;
//// [3.cjs]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
--- old.nodeModulesCJSEmit1(module=node18).js
+++ new.nodeModulesCJSEmit1(module=node18).js
@@= skipped -21, +21 lines =@@

//// [1.cjs]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
@@= skipped -24, +24 lines =@@
module.exports = {};
//// [2.cjs]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+export var foo = 0;
exports.foo = 0;
//// [3.cjs]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ three.foo;

//// [1.cjs]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = {};
//// [2.cjs]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export var foo = 0;
exports.foo = 0;
//// [3.cjs]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
--- old.nodeModulesCJSEmit1(module=node20).js
+++ new.nodeModulesCJSEmit1(module=node20).js
@@= skipped -21, +21 lines =@@

//// [1.cjs]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
@@= skipped -24, +24 lines =@@
module.exports = {};
//// [2.cjs]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+export var foo = 0;
exports.foo = 0;
//// [3.cjs]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ three.foo;

//// [1.cjs]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = {};
//// [2.cjs]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export var foo = 0;
exports.foo = 0;
//// [3.cjs]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
--- old.nodeModulesCJSEmit1(module=nodenext).js
+++ new.nodeModulesCJSEmit1(module=nodenext).js
@@= skipped -21, +21 lines =@@

//// [1.cjs]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
@@= skipped -24, +24 lines =@@
module.exports = {};
//// [2.cjs]
"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+export var foo = 0;
exports.foo = 0;
//// [3.cjs]
Expand Down