fix: reduce minimal bundle size#817
Conversation
📦 Bundle Size🟢 8 smaller · net -0.3 kB gz
All bundles (12)
⚡ Performance (directional)
All benchmarks (9)
Baseline: main @ 0cdf322 · 2026-06-30 · gzipped is the headline size metric · perf is directional (shared-runner, gated) |
📝 WalkthroughWalkthroughRefactors unhead's client DOM export surface, DOM renderer internals, script lifecycle handling, plugin purity annotations, and server-side tag weighting/prop stringification. Separately relocates Vue's injectHead into install.ts and updates Vue render scheduling. ChangesUnhead Core Refactors
Vue injectHead Relocation and Debounce Fix
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
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 |
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 `@packages/unhead/src/scripts/useScript.ts`:
- Around line 27-28: The script registry lookup in useScript is vulnerable
because head._scripts is a normal object and id is user-controlled, so keys like
constructor or __proto__ can hit inherited properties or affect the prototype.
Update the script-id registry used by useScript and any related
initialization/access in head._scripts to use a null-prototype structure, and
keep the bracket lookup against that safe registry so ids only resolve to own
entries.
🪄 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: 89cc2fa9-6117-4e7e-a99c-552bbe3e3d87
📒 Files selected for processing (11)
packages/unhead/src/client/index.tspackages/unhead/src/client/renderDOMHead.tspackages/unhead/src/plugins/aliasSorting.tspackages/unhead/src/plugins/safe.tspackages/unhead/src/scripts/useScript.tspackages/unhead/src/server/sort.tspackages/unhead/src/server/util/propsToString.tspackages/vue/src/client.tspackages/vue/src/composables.tspackages/vue/src/install.tspackages/vue/src/scripts/useScript.ts
Linked issue
No linked issue.
Type of change
Description
Reduces the core and Vue bundle benchmarks with small runtime rewrites that preserve the existing public API surface. The Vue server benchmark stays on the existing import shape:
useHeadfrom@unhead/vueand SSR utilities from@unhead/vue/server.Bundle size report from CI, baseline
main @ 0cdf3224:Verification
pnpm lintpnpm typecheckpnpm buildpnpm test:bundle-size && pnpm test:vue-bundle-sizepnpm vitest run