/
bundlers.cjs
49 lines (44 loc) 路 1.16 KB
/
bundlers.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const cp = require("child_process");
const path = require("path");
const fs = require("fs");
const expectedPath = path.join(__dirname, "expected.txt");
const expected = fs.readFileSync(expectedPath, "utf8");
{
console.log("Building with webpack 4");
cp.execSync("yarn webpack", {
cwd: path.join(__dirname, "webpack-4"),
encoding: "utf8",
});
console.log("Testing the webpack 4 bundle");
const out = cp.execSync("node ./output.js", {
cwd: path.join(__dirname, "webpack-4"),
encoding: "utf8",
});
if (expected === out) {
console.log("OK");
} else if (process.env.OVERWRITE) {
fs.writeFileSync(expectedPath, out);
console.log("UPDATED");
} else {
console.error("FAILED\n");
console.error(out);
}
}
{
console.log("Building with webpack 5");
cp.execSync("yarn webpack", {
cwd: path.join(__dirname, "webpack-5"),
encoding: "utf8",
});
console.log("Testing the webpack 5 bundle");
const out = cp.execSync("node ./output.js", {
cwd: path.join(__dirname, "webpack-5"),
encoding: "utf8",
});
if (expected === out) {
console.log("OK");
} else {
console.error("FAILED\n");
console.error(out);
}
}