Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions packages/nuxt/src/core/runtime/nitro/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ interface RenderResult {
}

// @ts-ignore
const getClientManifest = () => import('#build/dist/server/client.manifest.mjs').then(r => r.default || r)
const getClientManifest = () => import('#build/dist/server/client.manifest.mjs')
.then(r => r.default || r)
.then(r => typeof r === 'function' ? r() : r)

// @ts-ignore
const getServerEntry = () => process.env.NUXT_NO_SSR ? Promise.resolve(null) : import('#build/dist/server/server.mjs').then(r => r.default || r)
Expand All @@ -46,15 +48,22 @@ const getSSRRenderer = lazyCachedFunction(async () => {
if (!createSSRApp) { throw new Error('Server bundle is not available') }

// Create renderer
const renderToString = async (input, context) => {
const html = await _renderToString(input, context)
return `<div id="__nuxt">${html}</div>`
}
return createRenderer(createSSRApp, {
const renderer = createRenderer(createSSRApp, {
clientManifest,
renderToString,
publicPath: buildAssetsURL()
})

async function renderToString (input, context) {
const html = await _renderToString(input, context)
// In development with vite-node, the manifest is on-demand and will be available after rendering
if (process.dev && process.env.NUXT_VITE_NODE_OPTIONS) {
renderer.rendererContext.updateManifest(await getClientManifest())
}
return `<div id="__nuxt">${html}</div>`
}

return renderer
})

// -- SPA Renderer --
Expand Down
4 changes: 1 addition & 3 deletions packages/vite/src/runtime/client.manifest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ import { getViteNodeOptions } from './vite-node-shared.mjs'

const viteNodeOptions = getViteNodeOptions()

const manifest = await $fetch('/manifest', { baseURL: viteNodeOptions.baseURL })

export default manifest
export default () => $fetch('/manifest', { baseURL: viteNodeOptions.baseURL })