mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-25 10:54:56 +02:00
fix(dev): refine frontend chunk report layout
This commit is contained in:
6
.github/scripts/frontend-js-size.mts
vendored
6
.github/scripts/frontend-js-size.mts
vendored
@@ -456,6 +456,7 @@ function chunkMarkdownTable(
|
||||
];
|
||||
if (total != null) {
|
||||
lines.push(`| (total) | ${util.formatBytes(total.beforeSize)} | ${util.formatBytes(total.afterSize)} | ${util.calcAndFormatDeltaBytes(total.beforeSize, total.afterSize, 1000)} | ${util.calcAndFormatDeltaPercent(total.beforeSize, total.afterSize, 0.1).replaceAll('\\%', '\\\\%')} |`);
|
||||
lines.push('| | | | | |');
|
||||
}
|
||||
|
||||
for (const row of rows) {
|
||||
@@ -468,17 +469,12 @@ function chunkMarkdownTable(
|
||||
lines.push(`| <details><summary>\`${escapeCell(row.name)}\`</summary> \`${escapeCell(chunkFile)}\` </details> | ${util.formatBytes(row.beforeSize)} | ${util.formatBytes(row.afterSize)} | ${util.calcAndFormatDeltaBytes(row.beforeSize, row.afterSize, 1000)} | ${util.calcAndFormatDeltaPercent(row.beforeSize, row.afterSize, 0.1).replaceAll('\\%', '\\\\%')} |`);
|
||||
}
|
||||
}
|
||||
if (hasGenerated || hasOther) lines.push('| | | | | |');
|
||||
if (hasGenerated) {
|
||||
lines.push(`| (other generated chunks) | ${util.formatBytes(generated.beforeSize)} | ${util.formatBytes(generated.afterSize)} | ${util.calcAndFormatDeltaBytes(generated.beforeSize, generated.afterSize, 1000)} | ${util.calcAndFormatDeltaPercent(generated.beforeSize, generated.afterSize, 0.1).replaceAll('\\%', '\\\\%')} |`);
|
||||
}
|
||||
if (hasOther) {
|
||||
lines.push(`| (other) | ${util.formatBytes(other.beforeSize)} | ${util.formatBytes(other.afterSize)} | ${util.calcAndFormatDeltaBytes(other.beforeSize, other.afterSize, 1000)} | ${util.calcAndFormatDeltaPercent(other.beforeSize, other.afterSize, 0.1).replaceAll('\\%', '\\\\%')} |`);
|
||||
}
|
||||
if (hasGenerated) {
|
||||
lines.push('');
|
||||
lines.push(`_${generated.beforeCount} before / ${generated.afterCount} after generated chunks are grouped._`);
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
|
||||
8
.github/scripts/frontend-js-size.test.mts
vendored
8
.github/scripts/frontend-js-size.test.mts
vendored
@@ -91,7 +91,7 @@ test('groups generated chunks while preserving full and startup totals', async t
|
||||
|
||||
assert.match(report, /\| \(total\) \| 220 B \| 285 B \|/);
|
||||
assert.equal(report.match(/\| \(other generated chunks\) \| 30 B \| 70 B \|/g)?.length, 2);
|
||||
assert.equal(report.match(/_2 before \/ 2 after generated chunks are grouped\._/g)?.length, 2);
|
||||
assert.doesNotMatch(report, /generated chunks are grouped/);
|
||||
assert.doesNotMatch(report, /<summary>`(?:dist|esm)`<\/summary>/);
|
||||
assert.match(report, /<summary>`src\/_boot_\.ts`<\/summary>/);
|
||||
assert.match(report, /<summary>`vue`<\/summary>/);
|
||||
@@ -114,8 +114,8 @@ test('groups small deltas at the bottom while preserving all change counts', asy
|
||||
assert.match(report, /<summary>Startup chunk size \(2 updated, 1 added, 1 removed\)<\/summary>/);
|
||||
assert.equal(report.match(/<summary>`src\/_boot_\.ts`<\/summary>/g)?.length, 2);
|
||||
assert.doesNotMatch(report, /<summary>`(?:vue|i18n|src\/added-small\.ts|src\/removed-small\.ts)`<\/summary>/);
|
||||
assert.match(report, /\| \(total\) \| 225 B \| 276 B \|[^\n]*\n\| <details><summary>`src\/_boot_\.ts`<\/summary>[^\n]*\n\| \| \| \| \| \|\n\| \(other generated chunks\) \| 30 B \| 70 B \|[^\n]*\n\| \(other\) \| 45 B \| 50 B \|/);
|
||||
assert.match(report, /\| \(total\) \| 225 B \| 276 B \|[^\n]*\n\| <details><summary>`src\/_boot_\.ts`<\/summary>[^\n]*\n\| \| \| \| \| \|\n\| \(other generated chunks\) \| 30 B \| 70 B \|[^\n]*\n\| \(other\) \| 95 B \| 100 B \|/);
|
||||
assert.match(report, /\| \(total\) \| 225 B \| 276 B \|[^\n]*\n\| \| \| \| \| \|\n\| <details><summary>`src\/_boot_\.ts`<\/summary>[^\n]*\n\| \(other generated chunks\) \| 30 B \| 70 B \|[^\n]*\n\| \(other\) \| 45 B \| 50 B \|/);
|
||||
assert.match(report, /\| \(total\) \| 225 B \| 276 B \|[^\n]*\n\| \| \| \| \| \|\n\| <details><summary>`src\/_boot_\.ts`<\/summary>[^\n]*\n\| \(other generated chunks\) \| 30 B \| 70 B \|[^\n]*\n\| \(other\) \| 95 B \| 100 B \|/);
|
||||
});
|
||||
|
||||
test('fails instead of overwriting duplicate stable chunk keys', async t => {
|
||||
@@ -224,7 +224,6 @@ test('counts an unmanifested localized JavaScript file in totals and the generat
|
||||
|
||||
assert.match(report, /\| \(total\) \| 235 B \| 275 B \|/);
|
||||
assert.match(report, /\| \(other generated chunks\) \| 45 B \| 70 B \|/);
|
||||
assert.match(report, /_3 before \/ 2 after generated chunks are grouped\._/);
|
||||
});
|
||||
|
||||
test('counts duplicate manifest entries for one physical output only once', async t => {
|
||||
@@ -238,7 +237,6 @@ test('counts duplicate manifest entries for one physical output only once', asyn
|
||||
);
|
||||
|
||||
assert.match(report, /\| \(total\) \| 220 B \| 275 B \|/);
|
||||
assert.match(report, /_2 before \/ 2 after generated chunks are grouped\._/);
|
||||
});
|
||||
|
||||
test('does not count generated-aggregate-only changes as individual chunk changes', async t => {
|
||||
|
||||
Reference in New Issue
Block a user