Skip to content

Commit 652e6c5

Browse files
authored
[sizebot] Add link to diff view (#24790)
Updates the sizebot output so that the file names link to a diff view of the corresponding build artifact. Example diff view: https://react-builds.vercel.app/commits/955cad9bcc6d755b2a672f8038fe9754e0fe5108/files/oss-stable-semver/react-dom/cjs/react-dom.production.min.js?compare=c3d7a7e3d72937443ef75b7e29335c98ad0f1424 The diff view itself is rendered by a Next.js app that I built as a side project and is hosted at https://react-builds.vercel.app. If we find this useful enough I could move the app to a React-owned repo but since this isn't a critical feature it might be OK to leave it separate for now, so we don't need to commit to supporting it indefinitely.
1 parent 955cad9 commit 652e6c5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

dangerfile.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ const header = `
8484
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
8585
| ---- | --- | ---- | ------- | -------- | --------- | ------------ |`;
8686

87-
function row(result) {
87+
function row(result, baseSha, headSha) {
88+
const diffViewUrl = `https://react-builds.vercel.app/commits/${headSha}/files/${result.path}?compare=${baseSha}`;
8889
// prettier-ignore
89-
return `| ${result.path} | **${change(result.change)}** | ${kbs(result.baseSize)} | ${kbs(result.headSize)} | ${change(result.changeGzip)} | ${kbs(result.baseSizeGzip)} | ${kbs(result.headSizeGzip)}`;
90+
return `| [${result.path}](${diffViewUrl}) | **${change(result.change)}** | ${kbs(result.baseSize)} | ${kbs(result.headSize)} | ${change(result.changeGzip)} | ${kbs(result.baseSizeGzip)} | ${kbs(result.headSizeGzip)}`;
9091
}
9192

9293
(async function() {
@@ -196,7 +197,7 @@ function row(result) {
196197
artifactPath
197198
);
198199
}
199-
criticalResults.push(row(result));
200+
criticalResults.push(row(result, baseSha, headSha));
200201
}
201202

202203
let significantResults = [];
@@ -212,7 +213,7 @@ function row(result) {
212213
// Skip critical artifacts. We added those earlier, in a fixed order.
213214
!CRITICAL_ARTIFACT_PATHS.has(result.path)
214215
) {
215-
criticalResults.push(row(result));
216+
criticalResults.push(row(result, baseSha, headSha));
216217
}
217218

218219
// Do the same for results that exceed the significant threshold. These
@@ -224,7 +225,7 @@ function row(result) {
224225
result.change === Infinity ||
225226
result.change === -1
226227
) {
227-
significantResults.push(row(result));
228+
significantResults.push(row(result, baseSha, headSha));
228229
}
229230
}
230231

0 commit comments

Comments
 (0)