Skip to content

Conversation

@avivkeller
Copy link
Member

@avivkeller avivkeller commented Dec 11, 2025

This PR adds a system for adding a series of comparators to our codebase.

At the moment, only a web comparison is implemented. To add more comparators, add [generator-name].mjs to the scripts/compare-builds directory. These comparators will run on incoming PRs.

Example output: #517 (comment)

@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
api-docs-tooling Ready Ready Preview Dec 12, 2025 8:32pm

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 1.29870% with 152 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.58%. Comparing base (0e07e21) to head (9ef0970).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
scripts/compare-builds/web.mjs 0.00% 151 Missing ⚠️
src/generators/web/utils/processing.mjs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #517      +/-   ##
==========================================
- Coverage   80.76%   79.58%   -1.19%     
==========================================
  Files         119      120       +1     
  Lines       11877    12056     +179     
  Branches      841      841              
==========================================
+ Hits         9593     9595       +2     
- Misses       2281     2458     +177     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Dec 12, 2025

Web Generator

Pages (66)
File Base Head Diff
addons.html 278.88 KB 278.78 KB -101.00 B (-0.04%)
assert.html 331.65 KB 331.55 KB -101.00 B (-0.03%)
async_context.html 160.58 KB 160.48 KB -101.00 B (-0.06%)
async_hooks.html 154.71 KB 154.61 KB -101.00 B (-0.06%)
buffer.html 880.05 KB 879.95 KB -101.00 B (-0.01%)
child_process.html 372.15 KB 372.05 KB -101.00 B (-0.03%)
cli.html 501.49 KB 501.39 KB -101.00 B (-0.02%)
cluster.html 194.66 KB 194.56 KB -101.00 B (-0.05%)
console.html 143.07 KB 142.97 KB -101.00 B (-0.07%)
crypto.html 984.13 KB 984.03 KB -101.00 B (-0.01%)
debugger.html 53.34 KB 53.25 KB -101.00 B (-0.18%)
deprecations.html 502.45 KB 502.36 KB -101.00 B (-0.02%)
dgram.html 183.87 KB 183.77 KB -101.00 B (-0.05%)
diagnostics_channel.html 219.08 KB 218.98 KB -101.00 B (-0.05%)
dns.html 284.53 KB 284.43 KB -101.00 B (-0.03%)
documentation.html 35.21 KB 35.11 KB -101.00 B (-0.28%)
domain.html 102.34 KB 102.24 KB -101.00 B (-0.10%)
embedding.html 57.58 KB 57.49 KB -101.00 B (-0.17%)
environment_variables.html 44.77 KB 44.68 KB -101.00 B (-0.22%)
errors.html 417.78 KB 417.68 KB -101.00 B (-0.02%)
esm.html 158.50 KB 158.41 KB -101.00 B (-0.06%)
events.html 448.87 KB 448.77 KB -101.00 B (-0.02%)
fs.html 1.30 MB 1.30 MB -101.00 B (-0.01%)
globals.html 223.24 KB 223.14 KB -101.00 B (-0.04%)
http.html 713.44 KB 713.34 KB -101.00 B (-0.01%)
http2.html 758.46 KB 758.36 KB -101.00 B (-0.01%)
https.html 146.76 KB 146.66 KB -101.00 B (-0.07%)
index.html 33.30 KB 33.20 KB -101.00 B (-0.30%)
inspector.html 153.15 KB 153.05 KB -101.00 B (-0.06%)
intl.html 60.52 KB 60.42 KB -101.00 B (-0.16%)
module.html 287.45 KB 287.35 KB -101.00 B (-0.03%)
modules.html 185.60 KB 185.50 KB -101.00 B (-0.05%)
n-api.html 910.24 KB 910.14 KB -101.00 B (-0.01%)
net.html 344.13 KB 344.03 KB -101.00 B (-0.03%)
os.html 127.92 KB 127.83 KB -101.00 B (-0.08%)
packages.html 166.24 KB 166.14 KB -101.00 B (-0.06%)
path.html 142.15 KB 142.05 KB -101.00 B (-0.07%)
perf_hooks.html 359.81 KB 359.71 KB -101.00 B (-0.03%)
permissions.html 58.96 KB 58.87 KB -101.00 B (-0.17%)
process.html 677.50 KB 677.40 KB -101.00 B (-0.01%)
punycode.html 62.70 KB 62.60 KB -101.00 B (-0.16%)
querystring.html 61.57 KB 61.47 KB -101.00 B (-0.16%)
quic.html 347.01 KB 346.91 KB -101.00 B (-0.03%)
readline.html 245.47 KB 245.37 KB -101.00 B (-0.04%)
repl.html 187.08 KB 186.99 KB -101.00 B (-0.05%)
report.html 180.33 KB 180.24 KB -101.00 B (-0.05%)
single-executable-applications.html 108.07 KB 107.97 KB -101.00 B (-0.09%)
sqlite.html 230.65 KB 230.55 KB -101.00 B (-0.04%)
stream.html 858.38 KB 858.28 KB -101.00 B (-0.01%)
string_decoder.html 53.11 KB 53.01 KB -101.00 B (-0.19%)
synopsis.html 43.52 KB 43.42 KB -101.00 B (-0.23%)
test.html 681.16 KB 681.06 KB -101.00 B (-0.01%)
timers.html 120.63 KB 120.53 KB -101.00 B (-0.08%)
tls.html 343.22 KB 343.12 KB -101.00 B (-0.03%)
tracing.html 85.30 KB 85.20 KB -101.00 B (-0.12%)
tty.html 87.01 KB 86.91 KB -101.00 B (-0.11%)
typescript.html 55.02 KB 54.92 KB -101.00 B (-0.18%)
url.html 347.55 KB 347.45 KB -101.00 B (-0.03%)
util.html 692.12 KB 692.02 KB -101.00 B (-0.01%)
v8.html 285.39 KB 285.29 KB -101.00 B (-0.03%)
vm.html 336.09 KB 336.00 KB -101.00 B (-0.03%)
wasi.html 67.95 KB 67.85 KB -101.00 B (-0.15%)
webcrypto.html 488.07 KB 487.97 KB -101.00 B (-0.02%)
webstreams.html 336.67 KB 336.57 KB -101.00 B (-0.03%)
worker_threads.html 360.22 KB 360.12 KB -101.00 B (-0.03%)
zlib.html 275.54 KB 275.44 KB -101.00 B (-0.04%)

