perf(nuxt): drop pathe browser dep for deep server components (#30456)

This commit is contained in:
Daniel Roe 2025-01-05 00:28:48 +00:00 committed by GitHub
parent 7a5fd9b5f2
commit 7f49b6d573
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -7,7 +7,6 @@ import { type ActiveHeadEntry, type Head, injectHead } from '@unhead/vue'
import { randomUUID } from 'uncrypto'
import { joinURL, withQuery } from 'ufo'
import type { FetchResponse } from 'ofetch'
import { join } from 'pathe'
import type { NuxtIslandResponse } from '../types'
import { useNuxtApp, useRuntimeConfig } from '../nuxt'
@ -37,7 +36,7 @@ async function loadComponents (source = appBaseURL, paths: NuxtIslandResponse['c
for (const [component, item] of Object.entries(paths)) {
if (!(components!.has(component))) {
promises.push((async () => {
const chunkSource = join(source, item.chunk)
const chunkSource = joinURL(source, item.chunk)
const c = await import(/* @vite-ignore */ chunkSource).then(m => m.default || m)
components!.set(component, c)
})())

View File

@ -3,6 +3,8 @@ import { Teleport, defineComponent, h, inject, provide, useId } from 'vue'
import { useNuxtApp } from '../nuxt'
// @ts-expect-error virtual file
import { paths } from '#build/components-chunk'
// @ts-expect-error virtual file
import { buildAssetsURL } from '#internal/nuxt/paths'
type ExtendedComponent = Component & {
__file: string
@ -41,7 +43,7 @@ export default defineComponent({
const name = (slotType.__name || slotType.name) as string
islandContext.components[to] = {
chunk: import.meta.dev ? nuxtApp.$config.app.buildAssetsDir + paths[name] : paths[name],
chunk: import.meta.dev ? buildAssetsURL(paths[name]) : paths[name],
props: slot.props || {},
}