Skip to content

Commit

Permalink
fix(nuxt): restore prerenderedAt behaviour pending next patch
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 19, 2023
1 parent c2fff57 commit 108b1bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion packages/nuxt/src/app/composables/payload.ts
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/bundle.test.ts
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions test/fixtures/basic/nuxt.config.ts
Expand Up @@ -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 }
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/basic/plugins/prerender.server.ts
@@ -0,0 +1,4 @@
export default defineNuxtPlugin((nuxtApp) => {
// Pretend to be prerendered
nuxtApp.payload.prerenderedAt = Date.now()
})

0 comments on commit 108b1bd

Please sign in to comment.