Repository navigation
ci: bench infrastructure and combined size + perf PR report - #793
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds Schema.org bundle-size coverage, shared bundle reporting and update tooling, new benchmark entrypoints and build configs, SSR memory benchmarks, and related CI/workflow updates. ChangesBundle tooling, benchmarks, and CI
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Keeps this PR focused on SSR hot-path optimizations and the memory harness. The schema-org bench sources and bundle-size script move to #793, which also carries the matching workflow steps.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
bench/bundle/analyze.ts (1)
106-165: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winDon’t silently hide the new CI rows when the extra base args are missing.
The workflow contract shown in
.github/workflows/bundle-size.yml:59-75still passes only one Schema.org base file, soargs[5]andargs[6]stay undefined here. That makes Lines 148-165 skip both new Schema.org rows entirely in CI, which means the PR comment still won’t report the new bundles.Suggested fix
- const baseSchemaOrg = args[4] && schemaOrg ? fs.readFileSync(args[4]) : null - const baseSchemaOrgImports = args[5] && schemaOrgImports ? fs.readFileSync(args[5]) : null - const baseSchemaOrgVueMeta = args[6] && schemaOrgVueMeta ? fs.readFileSync(args[6]) : null + const baseSchemaOrg = args[4] && schemaOrg ? fs.readFileSync(args[4]) : null + const baseSchemaOrgImports = args[5] && schemaOrgImports ? fs.readFileSync(args[5]) : null + const baseSchemaOrgVueMeta = args[6] && schemaOrgVueMeta ? fs.readFileSync(args[6]) : null ... - ...(schemaOrgImports && baseSchemaOrgImports + ...(schemaOrgImports ? [{ name: 'Schema.org Imports', size: schemaOrgImports.length, gzippedSize: zlib.gzipSync(schemaOrgImports).length, - baseSize: baseSchemaOrgImports.length, - baseGzippedSize: zlib.gzipSync(baseSchemaOrgImports).length, + baseSize: baseSchemaOrgImports?.length ?? 0, + baseGzippedSize: baseSchemaOrgImports ? zlib.gzipSync(baseSchemaOrgImports).length : 0, }] : []), - ...(schemaOrgVueMeta && baseSchemaOrgVueMeta + ...(schemaOrgVueMeta ? [{ name: 'Schema.org Vue Meta', size: schemaOrgVueMeta.length, gzippedSize: zlib.gzipSync(schemaOrgVueMeta).length, - baseSize: baseSchemaOrgVueMeta.length, - baseGzippedSize: zlib.gzipSync(baseSchemaOrgVueMeta).length, + baseSize: baseSchemaOrgVueMeta?.length ?? 0, + baseGzippedSize: baseSchemaOrgVueMeta ? zlib.gzipSync(baseSchemaOrgVueMeta).length : 0, }] : []),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bench/bundle/analyze.ts` around lines 106 - 165, The new Schema.org bundle rows are being skipped when only the first base file is passed, so update the row-building logic in analyze.ts to still emit the Schema.org-related entries even when args[5] and args[6] are missing. Use the existing symbols baseSchemaOrg, baseSchemaOrgImports, baseSchemaOrgVueMeta, schemaOrg, schemaOrgImports, and schemaOrgVueMeta to locate the conditional spread blocks, and change them so CI reports the new rows instead of hiding them when extra baseline inputs are undefined.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/bundle-size.yml:
- Line 57: The workflow step using oven-sh/setup-bun is still pinned to the
mutable v2 tag instead of a full commit SHA. Update the bundle-size workflow to
reference the specific commit hash for setup-bun so the action is fully pinned
and consistent with the repo’s pinning policy.
- Around line 41-46: The bundle-size workflow step is not resilient on the first
PR that introduces schema-org bundle size testing, because after checkout to the
base ref the new test script and build config are missing. Update the workflow
logic around the pnpm test:schema-org-bundle-size invocation and the cp for
bench/bundle/dist/schema-org/schema-org/minimal.mjs so the base-branch run skips
or tolerates missing schema-org artifacts, while still producing the other
baseline files needed by the later analyze step.
---
Outside diff comments:
In `@bench/bundle/analyze.ts`:
- Around line 106-165: The new Schema.org bundle rows are being skipped when
only the first base file is passed, so update the row-building logic in
analyze.ts to still emit the Schema.org-related entries even when args[5] and
args[6] are missing. Use the existing symbols baseSchemaOrg,
baseSchemaOrgImports, baseSchemaOrgVueMeta, schemaOrg, schemaOrgImports, and
schemaOrgVueMeta to locate the conditional spread blocks, and change them so CI
reports the new rows instead of hiding them when extra baseline inputs are
undefined.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bdc8f120-6fca-447a-9696-0d3cc24e4e44
📒 Files selected for processing (9)
.github/workflows/bundle-size.yml.github/workflows/write-bundle-size.ymlbench/bundle/analyze.tsbench/bundle/last.jsonbench/bundle/schema-org-build.config.tsbench/bundle/src/schema-org/imports.tsbench/bundle/src/schema-org/vue-meta.tsbench/bundle/update.tspackage.json
Tracks the schema-org client bundle (minimal, imports, vue-meta) in the bundle-size analyzer and stats writer so the schema-org surface is reported alongside core and Vue. Pairs with the workflow steps already in this PR.
- analyze.ts: always emit the schema-org rows when the PR builds those bundles, falling back to a 0 baseline when the base ref lacks them (read base files defensively instead of throwing on a missing path) - bundle-size.yml: tolerate a base ref that predates the schema-org build config, pass the imports/vue-meta baselines, and pin setup-bun to a commit SHA
53b76c6 to
42f3f79
Compare
|
Addressed the review:
Also rebased onto |
📦 Bundle Size✅ No notable changes · 🆕 8 new bundles tracked All bundles (12)
⚡ Performance (directional)✅ No significant change (within CI noise) All benchmarks (2)
Baseline: main @ 8221da7 · 2026-06-26 · gzipped is the headline size metric · perf is directional (shared-runner, gated) |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/bundle-size.yml:
- Around line 41-50: The bundle-size workflow currently masks real schema-org
baseline failures by using unconditional fallbacks in the base build step.
Update the logic around the `pnpm test:schema-org-bundle-size` and the
subsequent `cp` commands in the bundle-size job so the zero-baseline fallback is
only used when the schema-org bundle config is actually missing, not when the
base branch build or copy step genuinely fails. Keep failures from
`bench/bundle/analyze.ts`-relevant artifact generation fatal for existing
schema-org bundles, and only allow the missing-config case to continue.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5bd8fd22-23d4-4dff-8763-857b46a8d841
📒 Files selected for processing (9)
.github/workflows/bundle-size.yml.github/workflows/write-bundle-size.ymlbench/bundle/analyze.tsbench/bundle/last.jsonbench/bundle/schema-org-build.config.tsbench/bundle/src/schema-org/imports.tsbench/bundle/src/schema-org/vue-meta.tsbench/bundle/update.tspackage.json
✅ Files skipped from review due to trivial changes (1)
- bench/bundle/last.json
🚧 Files skipped from review as they are similar to previous changes (4)
- bench/bundle/src/schema-org/vue-meta.ts
- package.json
- .github/workflows/write-bundle-size.yml
- bench/bundle/src/schema-org/imports.ts
| # base ref may predate the schema-org bundle config; tolerate its absence so the | ||
| # other baselines are still produced and the new rows show as a fresh bundle | ||
| pnpm test:schema-org-bundle-size || true | ||
| cp bench/bundle/dist/client/client/minimal.mjs /tmp/base-client.mjs | ||
| cp bench/bundle/dist/server/server/minimal.mjs /tmp/base-server.mjs | ||
| cp bench/bundle/dist/vue-server/vue-server/minimal.mjs /tmp/base-vue-server.mjs | ||
| cp bench/bundle/dist/vue-client/vue-client/minimal.mjs /tmp/base-vue-client.mjs | ||
| cp bench/bundle/dist/schema-org/schema-org/minimal.mjs /tmp/base-schema-org.mjs || true | ||
| cp bench/bundle/dist/schema-org/schema-org/imports.mjs /tmp/base-schema-org-imports.mjs || true | ||
| cp bench/bundle/dist/schema-org/schema-org/vue-meta.mjs /tmp/base-schema-org-vue-meta.mjs || true |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Don't swallow real base-branch schema-org failures.
This fixes the introductory PR case, but the unconditional || true also hides genuine baseline breakages after this workflow exists on the base branch. In that case bench/bundle/analyze.ts falls back to a zero baseline, so CI reports a “new” schema-org bundle instead of failing on the broken base build. Gate the fallback on the schema-org config actually being absent, and keep real build/copy failures fatal.
Suggested change
- pnpm test:schema-org-bundle-size || true
+ if [ -f bench/bundle/schema-org-build.config.ts ]; then
+ pnpm test:schema-org-bundle-size
+ cp bench/bundle/dist/schema-org/schema-org/minimal.mjs /tmp/base-schema-org.mjs
+ cp bench/bundle/dist/schema-org/schema-org/imports.mjs /tmp/base-schema-org-imports.mjs
+ cp bench/bundle/dist/schema-org/schema-org/vue-meta.mjs /tmp/base-schema-org-vue-meta.mjs
+ fi
cp bench/bundle/dist/client/client/minimal.mjs /tmp/base-client.mjs
cp bench/bundle/dist/server/server/minimal.mjs /tmp/base-server.mjs
cp bench/bundle/dist/vue-server/vue-server/minimal.mjs /tmp/base-vue-server.mjs
cp bench/bundle/dist/vue-client/vue-client/minimal.mjs /tmp/base-vue-client.mjs
- cp bench/bundle/dist/schema-org/schema-org/minimal.mjs /tmp/base-schema-org.mjs || true
- cp bench/bundle/dist/schema-org/schema-org/imports.mjs /tmp/base-schema-org-imports.mjs || true
- cp bench/bundle/dist/schema-org/schema-org/vue-meta.mjs /tmp/base-schema-org-vue-meta.mjs || true📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # base ref may predate the schema-org bundle config; tolerate its absence so the | |
| # other baselines are still produced and the new rows show as a fresh bundle | |
| pnpm test:schema-org-bundle-size || true | |
| cp bench/bundle/dist/client/client/minimal.mjs /tmp/base-client.mjs | |
| cp bench/bundle/dist/server/server/minimal.mjs /tmp/base-server.mjs | |
| cp bench/bundle/dist/vue-server/vue-server/minimal.mjs /tmp/base-vue-server.mjs | |
| cp bench/bundle/dist/vue-client/vue-client/minimal.mjs /tmp/base-vue-client.mjs | |
| cp bench/bundle/dist/schema-org/schema-org/minimal.mjs /tmp/base-schema-org.mjs || true | |
| cp bench/bundle/dist/schema-org/schema-org/imports.mjs /tmp/base-schema-org-imports.mjs || true | |
| cp bench/bundle/dist/schema-org/schema-org/vue-meta.mjs /tmp/base-schema-org-vue-meta.mjs || true | |
| # base ref may predate the schema-org bundle config; tolerate its absence so the | |
| # other baselines are still produced and the new rows show as a fresh bundle | |
| if [ -f bench/bundle/schema-org-build.config.ts ]; then | |
| pnpm test:schema-org-bundle-size | |
| cp bench/bundle/dist/schema-org/schema-org/minimal.mjs /tmp/base-schema-org.mjs | |
| cp bench/bundle/dist/schema-org/schema-org/imports.mjs /tmp/base-schema-org-imports.mjs | |
| cp bench/bundle/dist/schema-org/schema-org/vue-meta.mjs /tmp/base-schema-org-vue-meta.mjs | |
| fi | |
| cp bench/bundle/dist/client/client/minimal.mjs /tmp/base-client.mjs | |
| cp bench/bundle/dist/server/server/minimal.mjs /tmp/base-server.mjs | |
| cp bench/bundle/dist/vue-server/vue-server/minimal.mjs /tmp/base-vue-server.mjs | |
| cp bench/bundle/dist/vue-client/vue-client/minimal.mjs /tmp/base-vue-client.mjs |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/bundle-size.yml around lines 41 - 50, The bundle-size
workflow currently masks real schema-org baseline failures by using
unconditional fallbacks in the base build step. Update the logic around the
`pnpm test:schema-org-bundle-size` and the subsequent `cp` commands in the
bundle-size job so the zero-baseline fallback is only used when the schema-org
bundle config is actually missing, not when the base branch build or copy step
genuinely fails. Keep failures from `bench/bundle/analyze.ts`-relevant artifact
generation fatal for existing schema-org bundles, and only allow the
missing-config case to continue.
- verdict line up top (grew / smaller / no notable changes + new-bundle count) - only changed bundles surface in a top table; full per-category breakdown is collapsed in a <details> - a missing baseline now reads as a 🆕 new bundle instead of a red +X regression - sub-100-byte gz deltas render in bytes so they don't collapse to '0 kB' - footer shows the baseline ref + commit + date for cross-PR context - noise floor (16 B gz) keeps minifier jitter from showing as a change
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
bench/bundle/analyze.ts (2)
242-260: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse the same zero-baseline fallback in local mode.
The local
Schema.org Imports/Vue Metarows are still gated onlast.jsonkeys, so the firstbun bench/bundle/analyze.tsrun after adding those bundles hides them instead of marking themnew.statusOf()already supports a zero baseline, so local mode should default missinglast.schemaOrg*entries to0as well.Suggested fix
-...(schemaOrgImports && last.schemaOrgImports +...(schemaOrgImports ? [{ name: 'Schema.org Imports', size: schemaOrgImports.length, gzippedSize: zlib.gzipSync(schemaOrgImports).length, - baseSize: last.schemaOrgImports.size, - baseGzippedSize: last.schemaOrgImports.gz, + baseSize: last.schemaOrgImports?.size ?? 0, + baseGzippedSize: last.schemaOrgImports?.gz ?? 0, }] : []),Apply the same pattern to
schemaOrgVueMeta.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bench/bundle/analyze.ts` around lines 242 - 260, The local Schema.org bundle rows are incorrectly hidden when the baseline file has no matching entry, instead of showing them as new. Update the logic in analyze.ts where the `Schema.org Imports` row is built (and apply the same pattern to `schemaOrgVueMeta`) so local mode falls back to a zero baseline when `lastStats.schemaOrgImports` or `lastStats.schemaOrgVueMeta` is missing, matching the behavior already supported by `statusOf()`.
123-131: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winFail when a tracked current Schema.org bundle is missing.
These reads make the current PR artifacts optional, so if
test:schema-org-bundle-sizestops emittingimports.mjsorvue-meta.mjs, the CI comment just drops that row instead of surfacing the regression. The base files should stay optional; the current build outputs should not.Suggested fix
+function readCurrent(file: string) { + return fs.readFileSync(path.resolve(__dirname, file)) +} + -const schemaOrg = fs.existsSync(path.resolve(__dirname, 'dist/schema-org/schema-org/minimal.mjs')) - ? fs.readFileSync(path.resolve(__dirname, 'dist/schema-org/schema-org/minimal.mjs')) - : null +const schemaOrg = readCurrent('dist/schema-org/schema-org/minimal.mjs') +const schemaOrgImports = readCurrent('dist/schema-org/schema-org/imports.mjs') +const schemaOrgVueMeta = readCurrent('dist/schema-org/schema-org/vue-meta.mjs')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bench/bundle/analyze.ts` around lines 123 - 131, The current Schema.org bundle reads in analyze.ts are treating PR artifacts as optional, which can hide regressions when tracked outputs disappear. Update the schemaOrgImports and schemaOrgVueMeta handling so the current build outputs are required and the script fails explicitly if those files are missing, while keeping the base bundle reads optional. Use the existing analyze.ts schemaOrg file checks as the location to enforce this behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/bundle-size.yml:
- Around line 65-67: The shell step that builds BASE_LABEL is interpolating
github.base_ref directly inside a quoted echo, which can break if the branch
name contains special characters. Update the workflow step to pass
github.base_ref through env and use printf when writing to GITHUB_ENV, keeping
the existing sha/date logic in the same step.
---
Outside diff comments:
In `@bench/bundle/analyze.ts`:
- Around line 242-260: The local Schema.org bundle rows are incorrectly hidden
when the baseline file has no matching entry, instead of showing them as new.
Update the logic in analyze.ts where the `Schema.org Imports` row is built (and
apply the same pattern to `schemaOrgVueMeta`) so local mode falls back to a zero
baseline when `lastStats.schemaOrgImports` or `lastStats.schemaOrgVueMeta` is
missing, matching the behavior already supported by `statusOf()`.
- Around line 123-131: The current Schema.org bundle reads in analyze.ts are
treating PR artifacts as optional, which can hide regressions when tracked
outputs disappear. Update the schemaOrgImports and schemaOrgVueMeta handling so
the current build outputs are required and the script fails explicitly if those
files are missing, while keeping the base bundle reads optional. Use the
existing analyze.ts schemaOrg file checks as the location to enforce this
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 54acd9bd-e1ec-4046-87e4-672cd38854f4
📒 Files selected for processing (2)
.github/workflows/bundle-size.ymlbench/bundle/analyze.ts
| sha=$(git rev-parse --short "${{ github.event.pull_request.base.sha }}") | ||
| date=$(git show -s --format=%cs "${{ github.event.pull_request.base.sha }}") | ||
| echo "BASE_LABEL=${{ github.base_ref }} @ $sha · $date" >> "$GITHUB_ENV" |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant workflow section with line numbers.
sed -n '55,75p' .github/workflows/bundle-size.yml
# Probe Git refname rules for characters mentioned in the review comment.
python3 - <<'PY'
import subprocess, shlex
candidates = [
"main",
'feature"quote',
"feature'single",
"feature space",
"feature:colon",
"feature[bracket]",
"feature\\backslash",
]
for ref in candidates:
p = subprocess.run(
["git", "check-ref-format", "--branch", ref],
text=True,
capture_output=True,
)
print(f"{ref!r}: rc={p.returncode}")
if p.stdout:
print(" stdout:", p.stdout.strip())
if p.stderr:
print(" stderr:", p.stderr.strip())
PYRepository: unjs/unhead
Length of output: 1578
Avoid interpolating github.base_ref directly in this shell step. A valid branch name can include ", which can break the quoted echo and corrupt the $GITHUB_ENV write. Pass it through env: and use printf instead.
🧰 Tools
🪛 zizmor (1.26.1)
[error] 67-67: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/bundle-size.yml around lines 65 - 67, The shell step that
builds BASE_LABEL is interpolating github.base_ref directly inside a quoted
echo, which can break if the branch name contains special characters. Update the
workflow step to pass github.base_ref through env and use printf when writing to
GITHUB_ENV, keeping the existing sha/date logic in the same step.
Source: Linters/SAST tools
…infra PR Consolidates all benchmark + CI-reporting infrastructure here so the combined size+perf report has its inputs in one place. The memory harness (ssr.mjs, perf.ts, ssr-memory.test.ts), the e2e bench async->sync tweaks, and the test:memory script move out of the src-only perf PR (#794).
Bench + CI-reporting infra (memory harness, e2e bench tweaks, test:memory) moves to the bench infrastructure PR (#793) to avoid a circular dependency between the two.
- bundles.ts: single source of truth (id, name, category, dist path) that analyze.ts and update.ts both iterate; adding a bundle is now one entry - bundle-report.ts: pure collect + render module (no import-time side effects) so the combined report can reuse it; analyze.ts is a thin runner - CI now diffs the PR dist against a full base-branch dist via BASE_DIST instead of per-bundle positional args - add Full profiles (useHead + useSeoMeta + useScript) for core/vue/react as standalone single-entry builds, the only entry that catches useSeoMeta/useScript growth since the minimal floor tree-shakes them away - add React client+server tracking to mirror Vue - regenerate last.json baseline with all 12 bundles
- bundle-size.yml: build core/vue/react/schema-org for base and PR; snapshot the base dist to /tmp/base-dist and pass it via BASE_DIST (replaces per-bundle cp + positional args). Base build tolerates configs the base ref predates. - write-bundle-size.yml: build react bundles before updating last.json; pin setup-bun
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
bench/bundle/react-client-build.config.ts (1)
21-31: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFactor the shared bundle-config boilerplate into a helper.
The
unhead/*alias table and gzip-size reporter are now repeated across multiple bundle configs (bench/bundle/client-build.config.ts:32-45,bench/bundle/client-full-build.config.ts:13-33, and this file). Centralizing them would reduce drift the next time package entrypoints or reporting format change.Also applies to: 48-53
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bench/bundle/react-client-build.config.ts` around lines 21 - 31, The bundle config still repeats the shared `unhead/*` alias entries and gzip-size reporter setup, so move that boilerplate into a common helper and reuse it here and in the other bundle config files. Update the `alias.entries` setup and the reporter wiring in this config to call the shared helper instead of duplicating the `unhead/client`, `unhead/server`, `unhead/plugins`, `unhead/scripts`, `unhead/utils`, and `unhead` mappings and the gzip-size output formatting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/bundle-size.yml:
- Around line 39-48: The bundle-size workflow is swallowing failures for
established baseline jobs, so the snapshot step can proceed after a real
regression and hide missing baseline files. Update the bundle-size step in the
workflow to stop ignoring errors for the existing baselines by removing the
unconditional tolerance from `test:bundle-size` and `test:vue-bundle-size`,
while keeping conditional handling only for jobs that may not exist on the base
ref such as `test:react-bundle-size` and `test:schema-org-bundle-size`.
In `@bench/bundle/bundles.ts`:
- Around line 17-29: The tracked bundle entries in BUNDLES are still optional,
so missing outputs won’t fail the build. Update the BundleSpec definitions for
the tracked artifacts in the BUNDLES array to set required: true, matching the
behavior expected by collectBundleData() and update.ts so CI fails when a
tracked current artifact is not emitted.
In `@bench/bundle/src/react-client/full.ts`:
- Around line 8-31: The App component is returning the provider component itself
instead of rendering the hook usage inside it, so the Unhead hooks run without
provider context. Update App to wrap the existing useHead, useSeoMeta, and
useScript calls within <UnheadProvider> and return its rendered children, using
the App and UnheadProvider symbols to locate the fix.
In `@bench/memory/ssr.mjs`:
- Around line 68-99: The memory benchmark in measure() uses console.table, which
is being flagged by the repo console rule. Either exclude bench/memory/ssr.mjs
from the lint target or add a scoped local no-console disable around the
console.table call, keeping the change near measure() so the benchmark can still
print its results without failing eslint.
In `@bench/ssr-memory.test.ts`:
- Around line 59-65: The SSR memory benchmark test is using console.table
directly, which trips lint and blocks the suite from passing. Remove the
console.table call from the test and, if you still need local diagnostics, move
the output behind a debug-only path or switch it to the project’s approved
logger inside ssr-memory.test.ts.
---
Nitpick comments:
In `@bench/bundle/react-client-build.config.ts`:
- Around line 21-31: The bundle config still repeats the shared `unhead/*` alias
entries and gzip-size reporter setup, so move that boilerplate into a common
helper and reuse it here and in the other bundle config files. Update the
`alias.entries` setup and the reporter wiring in this config to call the shared
helper instead of duplicating the `unhead/client`, `unhead/server`,
`unhead/plugins`, `unhead/scripts`, `unhead/utils`, and `unhead` mappings and
the gzip-size output formatting.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ab32c795-a341-4b07-a846-4f2eaf4e533c
📒 Files selected for processing (27)
.github/workflows/bundle-size.yml.github/workflows/write-bundle-size.ymlbench/bundle/analyze.tsbench/bundle/bundle-report.tsbench/bundle/bundles.tsbench/bundle/client-build.config.tsbench/bundle/client-full-build.config.tsbench/bundle/last.jsonbench/bundle/react-client-build.config.tsbench/bundle/react-client-full-build.config.tsbench/bundle/react-server-build.config.tsbench/bundle/src/client/full.tsbench/bundle/src/react-client/full.tsbench/bundle/src/react-client/minimal.tsbench/bundle/src/react-server/minimal.tsbench/bundle/src/schema-org/vue-meta.tsbench/bundle/src/vue-client/full.tsbench/bundle/update.tsbench/bundle/vue-client-build.config.tsbench/bundle/vue-client-full-build.config.tsbench/memory/ssr.mjsbench/ssr-harlanzw-com-e2e.bench.tsbench/ssr-harlanzw-no-schema-e2e.bench.tsbench/ssr-memory.test.tsbench/utils/perf.tspackage.jsonpackages/vue/test/bench/ssr-harlanzw-no-schema-e2e.bench.ts
💤 Files with no reviewable changes (2)
- bench/bundle/client-build.config.ts
- bench/bundle/vue-client-build.config.ts
✅ Files skipped from review due to trivial changes (1)
- bench/bundle/last.json
🚧 Files skipped from review as they are similar to previous changes (2)
- bench/bundle/src/schema-org/vue-meta.ts
- package.json
| # the base ref may predate some bundle configs (react, full, schema-org); | ||
| # tolerate their absence so the other baselines are still produced and the | ||
| # new bundles surface as fresh rather than failing the run | ||
| pnpm test:bundle-size || true | ||
| pnpm test:vue-bundle-size || true | ||
| pnpm test:react-bundle-size || true | ||
| pnpm test:schema-org-bundle-size || true | ||
| # snapshot the whole base dist; analyze.ts diffs PR dist against it by path | ||
| rm -rf /tmp/base-dist | ||
| cp -r bench/bundle/dist /tmp/base-dist |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Don't ignore failures for the established baseline jobs.
test:bundle-size and test:vue-bundle-size are existing baselines. With || true, this step still snapshots bench/bundle/dist into /tmp/base-dist after a real failure, and the analyzer then treats missing files as zero baselines instead of failing the regression check. Only jobs that may not exist on the base ref should be conditional.
Suggested change
- pnpm test:bundle-size || true
- pnpm test:vue-bundle-size || true
- pnpm test:react-bundle-size || true
- pnpm test:schema-org-bundle-size || true
+ pnpm test:bundle-size
+ pnpm test:vue-bundle-size
+ if [ -f bench/bundle/react-client-build.config.ts ]; then
+ pnpm test:react-bundle-size
+ fi
+ if [ -f bench/bundle/schema-org-build.config.ts ]; then
+ pnpm test:schema-org-bundle-size
+ fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # the base ref may predate some bundle configs (react, full, schema-org); | |
| # tolerate their absence so the other baselines are still produced and the | |
| # new bundles surface as fresh rather than failing the run | |
| pnpm test:bundle-size || true | |
| pnpm test:vue-bundle-size || true | |
| pnpm test:react-bundle-size || true | |
| pnpm test:schema-org-bundle-size || true | |
| # snapshot the whole base dist; analyze.ts diffs PR dist against it by path | |
| rm -rf /tmp/base-dist | |
| cp -r bench/bundle/dist /tmp/base-dist | |
| # the base ref may predate some bundle configs (react, full, schema-org); | |
| # tolerate their absence so the other baselines are still produced and the | |
| # new bundles surface as fresh rather than failing the run | |
| pnpm test:bundle-size | |
| pnpm test:vue-bundle-size | |
| if [ -f bench/bundle/react-client-build.config.ts ]; then | |
| pnpm test:react-bundle-size | |
| fi | |
| if [ -f bench/bundle/schema-org-build.config.ts ]; then | |
| pnpm test:schema-org-bundle-size | |
| fi | |
| # snapshot the whole base dist; analyze.ts diffs PR dist against it by path | |
| rm -rf /tmp/base-dist | |
| cp -r bench/bundle/dist /tmp/base-dist |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/bundle-size.yml around lines 39 - 48, The bundle-size
workflow is swallowing failures for established baseline jobs, so the snapshot
step can proceed after a real regression and hide missing baseline files. Update
the bundle-size step in the workflow to stop ignoring errors for the existing
baselines by removing the unconditional tolerance from `test:bundle-size` and
`test:vue-bundle-size`, while keeping conditional handling only for jobs that
may not exist on the base ref such as `test:react-bundle-size` and
`test:schema-org-bundle-size`.
| export const BUNDLES: BundleSpec[] = [ | ||
| { id: 'client', name: 'Client (Minimal)', category: 'Core', file: 'client/client/minimal.mjs', required: true }, | ||
| { id: 'clientFull', name: 'Client (Full)', category: 'Core', file: 'client-full/client/full.mjs' }, | ||
| { id: 'server', name: 'Server (Minimal)', category: 'Core', file: 'server/server/minimal.mjs', required: true }, | ||
| { id: 'vueClient', name: 'Vue Client (Minimal)', category: 'Vue', file: 'vue-client/vue-client/minimal.mjs', required: true }, | ||
| { id: 'vueClientFull', name: 'Vue Client (Full)', category: 'Vue', file: 'vue-client-full/vue-client/full.mjs' }, | ||
| { id: 'vueServer', name: 'Vue Server (Minimal)', category: 'Vue', file: 'vue-server/vue-server/minimal.mjs', required: true }, | ||
| { id: 'reactClient', name: 'React Client (Minimal)', category: 'React', file: 'react-client/react-client/minimal.mjs' }, | ||
| { id: 'reactClientFull', name: 'React Client (Full)', category: 'React', file: 'react-client-full/react-client/full.mjs' }, | ||
| { id: 'reactServer', name: 'React Server (Minimal)', category: 'React', file: 'react-server/react-server/minimal.mjs' }, | ||
| { id: 'schemaOrg', name: 'Schema.org (Minimal)', category: 'Schema.org', file: 'schema-org/schema-org/minimal.mjs' }, | ||
| { id: 'schemaOrgImports', name: 'Schema.org Imports', category: 'Schema.org', file: 'schema-org/schema-org/imports.mjs' }, | ||
| { id: 'schemaOrgVueMeta', name: 'Schema.org Vue Meta', category: 'Schema.org', file: 'schema-org/schema-org/vue-meta.mjs' }, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Mark the tracked outputs as required.
collectBundleData() and update.ts only fail on a missing current artifact when required is set. With these entries left optional, a PR build can stop emitting a tracked bundle and CI will just drop that row/key instead of failing, which defeats the new tracking this PR adds.
Suggested change
export const BUNDLES: BundleSpec[] = [
{ id: 'client', name: 'Client (Minimal)', category: 'Core', file: 'client/client/minimal.mjs', required: true },
- { id: 'clientFull', name: 'Client (Full)', category: 'Core', file: 'client-full/client/full.mjs' },
+ { id: 'clientFull', name: 'Client (Full)', category: 'Core', file: 'client-full/client/full.mjs', required: true },
{ id: 'server', name: 'Server (Minimal)', category: 'Core', file: 'server/server/minimal.mjs', required: true },
{ id: 'vueClient', name: 'Vue Client (Minimal)', category: 'Vue', file: 'vue-client/vue-client/minimal.mjs', required: true },
- { id: 'vueClientFull', name: 'Vue Client (Full)', category: 'Vue', file: 'vue-client-full/vue-client/full.mjs' },
+ { id: 'vueClientFull', name: 'Vue Client (Full)', category: 'Vue', file: 'vue-client-full/vue-client/full.mjs', required: true },
{ id: 'vueServer', name: 'Vue Server (Minimal)', category: 'Vue', file: 'vue-server/vue-server/minimal.mjs', required: true },
- { id: 'reactClient', name: 'React Client (Minimal)', category: 'React', file: 'react-client/react-client/minimal.mjs' },
- { id: 'reactClientFull', name: 'React Client (Full)', category: 'React', file: 'react-client-full/react-client/full.mjs' },
- { id: 'reactServer', name: 'React Server (Minimal)', category: 'React', file: 'react-server/react-server/minimal.mjs' },
- { id: 'schemaOrg', name: 'Schema.org (Minimal)', category: 'Schema.org', file: 'schema-org/schema-org/minimal.mjs' },
- { id: 'schemaOrgImports', name: 'Schema.org Imports', category: 'Schema.org', file: 'schema-org/schema-org/imports.mjs' },
- { id: 'schemaOrgVueMeta', name: 'Schema.org Vue Meta', category: 'Schema.org', file: 'schema-org/schema-org/vue-meta.mjs' },
+ { id: 'reactClient', name: 'React Client (Minimal)', category: 'React', file: 'react-client/react-client/minimal.mjs', required: true },
+ { id: 'reactClientFull', name: 'React Client (Full)', category: 'React', file: 'react-client-full/react-client/full.mjs', required: true },
+ { id: 'reactServer', name: 'React Server (Minimal)', category: 'React', file: 'react-server/react-server/minimal.mjs', required: true },
+ { id: 'schemaOrg', name: 'Schema.org (Minimal)', category: 'Schema.org', file: 'schema-org/schema-org/minimal.mjs', required: true },
+ { id: 'schemaOrgImports', name: 'Schema.org Imports', category: 'Schema.org', file: 'schema-org/schema-org/imports.mjs', required: true },
+ { id: 'schemaOrgVueMeta', name: 'Schema.org Vue Meta', category: 'Schema.org', file: 'schema-org/schema-org/vue-meta.mjs', required: true },
]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export const BUNDLES: BundleSpec[] = [ | |
| { id: 'client', name: 'Client (Minimal)', category: 'Core', file: 'client/client/minimal.mjs', required: true }, | |
| { id: 'clientFull', name: 'Client (Full)', category: 'Core', file: 'client-full/client/full.mjs' }, | |
| { id: 'server', name: 'Server (Minimal)', category: 'Core', file: 'server/server/minimal.mjs', required: true }, | |
| { id: 'vueClient', name: 'Vue Client (Minimal)', category: 'Vue', file: 'vue-client/vue-client/minimal.mjs', required: true }, | |
| { id: 'vueClientFull', name: 'Vue Client (Full)', category: 'Vue', file: 'vue-client-full/vue-client/full.mjs' }, | |
| { id: 'vueServer', name: 'Vue Server (Minimal)', category: 'Vue', file: 'vue-server/vue-server/minimal.mjs', required: true }, | |
| { id: 'reactClient', name: 'React Client (Minimal)', category: 'React', file: 'react-client/react-client/minimal.mjs' }, | |
| { id: 'reactClientFull', name: 'React Client (Full)', category: 'React', file: 'react-client-full/react-client/full.mjs' }, | |
| { id: 'reactServer', name: 'React Server (Minimal)', category: 'React', file: 'react-server/react-server/minimal.mjs' }, | |
| { id: 'schemaOrg', name: 'Schema.org (Minimal)', category: 'Schema.org', file: 'schema-org/schema-org/minimal.mjs' }, | |
| { id: 'schemaOrgImports', name: 'Schema.org Imports', category: 'Schema.org', file: 'schema-org/schema-org/imports.mjs' }, | |
| { id: 'schemaOrgVueMeta', name: 'Schema.org Vue Meta', category: 'Schema.org', file: 'schema-org/schema-org/vue-meta.mjs' }, | |
| export const BUNDLES: BundleSpec[] = [ | |
| { id: 'client', name: 'Client (Minimal)', category: 'Core', file: 'client/client/minimal.mjs', required: true }, | |
| { id: 'clientFull', name: 'Client (Full)', category: 'Core', file: 'client-full/client/full.mjs', required: true }, | |
| { id: 'server', name: 'Server (Minimal)', category: 'Core', file: 'server/server/minimal.mjs', required: true }, | |
| { id: 'vueClient', name: 'Vue Client (Minimal)', category: 'Vue', file: 'vue-client/vue-client/minimal.mjs', required: true }, | |
| { id: 'vueClientFull', name: 'Vue Client (Full)', category: 'Vue', file: 'vue-client-full/vue-client/full.mjs', required: true }, | |
| { id: 'vueServer', name: 'Vue Server (Minimal)', category: 'Vue', file: 'vue-server/vue-server/minimal.mjs', required: true }, | |
| { id: 'reactClient', name: 'React Client (Minimal)', category: 'React', file: 'react-client/react-client/minimal.mjs', required: true }, | |
| { id: 'reactClientFull', name: 'React Client (Full)', category: 'React', file: 'react-client-full/react-client/full.mjs', required: true }, | |
| { id: 'reactServer', name: 'React Server (Minimal)', category: 'React', file: 'react-server/react-server/minimal.mjs', required: true }, | |
| { id: 'schemaOrg', name: 'Schema.org (Minimal)', category: 'Schema.org', file: 'schema-org/schema-org/minimal.mjs', required: true }, | |
| { id: 'schemaOrgImports', name: 'Schema.org Imports', category: 'Schema.org', file: 'schema-org/schema-org/imports.mjs', required: true }, | |
| { id: 'schemaOrgVueMeta', name: 'Schema.org Vue Meta', category: 'Schema.org', file: 'schema-org/schema-org/vue-meta.mjs', required: true }, | |
| ] |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bench/bundle/bundles.ts` around lines 17 - 29, The tracked bundle entries in
BUNDLES are still optional, so missing outputs won’t fail the build. Update the
BundleSpec definitions for the tracked artifacts in the BUNDLES array to set
required: true, matching the behavior expected by collectBundleData() and
update.ts so CI fails when a tracked current artifact is not emitted.
| export function App() { | ||
| useHead({ | ||
| title: 'Test', | ||
| titleTemplate: '%s | Site', | ||
| meta: [ | ||
| { name: 'description', content: 'Test' }, | ||
| ], | ||
| link: [ | ||
| { rel: 'icon', href: '/favicon.ico' }, | ||
| ], | ||
| }) | ||
|
|
||
| useSeoMeta({ | ||
| title: 'Test', | ||
| description: 'Test description', | ||
| ogTitle: 'Test', | ||
| ogDescription: 'Test description', | ||
| ogImage: '/og.png', | ||
| twitterCard: 'summary_large_image', | ||
| }) | ||
|
|
||
| useScript({ src: '/analytics.js' }) | ||
|
|
||
| return UnheadProvider |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
fd -i 'client.*' packages/react
rg -n -C3 'UnheadProvider|useHead|useSeoMeta|useScript' packages/react
ast-grep outline packages/react --match UnheadProvider --view expandedRepository: unjs/unhead
Length of output: 50367
Wrap the hook usage in <UnheadProvider>. return UnheadProvider returns the component function, so these hooks run without provider context and useScript will throw if this fixture is rendered.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bench/bundle/src/react-client/full.ts` around lines 8 - 31, The App component
is returning the provider component itself instead of rendering the hook usage
inside it, so the Unhead hooks run without provider context. Update App to wrap
the existing useHead, useSeoMeta, and useScript calls within <UnheadProvider>
and return its rendered children, using the App and UnheadProvider symbols to
locate the fix.
| console.table([{ | ||
| name: result.name, | ||
| runs: result.runs, | ||
| durationMs: Math.round(result.durationMs * 100) / 100, | ||
| heapUsedDelta: formatBytes(result.delta.heapUsed), | ||
| rssDelta: formatBytes(result.delta.rss), | ||
| }]) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Drop console.table from the test.
Line 59 is already failing lint, so this suite cannot merge green in its current form. If you want local diagnostics, gate them behind a debug path or use an allowed logger.
🧰 Tools
🪛 GitHub Check: lint
[failure] 59-59:
Unexpected console statement. Only these console methods are allowed: warn, error
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bench/ssr-memory.test.ts` around lines 59 - 65, The SSR memory benchmark test
is using console.table directly, which trips lint and blocks the suite from
passing. Remove the console.table call from the test and, if you still need
local diagnostics, move the output behind a debug-only path or switch it to the
project’s approved logger inside ssr-memory.test.ts.
Source: Linters/SAST tools
- ignore bench/**/*.mjs (standalone --expose-gc harnesses that import built dist, use process/console and top-level await by design) - perf.ts: import process from node:process - ssr-memory.test.ts: allow the informational console.table
…ment - perf-ci.mjs: standalone --expose-gc harness; prints JSON for SSR render wall-time (mean ms + 95% RME over sampled batches) and retained heap over a fixed run - perf-report.ts: only surfaces a change past the gate (time |Δ| > max(10%, 2×RME); memory |Δ| > 512 KiB, since retained heap hovers near zero), framed as directional - report.ts: one combined comment (size + perf), replacing analyze.ts as the CI comment generator (analyze.ts stays for local bundle-only runs) - bundle-size.yml: run the harness on base and PR (same runner) and feed both JSONs to report.ts via BASE_PERF / PR_PERF
❓ Type of change
📚 Description
Bench infrastructure and CI reporting: a single PR comment that tracks bundle size and performance for every PR, so size and perf regressions are caught the same way across core, Vue, React and Schema.org.
Self-contained (sources + workflows). Because GitHub does not run
pull_requestCI on a branch that edits workflow files, this PR intentionally carries the workflow changes; its own bundle-size run is degraded for that reason, which is expected.Bundle tracking
bench/bundle/bundles.ts): one list of{ id, name, category, dist path }that the analyzer and thelast.jsonwriter both iterate, so adding a bundle is one entry.useHeadfloor) and, where it matters, a Full profile (useHead+useSeoMeta+useScript). Full is the only profile that catches growth inuseSeoMeta/useScript/ plugins, since those tree-shake out of auseHead-only entry. Plus the Schema.org client surfaces.distagainst a snapshot of the base-branchdist(BASE_DIST) instead of per-bundle file copies.Combined PR comment
<details>.🆕 new, never a red regression. Sub-100-byte gz deltas render in bytes so they don't collapse to0 kB.last.jsononmainstays the longitudinal record.Performance (directional)
bench/perf-ci.mjsruns on the base and PR builds on the same runner (variance cancels) and prints JSON: SSR render wall-time (mean ms + 95% margin of error) and retained heap.|Δ| > max(10%, 2×RME); memory|Δ| > 512 KiB. Otherwise it reads "no significant change". Informational and non-blocking, never a required check.bench/memory/ssr.mjs) and the SSR e2e bench tweaks live here too, consolidating all bench + CI-reporting infra in one place (this is why perf: optimize SSR hot paths #794 is now purelysrc/changes; the two no longer depend on each other).