Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt): use virtual server stub with ssr: false
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 7, 2022
1 parent 23546a2 commit f0d5eac
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/nuxt/src/core/nitro.ts
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ export async function initNitro (nuxt: Nuxt) {
handlers,
devHandlers: [],
baseURL: nuxt.options.app.baseURL,
virtual: {},
runtimeConfig: {
...nuxt.options.runtimeConfig,
nitro: {
@@ -100,6 +101,11 @@ export async function initNitro (nuxt: Nuxt) {
}
})

// Add fallback server for `ssr: false`
if (!nuxt.options.ssr) {
nitroConfig.virtual['#build/dist/server/server.mjs'] = 'export default () => {}'
}

// Extend nitro config with hook
await nuxt.callHook('nitro:config', nitroConfig)

2 changes: 1 addition & 1 deletion packages/nuxt/src/core/runtime/nitro/renderer.ts
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ const getClientManifest = () => import('#build/dist/server/client.manifest.mjs')
.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)
const getServerEntry = () => import('#build/dist/server/server.mjs').then(r => r.default || r)

// -- SSR Renderer --
const getSSRRenderer = lazyCachedFunction(async () => {

0 comments on commit f0d5eac

Please sign in to comment.