@avivkeller avivkeller marked this pull request as ready for review December 12, 2025 01:20
@avivkeller avivkeller requested a review from a team as a code owner December 12, 2025 01:20
Copilot AI review requested due to automatic review settings December 12, 2025 01:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a build comparison system to automatically analyze and report size changes in generated artifacts for pull requests. The system dynamically discovers comparator scripts and generates markdown reports showing file size differences between base and head branches.

Key Changes:

  • Adds a new GitHub Actions workflow that runs after the Generate Docs workflow completes, comparing build outputs between PR head and base
  • Implements a web comparator script that analyzes file sizes and generates a formatted comparison report
  • Refactors SPECULATION_RULES constant to be pre-stringified, improving performance by eliminating redundant JSON.stringify calls per page

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.github/workflows/compare-builds.yml New workflow that orchestrates build comparison by discovering comparators, downloading artifacts from both branches, running comparisons, and posting results to PRs
scripts/compare-builds/web.mjs New comparator script that analyzes web generator output, calculates size differences, and formats results into markdown tables with collapsible sections
.github/workflows/generate.yml Updates artifact naming to remove run ID suffix, enabling consistent artifact names across workflow runs for comparison
src/generators/web/constants.mjs Moves JSON.stringify of SPECULATION_RULES from usage site to definition, improving performance
src/generators/web/utils/processing.mjs Removes redundant JSON.stringify call now that SPECULATION_RULES is pre-stringified

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

avivkeller and others added 2 commits December 11, 2025 20:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@avivkeller avivkeller merged commit 9ddf8f9 into main Dec 13, 2025
19 checks passed
@avivkeller avivkeller deleted the compare-builds branch December 13, 2025 18:41
* @see https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API
*/
export const SPECULATION_RULES = {
export const SPECULATION_RULES = JSON.stringify({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const SPECULATION_RULES = JSON.stringify({
export const SPECULATION_RULES_STRING = JSON.stringify({

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK why you made this unrelated change tho... Any reason why calling JSON.stringify right on definition? Not sure we do that with constants.

Copy link
Member Author

@avivkeller avivkeller Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK why you made this unrelated change tho... Any reason why calling JSON.stringify right on definition? Not sure we do that with constants.

As I mentioned in the comments, I made this change to slightly reduce the build size, showcasing the comparison.

It's on the constant just so that the same stringify isn't called on every page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the comments, I made this change to slightly reduce the build size, showcasing the comparison.

Hmm, how does this reduce build size? Hmmm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also apologies for not notidcing on the comments, I just quickly jumped to the PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants