Skip to content

Commit

Permalink
chore: legacy exports and misc tech debt (#457)
Browse files Browse the repository at this point in the history
* chore: fix legacy exports

* chore: fix legacy exports

* chore: bump lock

* chore: broken tests

* chore: script legacy exports

* chore: tidy up

* chore: tidy up

* chore: bump

* chore: bump
  • Loading branch information
harlan-zw authored Jan 13, 2025
1 parent c234e21 commit 7ae12ce
Show file tree
Hide file tree
Showing 68 changed files with 1,676 additions and 1,419 deletions.
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
},
"devDependencies": {
"@iconify-json/heroicons": "^1.2.2",
"@iconify-json/lucide": "^1.2.21",
"@iconify-json/lucide": "^1.2.22",
"@iconify-json/noto": "^1.2.2",
"@iconify-json/ph": "^1.2.2",
"@iconify-json/simple-icons": "^1.2.18",
"@iconify-json/simple-icons": "^1.2.19",
"@nuxt/content": "^2.13.4",
"@nuxt/devtools": "^1.7.0",
"@nuxt/fonts": "0.10.3",
"@nuxt/image": "^1.8.1",
"@nuxt/image": "^1.9.0",
"@nuxt/scripts": "^0.9.5",
"@nuxt/ui": "2.20.0",
"@nuxt/ui-pro": "1.6.0",
"@nuxtjs/seo": "2.0.2",
"@vueuse/nuxt": "^12.3.0",
"@vueuse/nuxt": "^12.4.0",
"nuxt": "3.15.1",
"nuxt-icon": "0.6.10",
"nuxt-lego": "^0.0.14",
Expand Down
8 changes: 4 additions & 4 deletions examples/vite-ssr-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"debug": "node --inspect-brk server"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^7.0.1"
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^7.1.1"
},
"devDependencies": {
"@vitejs/plugin-react": "latest",
"compression": "^1.7.5",
"express": "^4.21.1",
"express": "^4.21.2",
"serve-static": "^1.16.2"
}
}
12 changes: 6 additions & 6 deletions examples/vite-ssr-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
},
"dependencies": {
"@unhead/dom": "workspace:*",
"unhead": "workspace:*",
"@unhead/schema-org": "workspace:*",
"@unhead/shared": "workspace:*",
"@unhead/vue": "workspace:*",
"pinia": "^2.2.6",
"unplugin-auto-import": "^0.18.5",
"vite": "^5.4.11",
"vue-router": "^4.4.5"
"pinia": "^2.3.0",
"unhead": "workspace:*",
"unplugin-auto-import": "^19.0.0",
"vite": "^6.0.7",
"vue-router": "^4.5.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "latest",
"@vitejs/plugin-vue-jsx": "latest",
"compression": "^1.7.5",
"express": "^4.21.1",
"express": "^4.21.2",
"serve-static": "^1.16.2",
"vue": "^3.5.13"
}
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@
"stub": "pnpm -r --parallel --filter=./packages/** run stub",
"test": "vitest",
"test:memory": "vitest --expose-gc run memory",
"export:sizes": "pnpm -r --parallel --filter=./packages/** run export:sizes",
"bump": "bumpp package.json packages/*/package.json --commit --push --tag",
"release": "pnpm build && pnpm bump && pnpm -r publish --no-git-checks",
"release:beta": "pnpm build && pnpm bump && pnpm -r publish --no-git-checks --tag beta",
"lint": "eslint . --fix",
"benchmark": "vitest bench"
},
"devDependencies": {
"@antfu/eslint-config": "^3.12.1",
"@antfu/eslint-config": "^3.14.0",
"@types/fs-extra": "^11.0.4",
"@types/jsdom": "^21.1.7",
"acorn-loose": "^8.4.0",
"bumpp": "^9.9.2",
"eslint": "^9.17.0",
"bumpp": "^9.10.0",
"eslint": "^9.18.0",
"fs-extra": "^11.2.0",
"jsdom": "^25.0.1",
"jsdom": "^26.0.0",
"typescript": "5.7.2",
"unbuild": "^3.2.0",
"unbuild": "^3.3.0",
"utility-types": "^3.11.0",
"vitest": "^2.1.8",
"vue": "^3.5.13"
Expand Down
37 changes: 0 additions & 37 deletions packages/addons/export-size-report.json

This file was deleted.

7 changes: 3 additions & 4 deletions packages/addons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
],
"scripts": {
"build": "unbuild .",
"stub": "unbuild . --stub",
"export:sizes": "npx export-size . -r"
"stub": "unbuild . --stub"
},
"peerDependencies": {
"unhead": "workspace:*"
Expand All @@ -62,12 +61,12 @@
"@unhead/shared": "workspace:*",
"estree-walker": "^3.0.3",
"magic-string": "^0.30.17",
"mlly": "^1.7.3",
"mlly": "^1.7.4",
"ufo": "^1.5.4",
"unplugin": "^2.1.2",
"unplugin-ast": "^0.13.1"
},
"devDependencies": {
"@babel/types": "^7.26.3"
"@babel/types": "^7.26.5"
}
}
2 changes: 1 addition & 1 deletion packages/addons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './constants'

export { InferSeoMetaPlugin } from 'unhead/optionalPlugins'
export { InferSeoMetaPlugin } from 'unhead/plugins'
11 changes: 9 additions & 2 deletions packages/schema/src/head.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Hookable, NestedHooks } from 'hookable'
import type { HeadHooks } from './hooks'
import type { DomPluginOptions } from './plugins'
import type { Head } from './schema'
import type { HeadTag, ProcessesTemplateParams, ResolvesDuplicates, TagPosition, TagPriority, TemplateParams } from './tags'

