mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(nuxt): don't mark redirected routes as prerendered (#23707)
This commit is contained in:
parent
00917a1bd8
commit
ae630c599f
@ -88,7 +88,7 @@ export async function isPrerendered (url = useRoute().path) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
const rules = await getRouteRules(url)
|
const rules = await getRouteRules(url)
|
||||||
return !!rules.prerender
|
return !!rules.prerender && !rules.redirect
|
||||||
}
|
}
|
||||||
|
|
||||||
let payloadCache: any = null
|
let payloadCache: any = null
|
||||||
|
@ -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",
|
||||||
|
@ -27,7 +27,15 @@ registerEndpoint('/_nuxt/builds/latest.json', defineEventHandler(() => ({
|
|||||||
registerEndpoint('/_nuxt/builds/meta/override.json', defineEventHandler(() => ({
|
registerEndpoint('/_nuxt/builds/meta/override.json', defineEventHandler(() => ({
|
||||||
id: 'override',
|
id: 'override',
|
||||||
timestamp,
|
timestamp,
|
||||||
matcher: { static: { '/': null, '/pre': null }, wildcard: { '/pre': { prerender: true } }, dynamic: {} },
|
matcher: {
|
||||||
|
static: {
|
||||||
|
'/': null,
|
||||||
|
'/pre': null,
|
||||||
|
'/pre/test': { redirect: true }
|
||||||
|
},
|
||||||
|
wildcard: { '/pre': { prerender: true } },
|
||||||
|
dynamic: {}
|
||||||
|
},
|
||||||
prerendered: ['/specific-prerendered']
|
prerendered: ['/specific-prerendered']
|
||||||
})))
|
})))
|
||||||
|
|
||||||
@ -306,6 +314,9 @@ describe.skipIf(process.env.TEST_MANIFEST === 'manifest-off')('app manifests', (
|
|||||||
"static": {
|
"static": {
|
||||||
"/": null,
|
"/": null,
|
||||||
"/pre": null,
|
"/pre": null,
|
||||||
|
"/pre/test": {
|
||||||
|
"redirect": true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"wildcard": {
|
"wildcard": {
|
||||||
"/pre": {
|
"/pre": {
|
||||||
@ -320,12 +331,24 @@ describe.skipIf(process.env.TEST_MANIFEST === 'manifest-off')('app manifests', (
|
|||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
it('getRouteRules', async () => {
|
it('getRouteRules', async () => {
|
||||||
const rules = await getRouteRules('/')
|
expect(await getRouteRules('/')).toMatchInlineSnapshot('{}')
|
||||||
expect(rules).toMatchInlineSnapshot('{}')
|
expect(await getRouteRules('/pre')).toMatchInlineSnapshot(`
|
||||||
|
{
|
||||||
|
"prerender": true,
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
expect(await getRouteRules('/pre/test')).toMatchInlineSnapshot(`
|
||||||
|
{
|
||||||
|
"prerender": true,
|
||||||
|
"redirect": true,
|
||||||
|
}
|
||||||
|
`)
|
||||||
})
|
})
|
||||||
it('isPrerendered', async () => {
|
it('isPrerendered', async () => {
|
||||||
expect(await isPrerendered('/specific-prerendered')).toBeTruthy()
|
expect(await isPrerendered('/specific-prerendered')).toBeTruthy()
|
||||||
expect(await isPrerendered('/prerendered/test')).toBeTruthy()
|
expect(await isPrerendered('/prerendered/test')).toBeTruthy()
|
||||||
expect(await isPrerendered('/test')).toBeFalsy()
|
expect(await isPrerendered('/test')).toBeFalsy()
|
||||||
|
expect(await isPrerendered('/pre/test')).toBeFalsy()
|
||||||
|
expect(await isPrerendered('/pre/thing')).toBeTruthy()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user