@@ -202,7 +251,13 @@ async function run() {
Comparing: ${commitRange}
- ${detailsTable}
+
+ Details of page changes
+
+ ${pageDetailsTable}
+
+
+ ${mainDetailsTable}
`;
diff --git a/scripts/sizeSnapshot/create.js b/scripts/sizeSnapshot/create.js
index 8ccc35c863bb50..66f4863efcc07a 100644
--- a/scripts/sizeSnapshot/create.js
+++ b/scripts/sizeSnapshot/create.js
@@ -49,12 +49,78 @@ async function getWebpackSizes() {
});
}
+// waiting for String.prototype.matchAll in node 10
+function* matchAll(string, regex) {
+ let match = null;
+ do {
+ match = regex.exec(string);
+ if (match !== null) {
+ yield match;
+ }
+ } while (match !== null);
+}
+
+/**
+ * Inverse to `pretty-bytes`
+ *
+ * @param {string} n
+ * @param {'B', 'kB' | 'MB' | 'GB' | 'TB' | 'PB'} unit
+ * @returns {number}
+ */
+
+function prettyBytesInverse(n, unit) {
+ const metrixPrefix = unit.length < 2 ? '' : unit[0];
+ const metricPrefixes = ['', 'k', 'M', 'G', 'T', 'P'];
+ const metrixPrefixIndex = metricPrefixes.indexOf(metrixPrefix);
+ if (metrixPrefixIndex === -1) {
+ throw new TypeError(
+ `unrecognized metric prefix '${metrixPrefix}' in unit '${unit}'. only '${metricPrefixes.join(
+ "', '",
+ )}' are allowed`,
+ );
+ }
+
+ const power = metrixPrefixIndex * 3;
+ return n * 10 ** power;
+}
+
+/**
+ * parses output from next build to size snapshot format
+ * @returns {[string, { gzip: number, files: number, packages: number }][]}
+ */
+
+async function getNextPagesSize() {
+ const consoleOutput = await fse.readFile(path.join(__dirname, 'build/docs.next'), {
+ encoding: 'utf8',
+ });
+ const pageRegex = /^(?