Expand Down Expand Up @@ -32,7 +33,7 @@ export interface HeadEntry<Input> {
*
* @internal
*/
transform?: (input: Input) => Promise<Input> | Input
transform?: (input: Input) => Input
/**
* Head entry index
*
Expand Down Expand Up @@ -77,7 +78,6 @@ export interface ActiveHeadEntry<Input> {
}

export interface CreateHeadOptions {
domDelayFn?: (fn: () => void) => void
document?: Document
plugins?: HeadPluginInput[]
hooks?: NestedHooks<HeadHooks>
Expand All @@ -89,6 +89,13 @@ export interface CreateHeadOptions {
disableCapoSorting?: boolean
}

export interface CreateClientHeadOptions extends CreateHeadOptions {
/**
* Options to pass to the DomPlugin.
*/
domOptions?: DomPluginOptions
}

export interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams, ResolvesDuplicates {
mode?: RuntimeMode
transform?: (input: unknown) => unknown
Expand Down
8 changes: 4 additions & 4 deletions packages/schema/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CreateHeadOptions, HeadEntry, Unhead } from './head'
import type { CreateClientHeadOptions, HeadEntry, Unhead } from './head'
import type { HeadTag } from './tags'

export type HookResult = Promise<void> | void
Expand Down Expand Up @@ -38,17 +38,17 @@ export interface HeadHooks {
'init': (ctx: Unhead<any>) => HookResult
'entries:updated': (ctx: Unhead<any>) => HookResult
'entries:resolve': (ctx: EntryResolveCtx<any>) => HookResult
'tag:normalise': (ctx: { tag: HeadTag, entry: HeadEntry<any>, resolvedOptions: CreateHeadOptions }) => HookResult
'tag:normalise': (ctx: { tag: HeadTag, entry: HeadEntry<any>, resolvedOptions: CreateClientHeadOptions }) => HookResult
'tags:beforeResolve': (ctx: { tags: HeadTag[] }) => HookResult
'tags:resolve': (ctx: { tags: HeadTag[] }) => HookResult
'tags:afterResolve': (ctx: { tags: HeadTag[] }) => HookResult

// @unhead/dom
// client
'dom:beforeRender': (ctx: DomBeforeRenderCtx) => HookResult
'dom:renderTag': (ctx: DomRenderTagContext, document: Document, track: any) => HookResult
'dom:rendered': (ctx: { renders: DomRenderTagContext[] }) => HookResult

// @unhead/ssr
// server
'ssr:beforeRender': (ctx: ShouldRenderContext) => HookResult
'ssr:render': (ctx: { tags: HeadTag[] }) => HookResult
'ssr:rendered': (ctx: SSRRenderContext) => HookResult
Expand Down
1 change: 1 addition & 0 deletions packages/schema/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './head'
export * from './hooks'
export * from './plugins'
export * from './safeSchema'
export * from './schema'
export * from './tags'
10 changes: 10 additions & 0 deletions packages/schema/src/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface RenderDomHeadOptions {
/**
* Document to use for rendering. Allows stubbing for testing.
*/
document?: Document
}

export interface DomPluginOptions extends RenderDomHeadOptions {
delayFn?: (fn: () => void) => void
}
20 changes: 1 addition & 19 deletions packages/scripts/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@ export default defineBuildConfig({
entries: [
{ input: 'src/index' },
{ input: 'src/vue/index', name: 'vue' },
{ input: 'src/legacy', name: 'legacy' },
{ input: 'src/vue-legacy', name: 'vue-legacy' },
],
externals: [
'vue',
'@vue/runtime-core',
'unplugin-vue-components',
'unhead',
'@unhead/vue',
'@unhead/schema',
'vite',
'vue-router',
'@unhead/vue',
'@unhead/schema',
'unplugin-ast',
'unplugin',
'unplugin-vue-components',
'vue',
'@vue/runtime-core',
],
externals: ['vue'],
})
1 change: 0 additions & 1 deletion packages/scripts/legacy.d.ts

This file was deleted.

30 changes: 2 additions & 28 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@
"types": "./dist/vue.d.ts",
"import": "./dist/vue.mjs",
"require": "./dist/vue.cjs"
},
"./legacy": {
"types": "./dist/legacy.d.ts",
"import": "./dist/legacy.mjs",
"require": "./dist/legacy.cjs"
},
"./vue-legacy": {
"types": "./dist/vue-legacy.d.ts",
"import": "./dist/vue-legacy.mjs",
"require": "./dist/vue-legacy.cjs"
}
},
"main": "dist/index.cjs",
Expand All @@ -50,18 +40,11 @@
"*": {
"vue": [
"dist/vue"
],
"legacy": [
"dist/legacy"
],
"vue-legacy": [
"dist/vue-legacy"
]
}
},
"files": [
"dist",
"legacy.d.ts",
"overrides.d.ts",
"vue.d.ts"
],
Expand All @@ -73,7 +56,6 @@
"lint": "eslint \"{src,test}/**/*.{ts,vue,json,yml}\" --fix"
},
"peerDependencies": {
"@unhead/shared": "workspace:*",
"@unhead/vue": "workspace:*",
"unhead": "workspace:*"
},
Expand All @@ -82,16 +64,8 @@
"optional": true
}
},
"build": {
"external": [
"vue"
]
},
"devDependencies": {
"dependencies": {
"@unhead/schema": "workspace:*",
"@unhead/shared": "workspace:*",
"@unhead/vue": "workspace:*",
"unhead": "workspace:*",
"unplugin-vue-components": "^0.27.5"
"@unhead/shared": "workspace:*"
}
}
Loading

0 comments on commit 7ae12ce

Please sign in to comment.