Skip to content

Commit ded9ed5

Browse files
committed
split scenarios into scenarios and addons
1 parent 24d84b7 commit ded9ed5

25 files changed

+264
-116
lines changed

.github/workflows/compare.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ jobs:
2222
current:
2323
- "${{ github.event.inputs.current }}"
2424
case:
25-
- minimal
2625
- common-libs
2726
- esbuild-three
2827
scenario:
29-
- development-default-build
30-
- development-cached-build
31-
- development-cached-pnp-build
32-
- development-cached-rebuild
33-
- production-default-build
34-
- production-cached-build
35-
- production-source-map-build
36-
- production-source-map-cached-build
37-
runs-on: windows-latest
28+
- development-build
29+
- development-build+persistent-cache
30+
- development-build+pnp
31+
- development-rebuild
32+
- production-build
33+
- production-build+no-minimize
34+
- production-build+no-minimize+no-concatenation
35+
- production-build+persistent-cache
36+
- production-build+source-map+persistent-cache
37+
runs-on: linux-latest
3838
steps:
3939
- run: echo ${{ github.event.inputs.base }} vs ${{ github.event.inputs.current }}
4040
- uses: actions/checkout@v2

addons/babel-env.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const packageJson = (json) => {
2+
json.browserslist = "> 0.25%, not dead";
3+
Object.assign(json.dependencies, {
4+
"@babel/core": "^7.12.16",
5+
"@babel/preset-env": "^7.12.16",
6+
"babel-loader": "^8.2.2",
7+
"core-js": "^3.8.3",
8+
});
9+
return json;
10+
};
11+
12+
export const config = (content) => `${content}
13+
14+
module.exports.module = module.exports.module || {};
15+
module.exports.module.rules = module.exports.module.rules || [];
16+
module.exports.module.rules.push({
17+
test: /\.js$/,
18+
use: {
19+
loader: "babel-loader",
20+
options: {
21+
sourceType: "unambiguous",
22+
presets: [["@babel/env", {
23+
useBuiltIns: "usage",
24+
corejs: 3
25+
}]]
26+
}
27+
}
28+
});
29+
`;

addons/no-concatenation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const args = ["--no-optimization-concatenate-modules"];

addons/no-minimize.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const args = ["--no-optimization-minimize"];

addons/persistent-cache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const args = ["--cache-type", "filesystem"];

addons/pnp.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const installOptions = { pnp: true };

addons/source-map.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const args = ["--devtool", "source-map"];

bin/compare-scenarios.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import compare from "../lib/compare.js";
2+
import { formatDiffTable, formatResultTable } from "../lib/utils.js";
3+
import { mkdir, writeFile } from "fs/promises";
4+
import { resolve } from "path";
5+
import { fileURLToPath } from "url";
6+
7+
const [
8+
,
9+
,
10+
caseName = "minimal",
11+
baseline = "development-default-build",
12+
scenarioName = "development-cached-build",
13+
] = process.argv;
14+
15+
const rootDir = resolve(fileURLToPath(import.meta.url), "../..");
16+
17+
(async () => {
18+
const { diff, result } = await compare(caseName, scenarioName, {
19+
runs: 30,
20+
verboseSetup: true,
21+
baselineScenario: baseline,
22+
});
23+
console.log(formatResultTable(result, { colors: true, verbose: true }));
24+
console.log();
25+
console.log(formatDiffTable(diff, { colors: true, verbose: true }));
26+
await mkdir(resolve(rootDir, "output"), { recursive: true });
27+
await writeFile(
28+
resolve(rootDir, `output/${caseName}.json`),
29+
JSON.stringify(diff, null, 2)
30+
);
31+
})().catch((err) => {
32+
process.exitCode = 1;
33+
console.error(err.stack);
34+
});

bin/compare.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import compare from "../lib/compare.js";
2-
import { formatDiffTable } from "../lib/utils.js";
2+
import { formatDiffTable, formatResultTable } from "../lib/utils.js";
33
import { mkdir, writeFile } from "fs/promises";
44
import { resolve } from "path";
55
import { fileURLToPath } from "url";
@@ -16,7 +16,7 @@ const [
1616
const rootDir = resolve(fileURLToPath(import.meta.url), "../..");
1717

1818
(async () => {
19-
const diff = await compare(caseName, scenarioName, {
19+
const { diff, result } = await compare(caseName, scenarioName, {
2020
runs: 30,
2121
verboseSetup: true,
2222
baselineDependencies: {
@@ -26,6 +26,8 @@ const rootDir = resolve(fileURLToPath(import.meta.url), "../..");
2626
webpack: `webpack/webpack#${current}`,
2727
},
2828
});
29+
console.log(formatResultTable(result, { colors: true, verbose: true }));
30+
console.log();
2931
console.log(formatDiffTable(diff, { colors: true, verbose: true }));
3032
await mkdir(resolve(rootDir, "output"), { recursive: true });
3133
await writeFile(

bin/measure-mean.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import measure from "../lib/measure.js";
2+
import { formatResultTable } from "../lib/utils.js";
23

34
const [
45
,
@@ -8,7 +9,9 @@ const [
89
] = process.argv;
910

1011
(async () => {
11-
console.log(
12-
await measure(caseName, scenarioName, { runs: 20, verboseSetup: true })
13-
);
12+
const result = await measure(caseName, scenarioName, {
13+
runs: 30,
14+
verboseSetup: true,
15+
});
16+
console.log(formatResultTable(result, { colors: true, verbose: true }));
1417
})().catch((err) => console.error(err.stack));

0 commit comments

Comments
 (0)