Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(vue): expose @unhead/vue/stream/iife with correct types#707

Merged
harlan-zw merged 1 commit into
mainfrom
fix/expose-vue-stream-iife-types
Mar 27, 2026
Merged

fix(vue): expose @unhead/vue/stream/iife with correct types#707
harlan-zw merged 1 commit into
mainfrom
fix/expose-vue-stream-iife-types

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

πŸ”— Linked issue

N/A (internal TODO)

❓ Type of change

  • πŸ“– Documentation
  • 🐞 Bug fix
  • πŸ‘Œ Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

πŸ“š Description

The unhead build hook overwrites dist/stream/iife.mjs post-build to export streamingIifeCode (string) and streamingIifeSize (number), but the generated .d.ts still declared the source-level init export. This forced consumers to use as unknown as casts.

Now the build hook writes correct .d.ts files alongside the overwritten .mjs, the tsconfig path points to an ambient declaration matching the post-build API, and @unhead/vue exposes ./stream/iife as a subpath re-export.

Summary by CodeRabbit

  • New Features
    • Streaming IIFE resources are now publicly available. The ./stream/iife subpath export provides access to streamingIifeCode (bundled code for HTML inlining) and streamingIifeSize (byte-length metadata) with complete TypeScript type declarations, enabling enhanced streaming support with improved type safety and integration capabilities.

…reamingIifeCode`

The `unhead` build hook overwrites `dist/stream/iife.mjs` post-build to export
`streamingIifeCode` (string) and `streamingIifeSize` (number), but the generated
`.d.ts` still declared the source-level `init` export. This caused consumers to
need `as unknown as` casts when importing.

Now the build hook writes correct `.d.ts` files alongside the overwritten `.mjs`,
and `@unhead/vue` re-exports the subpath so Vue users can import from
`@unhead/vue/stream/iife`.
@coderabbitai

coderabbitai Bot commented Mar 27, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: acd79956-584e-4535-b53a-95d2a0646f70

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between e413c5c and cf6d611.

πŸ“’ Files selected for processing (9)
  • packages/unhead/build.config.ts
  • packages/unhead/src/stream/iife-code.d.ts
  • packages/unhead/src/stream/vite.ts
  • packages/vue/build.config.ts
  • packages/vue/package.json
  • packages/vue/src/stream/iife.ts
  • packages/vue/test/client-hydration.test.ts
  • test/exports/vue.yaml
  • tsconfig.json

πŸ“ Walkthrough

Walkthrough

This PR introduces public API exports for streaming IIFE code assets across the unhead and Vue packages, adding TypeScript declarations, build configurations, and package.json exports for streamingIifeCode and streamingIifeSize constants.

Changes

Cohort / File(s) Summary
Build & Declaration Generation
packages/unhead/build.config.ts, packages/unhead/src/stream/iife-code.d.ts
Added post-build TypeScript declaration file generation for streaming IIFE exports and created source declaration file for streamingIifeCode and streamingIifeSize.
Vue Stream Module Exports
packages/vue/build.config.ts, packages/vue/src/stream/iife.ts, packages/vue/package.json
Added new build entry and package export for stream/iife subpath, re-exporting streaming constants from unhead with TypeScript typesVersions mapping.
Type Resolution & Import Updates
tsconfig.json, packages/unhead/src/stream/vite.ts, packages/vue/test/client-hydration.test.ts
Updated TypeScript path alias for unhead/stream/iife resolution, simplified dynamic import type-casting, and adjusted test import path for consistency.
Export Validation
test/exports/vue.yaml
Added validation entry for new ./stream/iife export with streamingIifeCode and streamingIifeSize fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A streaming path now clearer made,
With types declared and exports laid,
IIFE code bundled, sizes known,
Through Vue and unhead, it's shown!
Configuration hops with perfect care, ✨

πŸš₯ Pre-merge checks | βœ… 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (2 passed)
Check name Status Explanation
Title check βœ… Passed The title accurately summarizes the main change: exposing the Vue stream/iife export with correct TypeScript types to resolve the type mismatch issue.
Description check βœ… Passed The description covers the bug being fixed, root cause, and the solution. It follows the template with linked issue, type of change marked, and detailed explanation of the problem and fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/expose-vue-stream-iife-types

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Bundle Size Gzipped
Client (Minimal) 10.5 kB 4.3 kB
Server (Minimal) 10.2 kB 4.2 kB
Vue Client (Minimal) 11.4 kB 4.7 kB
Vue Server (Minimal) 11.1 kB 4.6 kB

@harlan-zw harlan-zw merged commit a8f1a17 into main Mar 27, 2026
6 checks passed
@harlan-zw harlan-zw mentioned this pull request Apr 4, 2026
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.

1 participant