Fix a few more issues that should fix the CI
Dan committed
Dec 24, 2017 at 01:16 UTC
5bf608723d5ef84ca587448adb4c9431859eca8b
1 file changed
+12
-7
scripts/rollup/stats.js
+12
-7
@@ -9,7 +9,8 @@ const prevBuildResults = require('./results.json');
9
10
const currentBuildResults = {
11
// Mutated inside build.js during a build run.
12
- bundleSizes: [],
12
+ // We make a copy so that partial rebuilds don't erase other stats.
13
+ bundleSizes: [...prevBuildResults.bundleSizes],
14
};
15
16
function saveResults() {
@@ -41,11 +42,15 @@ function printResults() {
42
chalk.gray.yellow('Diff'),
43
],
44
});
44
- currentBuildResults.bundleSizes.forEach(index => {
45
- const result = currentBuildResults.bundleSizes[index];
46
- const prev = prevBuildResults.bundleSizes.filter(
47
- res => res.filename === result.filename
48
- )[0];
45
+ currentBuildResults.bundleSizes.forEach(result => {
46
+ const matches = prevBuildResults.bundleSizes.filter(
47
+ ({filename, bundleType}) =>
48
+ filename === result.filename && bundleType === result.bundleType
49
+ );
50
+ if (matches.length > 1) {
51
+ throw new Error(`Ambiguous bundle size record for: ${result.filename}`);
52
+ }
53
+ const prev = matches[0];
54
if (result === prev) {
55
// We didn't rebuild this bundle.
56
return;
@@ -56,7 +61,7 @@ function printResults() {
61
let prevSize = prev ? prev.size : 0;
62
let prevGzip = prev ? prev.gzip : 0;
63
table.push([
59
- chalk.white.bold(`${result.filename} (${result.bundleType}`),
64
+ chalk.white.bold(`${result.filename} (${result.bundleType})`),
65
chalk.gray.bold(filesize(prevSize)),
66
chalk.white.bold(filesize(size)),
67
percentChange(prevSize, size),