Skip to content

Commit

Permalink
Merge pull request #12832 from webpack/bugfix/array-default-fallback
Browse files Browse the repository at this point in the history
fix array expansion when using "..."
  • Loading branch information
sokra committed Mar 8, 2021
2 parents 9e7a293 + e63e733 commit c18b3c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/config/defaults.js
Expand Up @@ -95,7 +95,7 @@ const A = (obj, prop, factory) => {
const item = value[i];
if (item === "...") {
if (newArray === undefined) {
newArray = i > 0 ? value.slice(0, i - 1) : [];
newArray = value.slice(0, i);
obj[prop] = /** @type {T[P]} */ (/** @type {unknown} */ (newArray));
}
const items = /** @type {any[]} */ (/** @type {unknown} */ (factory()));
Expand Down
20 changes: 20 additions & 0 deletions test/Defaults.unittest.js
Expand Up @@ -1703,4 +1703,24 @@ describe("Defaults", () => {
process.chdir(cwd);
}
);

test(
"array defaults",
{
output: {
enabledChunkLoadingTypes: ["require", "..."],
enabledWasmLoadingTypes: ["...", "async-node"]
}
},
e =>
e.toMatchInlineSnapshot(`
- Expected
+ Received
@@ ... @@
+ "require",
@@ ... @@
+ "async-node",
`)
);
});

0 comments on commit c18b3c5

Please sign in to comment.