diff --git a/packages/nuxt/src/app/composables/payload.ts b/packages/nuxt/src/app/composables/payload.ts index b708f0bcc1..7220a36e53 100644 --- a/packages/nuxt/src/app/composables/payload.ts +++ b/packages/nuxt/src/app/composables/payload.ts @@ -79,7 +79,10 @@ async function _importPayload (payloadURL: string) { export async function isPrerendered (url = useRoute().path) { // Note: Alternative for server is checking x-nitro-prerender header const nuxtApp = useNuxtApp() - if (!appManifest) { return !!nuxtApp.payload.prerenderedAt } + if (nuxtApp.payload.prerenderedAt) { + return true + } + if (!appManifest) { return false } const manifest = await getAppManifest() if (manifest.prerendered.includes(url)) { return true diff --git a/test/bundle.test.ts b/test/bundle.test.ts index 0887888846..ed506c5094 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -19,7 +19,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM for (const outputDir of ['.output', '.output-inline']) { it('default client bundle size', async () => { const clientStats = await analyzeSizes('**/*.js', join(rootDir, outputDir, 'public')) - expect.soft(roundToKilobytes(clientStats.totalBytes)).toMatchInlineSnapshot('"99.1k"') + expect.soft(roundToKilobytes(clientStats.totalBytes)).toMatchInlineSnapshot('"99.2k"') expect(clientStats.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(` [ "_nuxt/entry.js", diff --git a/test/fixtures/basic/nuxt.config.ts b/test/fixtures/basic/nuxt.config.ts index 5ff07c9e0b..3c1193ad16 100644 --- a/test/fixtures/basic/nuxt.config.ts +++ b/test/fixtures/basic/nuxt.config.ts @@ -47,9 +47,6 @@ export default defineNuxtConfig({ } }, routeRules: { - // TODO: update this test - // pretend to be fully prerendered - '/**': { prerender: true }, '/route-rules/spa': { ssr: false }, '/hydration/spa-redirection/**': { ssr: false }, '/no-scripts': { experimentalNoScripts: true } diff --git a/test/fixtures/basic/plugins/prerender.server.ts b/test/fixtures/basic/plugins/prerender.server.ts new file mode 100644 index 0000000000..9eec0f831c --- /dev/null +++ b/test/fixtures/basic/plugins/prerender.server.ts @@ -0,0 +1,4 @@ +export default defineNuxtPlugin((nuxtApp) => { + // Pretend to be prerendered + nuxtApp.payload.prerenderedAt = Date.now() +})