Skip to content

Commit

Permalink
set output.environment.module=true when output.module enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop committed Feb 2, 2022
1 parent 4bc6150 commit 3f10a17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ const applyOutputDefaults = (
D(output, "strictModuleExceptionHandling", false);

const optimistic = v => v || v === undefined;
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
F(
output.environment,
"arrowFunction",
Expand All @@ -921,7 +922,11 @@ const applyOutputDefaults = (
F(output.environment, "forOf", () => tp && optimistic(tp.forOf));
F(output.environment, "bigIntLiteral", () => tp && tp.bigIntLiteral);
F(output.environment, "dynamicImport", () => tp && tp.dynamicImport);
F(output.environment, "module", () => tp && tp.module);
F(
output.environment,
"module",
() => tp && conditionallyOptimistic(tp.module, output.module)
);

const { trustedTypes } = output;
if (trustedTypes) {
Expand Down
3 changes: 3 additions & 0 deletions test/Defaults.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,9 @@ describe("Defaults", () => {
- "chunkFilename": "[name].js",
+ "chunkFilename": "[name].mjs",
@@ ... @@
- "module": undefined,
+ "module": true,
@@ ... @@
- "filename": "[name].js",
+ "filename": "[name].mjs",
@@ ... @@
Expand Down

0 comments on commit 3f10a17

Please sign in to comment.