Skip to content

Commit

Permalink
fix subtraction of runtimes
Browse files Browse the repository at this point in the history
fixes #13063
  • Loading branch information
sokra committed Apr 7, 2021
1 parent 7abdaad commit 651e2ff
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ const subtractRuntime = (a, b) => {
return undefined;
} else if (typeof a === "string") {
if (typeof b === "string") {
return undefined;
return a;
} else if (b.has(a)) {
return undefined;
} else {
Expand Down
1 change: 1 addition & 0 deletions test/configCases/side-effects/issue-13063/another.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("./vendors").UiSelectButton2();
5 changes: 5 additions & 0 deletions test/configCases/side-effects/issue-13063/test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
findBundle: function () {
return ["./vendors.js", "./tst_examples_uiform.js"];
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
it("should not crash", () => {
require("./vendors").UiSelectButton();
require("./vendors").UiSelectButton2();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { UiButton } from "./vendors";

it("should not crash", () => {
UiButton();
});
9 changes: 9 additions & 0 deletions test/configCases/side-effects/issue-13063/vendors/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import uuid from "./uuid";
import { checkIsNonemptyString } from "./types";
export { UiSelectButton } from "./select";
export { UiSelectButton2 } from "./select2";

export function UiButton() {
checkIsNonemptyString();
uuid();
}
9 changes: 9 additions & 0 deletions test/configCases/side-effects/issue-13063/vendors/select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import uuid from "./uuid";
import { checkIsNonemptyString } from "./types";

export function UiSelectButton() {
checkIsNonemptyString();
uuid();
}

console.log.bind(console);
7 changes: 7 additions & 0 deletions test/configCases/side-effects/issue-13063/vendors/select2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import uuid from "./uuid";

export function UiSelectButton2() {
uuid();
}

console.log.bind(console);
1 change: 1 addition & 0 deletions test/configCases/side-effects/issue-13063/vendors/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function checkIsNonemptyString() {}
1 change: 1 addition & 0 deletions test/configCases/side-effects/issue-13063/vendors/uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function uuid() {}
26 changes: 26 additions & 0 deletions test/configCases/side-effects/issue-13063/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
entry: {
tst_examples_uiform: "./tst_examples_uiform",
tst_examples_uitable: "./tst_examples_uitable",
another: "./another"
},
output: {
pathinfo: "verbose",
filename: "[name].js"
},
target: "web",
optimization: {
sideEffects: true,
concatenateModules: true,
splitChunks: {
cacheGroups: {
vendors: {
chunks: "all",
test: /vendors/,
enforce: true,
name: "vendors"
}
}
}
}
};

0 comments on commit 651e2ff

Please sign in to comment.