Skip to content

Commit

Permalink
Update Filesize to 4.0.1 with new API (#27898)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferbaxter committed Apr 21, 2020
1 parent 9f67f89 commit b4427a8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
28 changes: 16 additions & 12 deletions build-system/tasks/bundle-size/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const {
VERSION: internalRuntimeVersion,
} = require('../../compile/internal-version');
const {cyan, green, red, yellow} = require('ansi-colors');
const {serialReport} = require('@ampproject/filesize');
const {report, Report} = require('@ampproject/filesize');

const requestPost = util.promisify(require('request').post);

Expand All @@ -58,18 +58,22 @@ async function getBrotliBundleSizes() {
const bundleSizes = {};

log(cyan('brotli'), 'bundle sizes are:');
const values = serialReport(process.cwd(), (content) =>
content.replace(replacementExpression, normalizedRtvNumber)
await report(
process.cwd(),
(content) => content.replace(replacementExpression, normalizedRtvNumber),
class extends Report {
update(context) {
const completed = super.getUpdated(context);
for (const complete of completed) {
const [filePath, sizeMap] = complete;
const relativePath = path.relative('.', filePath);
const reportedSize = parseFloat((sizeMap[0][0] / 1024).toFixed(2));
log(' ', cyan(relativePath) + ':', green(reportedSize + 'KB'));
bundleSizes[relativePath] = reportedSize;
}
}
}
);
let next = await values.next();
while (!next.done) {
const [filePath, brotliSize] = next.value;
const relativePath = path.relative('.', filePath);
const reportedSize = parseFloat((brotliSize / 1024).toFixed(2));
log(' ', cyan(relativePath) + ':', green(reportedSize + 'KB'));
bundleSizes[relativePath] = reportedSize;
next = await values.next();
}

return bundleSizes;
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"web-animations-js": "2.3.1"
},
"devDependencies": {
"@ampproject/filesize": "3.2.1",
"@ampproject/filesize": "4.0.1",
"@ampproject/remapping": "0.2.0",
"@babel/core": "7.9.0",
"@babel/helper-plugin-test-runner": "7.8.3",
Expand Down Expand Up @@ -196,6 +196,7 @@
"dist/v0/*-?.?.js",
"dist/*.mjs",
"dist/v0/*-?.?.mjs"
]
],
"trackFormat": ["brotli"]
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@ampproject/animations/-/animations-0.2.0.tgz#82b6b68b6fe0eacbcc95d3f0a82ddf19a0e2b316"
integrity sha512-CiMdKK9eMa6eqhqZc9bq86nPdgbALY+E8rKgUPR7wf2wGUNTm/jtFZQ7fn4sj/oggn0wvadBokabErtl1m1KSw==

"@ampproject/filesize@3.2.1":
version "3.2.1"
resolved "https://registry.yarnpkg.com/@ampproject/filesize/-/filesize-3.2.1.tgz#5ed28338dd6213a72acea14cead69ce34e14f378"
integrity sha512-b5Q0dg0t5fizZMX3qL4SuoUKNQ5i1WCiD4MNAWGokX2hFWPCeroa5UxxPIP2LmORDwtkgcZksZ6QrmiA/AU2Ng==
"@ampproject/filesize@4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@ampproject/filesize/-/filesize-4.0.1.tgz#a969318ec06b440e66f3b16df0f25cb826c2cd30"
integrity sha512-YDaHU5d4RL6xuJV4W+1Eh3QxXtU0Y8i4hdrtRY7OLyG93wfYOLiabkSFbg5HQmxFWqj+NYko/3pjpBiXnEuhdw==
dependencies:
bytes "3.1.0"
fast-glob "3.2.2"
Expand Down

0 comments on commit b4427a8

Please sign in to comment.