Commit e29d435
authored
feat(devtools): vite devtools integration (#731)
* feat: vite devtools integration
Add devtools and devtools-app packages with Vue composables and plugin updates.
* feat: vite devtools integration
Add devtools and devtools-app packages with Vue composables and plugin updates.
* doc: clean up
* doc: clean up
* chore: progress
* chore: progress
* chore: progress
* chore: progress
* fix(validate): false positives for warmup preloads and charset position
- Allow `preload` + `fetchpriority="low"` for `as="script"` (the warmup
pattern used by `useScript` to start fetching at low priority).
- Skip `preload-async-defer-conflict` when the preload uses
`fetchpriority="low"` for the same reason.
- Run `charset-not-early` only on SSR (DOM order is already set after
hydration), and sort by capo weight while filtering virtual tags
(`templateParams`, `titleTemplate`) so they don't inflate the position
count.
- Pass tag references to several `report()` calls so consumers can
surface the offending tag in error messages.
* refactor(bundler): named Unhead export, ctx-based transforms, dev-mode validate
Foundational changes that landed alongside the in-progress devtools work.
Splits the bundler refactor + DX improvements out from the devtools branch
so they can be reviewed and merged independently.
## Bundler
- BREAKING: `default` export → named `Unhead` export on `@unhead/bundler/{vite,webpack}`
and on every framework wrapper (`@unhead/{react,solid-js,svelte,vue}/vite`).
Existing imports must change from `import unhead from ...` to
`import { Unhead } from ...`.
- New `VitePluginOptions` interface (extends `UnpluginOptions`) with a
`validate` flag that injects `ValidatePlugin` in dev so head-tag warnings
surface in the console without manual setup. Internal `_framework` field
lets framework wrappers identify themselves to the runtime.
- New `CreateHeadTransform` + `createHeadTransformContext` foundation: a
single transform handles `createHead()` wrapping and lets other plugins
register runtime plugins via shared context.
- New `SSRStaticReplace` transform: replaces `head.ssr` with a static
boolean per environment so the dead branch tree-shakes cleanly.
- `UseSeoMetaTransform` now preserves the second argument (e.g.
`useSeoMeta(meta, { head })`) when rewriting to `useHead`.
- Tests: `createHeadTransform.test.ts` and updated `useSeoMetaTransform.test.ts`.
## Framework wrappers
- Vue / React / Solid / Svelte vite plugins updated for the named export
and forward `_framework` so the bundler can resolve framework-scoped
runtime plugins (`@unhead/vue/plugins`, etc.).
- `packages-aliased/addons` deprecation shim re-exports the new named export.
## Vue
- Re-exports `useServerHead`, `useServerHeadSafe`, `useServerSeoMeta` as
deprecated aliases for the non-`Server` variants (v2 compat).
- Re-exports `resolveUnrefHeadInput` from `utils` (v2 compat).
## Schema.org
- Exports `schemaAutoImports` from the package root so consumers can wire
it into `unplugin-auto-import` without reaching into subpaths.
## Docs
- Reorganises `1.guides/2.advanced/{vite-plugin,client-only-tags,extending-unhead}`
into a new `1.guides/build-plugins/` section: overview, tree-shaking,
seo-meta-transform, minify-transform.
- Migration guide moves out of `content/` to top-level `6.migration-guide/`.
- Adds `7.api/plugins.md` and updates `use-head` / `use-seo-meta` API pages.
## Examples
- `vite-ssr-vue-prerender`: switches to the named `Unhead` import.
* chore: dedupe pnpm lockfile to fix vite peer-dep duplication
Two [email protected] instances were resolved due to a peer-dep variation on
the bundler package's optional `esbuild` peer, causing TS to see two
incompatible Plugin types in the new bundler transforms. `pnpm update &&
pnpm dedupe` collapses them onto a single resolution and bumps vitest to
4.1.4.
* fix(bundler): scope createHead matching and restore SSR transform
Addresses CodeRabbit review feedback on #733.
- SSRStaticReplace: vite.apply now returns true so the plugin actually
runs during SSR builds (returning false disabled it entirely, so the
head.ssr static replacement never happened)
- CreateHeadTransform: scope createHead callsite matching to symbols
imported from unhead/@unhead modules; supports named, aliased, and
namespace imports; ignores shadowed locals and unrelated packages
- Tests: cover false-positive cases (non-Unhead packages, shadowed
locals) plus aliased and namespace imports
- Docs: rename unhead({...}) -> Unhead({...}) in build-plugins examples,
drop undocumented devtools option from overview, fix head.resolveTags()
to resolveTags(head) in plugins API page
- Migration guide: restore v3 content (was emptied in 66c387c) and add
@unhead/addons -> @unhead/bundler rename + named Unhead export sections
* docs: address coderabbit nits on v3 migration and plugins API
- v3.md: add blank line before ::tip closing marker (markdownlint MD031)
- plugins.md: hyphenate "hooks-based" compound adjective
* fix(ci): unblock test workflow on devtools branch
Four CI fixes needed after merging refactor/bundler-vite-improvements:
- package.json: exclude @unhead/devtools-app from the main build script
(needs nuxi prepare and was racing pnpm topology against @unhead/vue,
blowing up the Build step). Add a separate build:devtools-app script
for use during release.
- bundler/src/devtools/rpc/functions/get-config.ts: annotate getConfigRpc
as `: any` to break a TS2883 portable-inference chain caused by
duplicate @vitejs/devtools-rpc resolutions across two TS peer-dep
variants in the lockfile.
- unhead/src/scripts/useScript.ts: revert the SSR proxy skip so
script.proxy is still a noop recording proxy in SSR. The skip broke
ssr.test.ts/use.test.ts which intentionally exercise proxy access on
a server head.
- test/exports/bundler.yaml: regenerate snapshot to include the new
devtoolsPlugin export from @unhead/bundler.
* chore: untrack packages/devtools-app/.nuxt build artifacts
158 .nuxt files were committed accidentally. .gitignore already covers
.nuxt at the root, so just removing them from the index is enough.
* fix: address coderabbit review on devtools branch
Critical / major fixes:
- bundler/devtools/plugin.ts: escape `<` in inlined JSON payload so a
serialized `</script>` can't close the application/json block early
- DevtoolsSection.vue: remove duplicate `open` prop (already declared
by `defineModel('open')`, was a Vue compile error)
- composables/link-checker.ts: guard `new Image()` and fetch behind
`typeof window === 'undefined'` so SSR/prerender doesn't crash; also
drop the permanent `checkedUrls` set so fixed assets self-heal and
pendingUrls becomes the de-duplication gate
- composables/update-check.ts: skip the npm registry fetch in SSR; only
flip `checked` after a successful response (was permanently disabling
on transient failures)
- bundler/package.json: move `@vitejs/devtools-kit` from devDeps to deps
since `bundler/src/devtools/bridge.ts` is published and imports it at
runtime via `@vitejs/devtools-kit/client`
- DevtoolsTagTable.vue: track `expandedRows` by `tagMatchKey(tag)`
instead of filteredTags index so filtering doesn't reopen the wrong
detail row
- pages/serp.vue: parse every JSON-LD `<script>` tag (collapse multi-tag
pages into a synthetic `@graph`) instead of stopping at the first
- pages/serp.vue: add `type="button"`, `aria-label`, and `aria-pressed`
to the desktop/mobile preview toggles
Minor fixes:
- docs/build-plugins/4.devtools.md: vite-devtools repo URL → vitejs/devtools
- examples vite-ssr-vue/BlogPage.vue: "first class" → "first-class"
- assets/css/global.css: drop duplicate `--scrollbar-thumb` declaration
- DevtoolsEmptyState.vue: render description slot in a `<div>` instead
of nesting block content inside `<p>`
- DevtoolsHeadEntry.vue: fall back to "unknown" when `entry.mode` is empty
- DevtoolsLayout.vue: tighten non-root tab match so `/schema-preview`
doesn't activate the `/schema` tab
- composables/rpc.ts: drop the `as any` cast on sharedState, add
try/catch around the connection setup with a console warning
- composables/shiki.ts: load CSS grammar (DevtoolsSnippet accepts `css`)
- pages/identity.vue: composite icon-card key including rel/sizes/type
so duplicate hrefs across variants don't collide
Tests: 1214 passed; build, vue-tsc, eslint, all green.
* chore: sync
* chore: sync1 parent 183424b commit e29d435
82 files changed
Lines changed: 17879 additions & 6653 deletions
File tree
- docs/head/1.guides/build-plugins
- examples
- vite-ssr-vue-streaming
- vite-ssr-vue
- src
- components
- pages
- packages
- bundler
- src
- devtools
- rpc
- functions
- unplugin
- devtools-app
- app
- assets
- css
- fonts
- components
- composables
- pages
- public
- utils
- unhead
- src
- plugins
- scripts
- stream
- types
- test/streaming
- test/exports
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | | - | |
| 10 | + | |
9 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 2 | + | |
6 | 3 | | |
7 | 4 | | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
9 | 22 | | |
10 | 23 | | |
11 | 24 | | |
12 | 25 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
22 | 37 | | |
23 | 38 | | |
24 | 39 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
29 | 45 | | |
30 | | - | |
31 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
32 | 50 | | |
33 | | - | |
34 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
35 | 56 | | |
36 | 57 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
0 commit comments