mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): restore prerenderedAt
behaviour pending next patch
This commit is contained in:
parent
c2fff578d1
commit
108b1bdf72
@ -79,7 +79,10 @@ async function _importPayload (payloadURL: string) {
|
|||||||
export async function isPrerendered (url = useRoute().path) {
|
export async function isPrerendered (url = useRoute().path) {
|
||||||
// Note: Alternative for server is checking x-nitro-prerender header
|
// Note: Alternative for server is checking x-nitro-prerender header
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
if (!appManifest) { return !!nuxtApp.payload.prerenderedAt }
|
if (nuxtApp.payload.prerenderedAt) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (!appManifest) { return false }
|
||||||
const manifest = await getAppManifest()
|
const manifest = await getAppManifest()
|
||||||
if (manifest.prerendered.includes(url)) {
|
if (manifest.prerendered.includes(url)) {
|
||||||
return true
|
return true
|
||||||
|
@ -19,7 +19,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
|||||||
for (const outputDir of ['.output', '.output-inline']) {
|
for (const outputDir of ['.output', '.output-inline']) {
|
||||||
it('default client bundle size', async () => {
|
it('default client bundle size', async () => {
|
||||||
const clientStats = await analyzeSizes('**/*.js', join(rootDir, outputDir, 'public'))
|
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(`
|
expect(clientStats.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
"_nuxt/entry.js",
|
"_nuxt/entry.js",
|
||||||
|
3
test/fixtures/basic/nuxt.config.ts
vendored
3
test/fixtures/basic/nuxt.config.ts
vendored
@ -47,9 +47,6 @@ export default defineNuxtConfig({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
routeRules: {
|
routeRules: {
|
||||||
// TODO: update this test
|
|
||||||
// pretend to be fully prerendered
|
|
||||||
'/**': { prerender: true },
|
|
||||||
'/route-rules/spa': { ssr: false },
|
'/route-rules/spa': { ssr: false },
|
||||||
'/hydration/spa-redirection/**': { ssr: false },
|
'/hydration/spa-redirection/**': { ssr: false },
|
||||||
'/no-scripts': { experimentalNoScripts: true }
|
'/no-scripts': { experimentalNoScripts: true }
|
||||||
|
4
test/fixtures/basic/plugins/prerender.server.ts
vendored
Normal file
4
test/fixtures/basic/plugins/prerender.server.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
|
// Pretend to be prerendered
|
||||||
|
nuxtApp.payload.prerenderedAt = Date.now()
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user