Skip to content

Commit

Permalink
update dynamicImport default, add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop committed Feb 3, 2022
1 parent 3f10a17 commit b254f35
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,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,
"dynamicImport",
() => tp && conditionallyOptimistic(tp.dynamicImport, output.module)
);
F(
output.environment,
"module",
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",
@@ ... @@
- "dynamicImport": undefined,
+ "dynamicImport": true,
@@ ... @@
- "module": undefined,
+ "module": true,
@@ ... @@
Expand Down
3 changes: 3 additions & 0 deletions test/configCases/output-module/check-defaults/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = [
[/For the selected environment is no default ESM chunk format available/]
];
3 changes: 3 additions & 0 deletions test/configCases/output-module/check-defaults/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
it("should compile and run", () => {
expect(import.meta.url).toBe(import.meta.url);
});
17 changes: 17 additions & 0 deletions test/configCases/output-module/check-defaults/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
experiments: {
outputModule: true
},
devtool: false,
target: "web"
},
{
experiments: {
outputModule: true
},
devtool: false,
target: "node10"
}
];

0 comments on commit b254f35

Please sign in to comment.