feat: @unhead/vue v2

This commit is contained in:
harlan 2025-01-14 20:03:48 +11:00
parent 218d8f1e6c
commit 99d36f1be7
12 changed files with 143 additions and 118 deletions

View File

@ -111,7 +111,8 @@ export default defineNuxtModule({
```
```ts [plugin.ts]
import { createHead as createClientHead, createServerHead } from '@unhead/vue'
import { createHead as createServerHead } from '@unhead/vue/server'
import { createHead as createClientHead } from '@unhead/vue/client'
import { defineNuxtPlugin } from '#imports'
// @ts-ignore
import metaConfig from '#build/meta.config.mjs'

View File

@ -40,11 +40,9 @@
"@nuxt/vite-builder": "workspace:*",
"@nuxt/webpack-builder": "workspace:*",
"@types/node": "22.10.5",
"@unhead/dom": "1.11.15",
"@unhead/schema": "1.11.15",
"@unhead/shared": "1.11.15",
"@unhead/ssr": "1.11.15",
"@unhead/vue": "1.11.15",
"@unhead/schema": "2.0.0-alpha.2",
"@unhead/vue": "2.0.0-alpha.2",
"@unhead/shared": "2.0.0-alpha.2",
"@vue/compiler-core": "3.5.13",
"@vue/compiler-dom": "3.5.13",
"@vue/shared": "3.5.13",
@ -61,7 +59,7 @@
"typescript": "5.7.3",
"ufo": "1.5.4",
"unbuild": "3.2.0",
"unhead": "1.11.15",
"unhead": "2.0.0-alpha.2",
"unimport": "3.14.5",
"vite": "6.0.7",
"vue": "3.5.13"
@ -77,8 +75,8 @@
"@testing-library/vue": "8.1.0",
"@types/node": "22.10.5",
"@types/semver": "7.5.8",
"@unhead/schema": "1.11.15",
"@unhead/vue": "1.11.15",
"@unhead/schema": "2.0.0-alpha.2",
"@unhead/vue": "2.0.0-alpha.2",
"@vitest/coverage-v8": "2.1.8",
"@vue/test-utils": "2.4.6",
"autoprefixer": "10.4.20",

View File

@ -71,10 +71,7 @@
"@nuxt/schema": "workspace:*",
"@nuxt/telemetry": "^2.6.4",
"@nuxt/vite-builder": "workspace:*",
"@unhead/dom": "^1.11.15",
"@unhead/shared": "^1.11.15",
"@unhead/ssr": "^1.11.15",
"@unhead/vue": "^1.11.15",
"@unhead/vue": "^2.0.0-alpha.2",
"@vue/shared": "^3.5.13",
"acorn": "8.14.0",
"c12": "^2.0.1",
@ -118,7 +115,6 @@
"uncrypto": "^0.1.3",
"unctx": "^2.4.1",
"unenv": "^1.10.0",
"unhead": "^1.11.15",
"unimport": "^3.14.5",
"unplugin": "^2.1.2",
"unplugin-vue-router": "^0.10.9",

View File

@ -16,16 +16,16 @@ import { stringify, uneval } from 'devalue'
import destr from 'destr'
import { getQuery as getURLQuery, joinURL, withoutTrailingSlash } from 'ufo'
import { renderToString as _renderToString } from 'vue/server-renderer'
import { propsToString, renderSSRHead } from '@unhead/ssr'
import { createHead as createServerHead, propsToString, renderSSRHead } from '@unhead/vue/server'
import type { Head, HeadEntryOptions } from '@unhead/schema'
import type { Link, Script, Style } from '@unhead/vue'
import { createServerHead, resolveUnrefHeadInput } from '@unhead/vue'
import { resolveUnrefHeadInput } from '@unhead/vue'
import { defineRenderHandler, getRouteRules, useNitroApp, useRuntimeConfig, useStorage } from 'nitro/runtime'
import type { NuxtPayload, NuxtSSRContext } from 'nuxt/app'
// @ts-expect-error virtual file
import unheadPlugins from '#internal/unhead-plugins.mjs'
import unheadOptions from '#internal/unhead-options.mjs'
// @ts-expect-error virtual file
import { renderSSRHeadOptions } from '#internal/unhead.config.mjs'
@ -289,9 +289,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
// Get route options (currently to apply `ssr: false`)
const routeOptions = getRouteRules(event)
const head = createServerHead({
plugins: unheadPlugins,
})
const head = createServerHead(unheadOptions)
// needed for hash hydration plugin to work
const headEntryOptions: HeadEntryOptions = { mode: 'server' }

View File

@ -12,6 +12,7 @@ export default defineNuxtModule<NuxtOptions['unhead']>({
},
async setup (options, nuxt) {
const runtimeDir = resolve(distDir, 'head/runtime')
const isNuxtV4 = nuxt.options.future?.compatibilityVersion === 4
// Transpile @unhead/vue
nuxt.options.build.transpile.push('@unhead/vue')
@ -38,7 +39,7 @@ export default defineNuxtModule<NuxtOptions['unhead']>({
}
addImportsSources({
from: '@unhead/vue',
from: resolve(runtimeDir, 'composables', isNuxtV4 ? 'v4' : 'v3'),
// hard-coded for now we so don't support auto-imports on the deprecated composables
imports: [
'injectHead',
@ -51,17 +52,21 @@ export default defineNuxtModule<NuxtOptions['unhead']>({
],
})
// Opt-out feature allowing dependencies using @vueuse/head to work
const unheadVue = await tryResolveModule('@unhead/vue', nuxt.options.modulesDir) || '@unhead/vue'
const unheadVue = await tryResolveModule('unhead/plugins', nuxt.options.modulesDir) || 'unhead/plugins'
addTemplate({
filename: 'unhead-plugins.mjs',
filename: 'unhead-options.mjs',
getContents () {
if (!nuxt.options.experimental.headNext) {
return 'export default []'
if (isNuxtV4) {
return `export default {}`
}
return `import { CapoPlugin } from ${JSON.stringify(unheadVue)};
export default import.meta.server ? [CapoPlugin({ track: true })] : [];`
// v1 unhead legacy options
const disableCapoSorting = !nuxt.options.experimental.headNext
return `import { DeprecationsPlugin, PromisesPlugin } from ${JSON.stringify(unheadVue)};
export default {
disableCapoSorting: ${disableCapoSorting}
plugins: [DeprecationsPlugin, PromisesPlugin],
}`
},
})
@ -76,7 +81,7 @@ export default import.meta.server ? [CapoPlugin({ track: true })] : [];`
// template is only exposed in nuxt context, expose in nitro context as well
nuxt.hooks.hook('nitro:config', (config) => {
config.virtual!['#internal/unhead-plugins.mjs'] = () => nuxt.vfs['#build/unhead-plugins.mjs']
config.virtual!['#internal/unhead-options.mjs'] = () => nuxt.vfs['#build/unhead-options.mjs']
config.virtual!['#internal/unhead.config.mjs'] = () => nuxt.vfs['#build/unhead.config.mjs']
})

View File

@ -0,0 +1,36 @@
import type { ActiveHeadEntry, MergeHead } from '@unhead/schema'
import type { UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput } from '@unhead/vue'
import { useHead as head, useHeadSafe as headSafe, useSeoMeta as seoMeta, useServerHead as serverHead, useServerHeadSafe as serverHeadSafe, useServerSeoMeta as serverSeoMeta } from '@unhead/vue'
import { tryUseNuxtApp } from '#app'
interface NuxtUseHeadOptions extends UseHeadOptions {
nuxt?: any
}
export function injectHead (nuxtApp?: any) {
return (nuxtApp || tryUseNuxtApp())?.runWithContext(() => injectHead())
}
export function useHead<T extends MergeHead> (input: UseHeadInput<T>, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> | void {
return (options.nuxt || tryUseNuxtApp()).runWithContext(() => head<T>(input, options))
}
export function useHeadSafe<T extends MergeHead> (input: UseHeadSafeInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> | void {
return (options.nuxt || tryUseNuxtApp()).runWithContext(() => headSafe(input, options))
}
export function useSeoMeta (input: UseSeoMetaInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseSeoMetaInput> | void {
return (options.nuxt || tryUseNuxtApp()).runWithContext(() => seoMeta(input, options))
}
export function useServerHead<T extends MergeHead> (input: UseHeadInput<T>, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> | void {
return (options.nuxt || tryUseNuxtApp()).runWithContext(() => serverHead<T>(input, options))
}
export function useServerHeadSafe (input: UseHeadSafeInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseSeoMetaInput> | void {
return (options.nuxt || tryUseNuxtApp()).runWithContext(() => serverHeadSafe(input, options))
}
export function useServerSeoMeta<T extends MergeHead> (input: UseSeoMetaInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> | void {
return (options.nuxt || tryUseNuxtApp()).runWithContext(() => serverSeoMeta(input, options))
}

View File

@ -0,0 +1,36 @@
import type { ActiveHeadEntry, MergeHead } from '@unhead/schema'
import type { UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput } from '@unhead/vue'
import { useHead as head, useHeadSafe as headSafe, useSeoMeta as seoMeta, useServerHead as serverHead, useServerHeadSafe as serverHeadSafe, useServerSeoMeta as serverSeoMeta } from '@unhead/vue'
import { useNuxtApp } from '#app'
interface NuxtUseHeadOptions extends UseHeadOptions {
nuxt?: any
}
export function injectHead (nuxtApp?: any) {
return (nuxtApp || useNuxtApp()).runWithContext(() => injectHead())
}
export function useHead<T extends MergeHead> (input: UseHeadInput<T>, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> {
return (options.nuxt || useNuxtApp()).runWithContext(() => head<T>(input, options))
}
export function useHeadSafe<T extends MergeHead> (input: UseHeadSafeInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> {
return (options.nuxt || useNuxtApp()).runWithContext(() => headSafe(input, options))
}
export function useSeoMeta (input: UseSeoMetaInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseSeoMetaInput> {
return (options.nuxt || useNuxtApp()).runWithContext(() => seoMeta(input, options))
}
export function useServerHead<T extends MergeHead> (input: UseHeadInput<T>, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> {
return (options.nuxt || useNuxtApp()).runWithContext(() => serverHead<T>(input, options))
}
export function useServerHeadSafe (input: UseHeadSafeInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseSeoMetaInput> {
return (options.nuxt || useNuxtApp()).runWithContext(() => serverHeadSafe(input, options))
}
export function useServerSeoMeta<T extends MergeHead> (input: UseSeoMetaInput, options: NuxtUseHeadOptions = {}): ActiveHeadEntry<UseHeadInput<T>> {
return (options.nuxt || useNuxtApp()).runWithContext(() => serverSeoMeta(input, options))
}

View File

@ -1,9 +1,8 @@
import { createHead as createClientHead, setHeadInjectionHandler } from '@unhead/vue'
import { renderDOMHead } from '@unhead/dom'
import { defineNuxtPlugin, useNuxtApp } from '#app/nuxt'
import { createHead as createClientHead, renderDOMHead } from '@unhead/vue/client'
import { defineNuxtPlugin } from '#app/nuxt'
// @ts-expect-error virtual file
import unheadPlugins from '#build/unhead-plugins.mjs'
import unheadOptions from '#build/unhead-options.mjs'
export default defineNuxtPlugin({
name: 'nuxt:head',
@ -11,14 +10,7 @@ export default defineNuxtPlugin({
setup (nuxtApp) {
const head = import.meta.server
? nuxtApp.ssrContext!.head
: createClientHead({
plugins: unheadPlugins,
})
// allow useHead to be used outside a Vue context but within a Nuxt context
setHeadInjectionHandler(
// need a fresh instance of the nuxt app to avoid parallel requests interfering with each other
() => useNuxtApp().vueApp._context.provides.usehead,
)
: createClientHead(unheadOptions)
// nuxt.config appHead is set server-side within the renderer
nuxtApp.vueApp.use(head)

View File

@ -37,7 +37,7 @@
},
"devDependencies": {
"@types/pug": "2.0.10",
"@unhead/schema": "1.11.15",
"@unhead/schema": "2.0.0-alpha.2",
"@vitejs/plugin-vue": "5.2.1",
"@vitejs/plugin-vue-jsx": "4.1.1",
"@vue/compiler-core": "3.5.13",

View File

@ -122,7 +122,7 @@ export async function buildServer (ctx: ViteBuildContext) {
if (Array.isArray(serverConfig.ssr!.external)) {
serverConfig.ssr!.external.push(
// explicit dependencies we use in our ssr renderer - these can be inlined (if necessary) in the nitro build
'unhead', '@unhead/ssr', 'unctx', 'h3', 'devalue', '@nuxt/devalue', 'radix3', 'rou3', 'unstorage', 'hookable',
'unhead', 'unctx', 'h3', 'devalue', '@nuxt/devalue', 'radix3', 'rou3', 'unstorage', 'hookable',
// ensure we only have one version of vue if nitro is going to inline anyway
...((ctx.nuxt as any)._nitro as Nitro).options.inlineDynamicImports ? ['vue', '@vue/server-renderer', '@unhead/vue'] : [],
// dependencies we might share with nitro - these can be inlined (if necessary) in the nitro build

View File

@ -11,11 +11,9 @@ overrides:
'@nuxt/vite-builder': workspace:*
'@nuxt/webpack-builder': workspace:*
'@types/node': 22.10.5
'@unhead/dom': 1.11.15
'@unhead/schema': 1.11.15
'@unhead/shared': 1.11.15
'@unhead/ssr': 1.11.15
'@unhead/vue': 1.11.15
'@unhead/schema': 2.0.0-alpha.2
'@unhead/vue': 2.0.0-alpha.2
'@unhead/shared': 2.0.0-alpha.2
'@vue/compiler-core': 3.5.13
'@vue/compiler-dom': 3.5.13
'@vue/shared': 3.5.13
@ -32,7 +30,7 @@ overrides:
typescript: 5.7.3
ufo: 1.5.4
unbuild: 3.2.0
unhead: 1.11.15
unhead: 2.0.0-alpha.2
unimport: 3.14.5
vite: 6.0.7
vue: 3.5.13
@ -72,11 +70,11 @@ importers:
specifier: 7.5.8
version: 7.5.8
'@unhead/schema':
specifier: 1.11.15
version: 1.11.15
specifier: 2.0.0-alpha.2
version: 2.0.0-alpha.2
'@unhead/vue':
specifier: 1.11.15
version: 1.11.15(vue@3.5.13(typescript@5.7.3))
specifier: 2.0.0-alpha.2
version: 2.0.0-alpha.2(vue@3.5.13(typescript@5.7.3))
'@vitest/coverage-v8':
specifier: 2.1.8
version: 2.1.8(vitest@2.1.8(@types/node@22.10.5)(happy-dom@16.5.3)(jiti@2.4.2)(sass@1.78.0)(terser@5.32.0)(tsx@4.19.2)(yaml@2.6.1))
@ -303,18 +301,9 @@ importers:
'@types/node':
specifier: 22.10.5
version: 22.10.5
'@unhead/dom':
specifier: 1.11.15
version: 1.11.15
'@unhead/shared':
specifier: 1.11.15
version: 1.11.15
'@unhead/ssr':
specifier: 1.11.15
version: 1.11.15
'@unhead/vue':
specifier: 1.11.15
version: 1.11.15(vue@3.5.13(typescript@5.7.3))
specifier: 2.0.0-alpha.2
version: 2.0.0-alpha.2(vue@3.5.13(typescript@5.7.3))
'@vue/shared':
specifier: 3.5.13
version: 3.5.13
@ -444,9 +433,6 @@ importers:
unenv:
specifier: ^1.10.0
version: 1.10.0
unhead:
specifier: 1.11.15
version: 1.11.15
unimport:
specifier: 3.14.5
version: 3.14.5(rollup@4.30.1)
@ -661,8 +647,8 @@ importers:
specifier: 2.0.10
version: 2.0.10
'@unhead/schema':
specifier: 1.11.15
version: 1.11.15
specifier: 2.0.0-alpha.2
version: 2.0.0-alpha.2
'@vitejs/plugin-vue':
specifier: 5.2.1
version: 5.2.1(vite@6.0.7(@types/node@22.10.5)(jiti@2.4.2)(sass@1.78.0)(terser@5.32.0)(tsx@4.19.2)(yaml@2.6.1))(vue@3.5.13(typescript@5.7.3))
@ -2743,20 +2729,14 @@ packages:
'@ungap/structured-clone@1.2.0':
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
'@unhead/dom@1.11.15':
resolution: {integrity: sha512-2OZ7zvZQLqlqkhvsKsNOhxxoO3vgjygzzrmtooQR9QNKY+3HjwJ3+QfjGswXI976YV7VJem57ydQSMk1ijB7yg==}
'@unhead/schema@2.0.0-alpha.2':
resolution: {integrity: sha512-Zuo0kqx2jnmxXDefsGEblTwSSXVenYDkMJ5H17lFTyxTIPnscISpvBSEFlPyCit7oTZXQ69wo4URhKiIXOZRyg==}
'@unhead/schema@1.11.15':
resolution: {integrity: sha512-UkLz1dqw4yoh4jELEyLsgSG7yrXc+gv68GkQeTv8LysEPa8sXtFqhfuqTBLhY3sHqSnP8RkDknhtFhG2S3fuKQ==}
'@unhead/shared@2.0.0-alpha.2':
resolution: {integrity: sha512-7hJpzfmnb9md6R3q5oxpX7bPdmTRbXsyaqHJzwaSrm9Q4+1J8wm0o36lwncQ0ssZfYxXynzrLkgY7sqCTSoGjA==}
'@unhead/shared@1.11.15':
resolution: {integrity: sha512-VT42ssmwpFGfixfXqAZ+Rn7KyNG0yFqWGsvLOXIgahiTzh3N1k2st1tPvuYFZU22dtWBNxG7cvy8yxUd1vunMQ==}
'@unhead/ssr@1.11.15':
resolution: {integrity: sha512-btoJ7huldVdxOJOr9yx8DpDiUELzdlX3LB0k5cBub+CI4nZoPC/8ovuaYzKBriAIkEtQp9g9ytHRUJYDvim/1g==}
'@unhead/vue@1.11.15':
resolution: {integrity: sha512-2NT8Kph5AvB/qO+C8UKAc7cudbFRZTJk0eRpn8o1nG3yk2+mWvN0vsTTjnKvXixNF193I/R+zqo/NkcjgaWG9A==}
'@unhead/vue@2.0.0-alpha.2':
resolution: {integrity: sha512-ieMix+zVKp+8grIkokWHgeakS+GSK1NtDs40iC072XVYbtw+5qCKA0Vmkelp31NTH/XRbVHtIqlvbzNCWKT24w==}
peerDependencies:
vue: 3.5.13
@ -7242,8 +7222,8 @@ packages:
unenv@1.10.0:
resolution: {integrity: sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==}
unhead@1.11.15:
resolution: {integrity: sha512-fA0rYB7qMHKY4sg0yzEXhi0cqiF/nl/OUKNaXOS9ChJwCjJxabpZvmQIUOiGS+1ckoFbZc3qZnhDLpdeNhOQwg==}
unhead@2.0.0-alpha.2:
resolution: {integrity: sha512-niBkQIczWnFEJdE/3Zj4QlYtiHFCrLKVM/xdz9aOnZ3U+E8kWyCnEwpOLKZuOUjyXRGnvX9XMsbcBBkBe+ei+A==}
unicode-emoji-modifier-base@1.0.0:
resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==}
@ -8872,7 +8852,7 @@ snapshots:
'@types/google.maps': 3.58.1
'@types/vimeo__player': 2.18.3
'@types/youtube': 0.1.0
'@unhead/vue': 1.11.15(vue@3.5.13(typescript@5.7.3))
'@unhead/vue': 2.0.0-alpha.2(vue@3.5.13(typescript@5.7.3))
'@vueuse/core': 11.1.0(vue@3.5.13(typescript@5.7.3))
consola: 3.3.3
defu: 6.1.4
@ -9733,32 +9713,22 @@ snapshots:
'@ungap/structured-clone@1.2.0': {}
'@unhead/dom@1.11.15':
dependencies:
'@unhead/schema': 1.11.15
'@unhead/shared': 1.11.15
'@unhead/schema@1.11.15':
'@unhead/schema@2.0.0-alpha.2':
dependencies:
hookable: 5.5.3
zhead: 2.2.4
'@unhead/shared@1.11.15':
'@unhead/shared@2.0.0-alpha.2':
dependencies:
'@unhead/schema': 1.11.15
'@unhead/schema': 2.0.0-alpha.2
packrup: 0.1.2
'@unhead/ssr@1.11.15':
'@unhead/vue@2.0.0-alpha.2(vue@3.5.13(typescript@5.7.3))':
dependencies:
'@unhead/schema': 1.11.15
'@unhead/shared': 1.11.15
'@unhead/vue@1.11.15(vue@3.5.13(typescript@5.7.3))':
dependencies:
'@unhead/schema': 1.11.15
'@unhead/shared': 1.11.15
'@unhead/schema': 2.0.0-alpha.2
'@unhead/shared': 2.0.0-alpha.2
hookable: 5.5.3
unhead: 1.11.15
unhead: 2.0.0-alpha.2
vue: 3.5.13(typescript@5.7.3)
'@unocss/astro@0.62.4(rollup@4.30.1)(vite@6.0.7(@types/node@22.10.5)(jiti@2.4.2)(sass@1.78.0)(terser@5.32.0)(tsx@4.19.2)(yaml@2.6.1))':
@ -15203,11 +15173,10 @@ snapshots:
node-fetch-native: 1.6.4
pathe: 1.1.2
unhead@1.11.15:
unhead@2.0.0-alpha.2:
dependencies:
'@unhead/dom': 1.11.15
'@unhead/schema': 1.11.15
'@unhead/shared': 1.11.15
'@unhead/schema': 2.0.0-alpha.2
'@unhead/shared': 2.0.0-alpha.2
hookable: 5.5.3
unicode-emoji-modifier-base@1.0.0: {}

View File

@ -23,8 +23,8 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
const [clientStats, clientStatsInlined] = await Promise.all((['.output', '.output-inline'])
.map(outputDir => analyzeSizes(['**/*.js'], join(rootDir, outputDir, 'public'))))
expect.soft(roundToKilobytes(clientStats!.totalBytes)).toMatchInlineSnapshot(`"116k"`)
expect.soft(roundToKilobytes(clientStatsInlined!.totalBytes)).toMatchInlineSnapshot(`"116k"`)
expect.soft(roundToKilobytes(clientStats!.totalBytes)).toMatchInlineSnapshot(`"115k"`)
expect.soft(roundToKilobytes(clientStatsInlined!.totalBytes)).toMatchInlineSnapshot(`"115k"`)
const files = new Set([...clientStats!.files, ...clientStatsInlined!.files].map(f => f.replace(/\..*\.js/, '.js')))
@ -58,10 +58,10 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
const serverDir = join(rootDir, '.output/server')
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"210k"`)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"209k"`)
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1398k"`)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1382k"`)
const packages = modules.files
.filter(m => m.endsWith('package.json'))
@ -70,9 +70,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
expect(packages).toMatchInlineSnapshot(`
[
"@babel/parser",
"@unhead/dom",
"@unhead/shared",
"@unhead/ssr",
"@vue/compiler-core",
"@vue/compiler-dom",
"@vue/compiler-ssr",
@ -103,7 +101,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"560k"`)
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"96.4k"`)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"79.7k"`)
const packages = modules.files
.filter(m => m.endsWith('package.json'))
@ -111,9 +109,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
.sort()
expect(packages).toMatchInlineSnapshot(`
[
"@unhead/dom",
"@unhead/shared",
"@unhead/ssr",
"db0",
"devalue",
"hookable",
@ -127,10 +123,10 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
const serverDir = join(pagesRootDir, '.output/server')
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"303k"`)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"302k"`)
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1398k"`)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1382k"`)
const packages = modules.files
.filter(m => m.endsWith('package.json'))
@ -139,9 +135,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
expect(packages).toMatchInlineSnapshot(`
[
"@babel/parser",
"@unhead/dom",
"@unhead/shared",
"@unhead/ssr",
"@vue/compiler-core",
"@vue/compiler-dom",
"@vue/compiler-ssr",