Skip to content

Commit 3f10a17

Browse files
committed
set output.environment.module=true when output.module enabled
1 parent 4bc6150 commit 3f10a17

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/config/defaults.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ const applyOutputDefaults = (
907907
D(output, "strictModuleExceptionHandling", false);
908908

909909
const optimistic = v => v || v === undefined;
910+
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
910911
F(
911912
output.environment,
912913
"arrowFunction",
@@ -921,7 +922,11 @@ const applyOutputDefaults = (
921922
F(output.environment, "forOf", () => tp && optimistic(tp.forOf));
922923
F(output.environment, "bigIntLiteral", () => tp && tp.bigIntLiteral);
923924
F(output.environment, "dynamicImport", () => tp && tp.dynamicImport);
924-
F(output.environment, "module", () => tp && tp.module);
925+
F(
926+
output.environment,
927+
"module",
928+
() => tp && conditionallyOptimistic(tp.module, output.module)
929+
);
925930

926931
const { trustedTypes } = output;
927932
if (trustedTypes) {

test/Defaults.unittest.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,9 @@ describe("Defaults", () => {
882882
- "chunkFilename": "[name].js",
883883
+ "chunkFilename": "[name].mjs",
884884
@@ ... @@
885+
- "module": undefined,
886+
+ "module": true,
887+
@@ ... @@
885888
- "filename": "[name].js",
886889
+ "filename": "[name].mjs",
887890
@@ ... @@

0 commit comments

Comments
 (0)