mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): skip middleware for islands components (#20924)
This commit is contained in:
parent
b88aab049f
commit
2d680455ae
@ -235,6 +235,7 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>({
|
|||||||
}
|
}
|
||||||
nuxtApp._processingMiddleware = true
|
nuxtApp._processingMiddleware = true
|
||||||
|
|
||||||
|
if (process.client || !nuxtApp.ssrContext?.islandContext) {
|
||||||
const middlewareEntries = new Set<RouteGuard>([...globalMiddleware, ...nuxtApp._middleware.global])
|
const middlewareEntries = new Set<RouteGuard>([...globalMiddleware, ...nuxtApp._middleware.global])
|
||||||
|
|
||||||
for (const middleware of middlewareEntries) {
|
for (const middleware of middlewareEntries) {
|
||||||
@ -251,6 +252,7 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>({
|
|||||||
}
|
}
|
||||||
if (result || result === false) { return result }
|
if (result || result === false) { return result }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.afterEach(() => { delete nuxtApp._processingMiddleware })
|
router.afterEach(() => { delete nuxtApp._processingMiddleware })
|
||||||
|
@ -135,6 +135,7 @@ const plugin: Plugin<{ router: Router }> = defineNuxtPlugin({
|
|||||||
}
|
}
|
||||||
nuxtApp._processingMiddleware = true
|
nuxtApp._processingMiddleware = true
|
||||||
|
|
||||||
|
if (process.client || !nuxtApp.ssrContext?.islandContext) {
|
||||||
type MiddlewareDef = string | RouteMiddleware
|
type MiddlewareDef = string | RouteMiddleware
|
||||||
const middlewareEntries = new Set<MiddlewareDef>([...globalMiddleware, ...nuxtApp._middleware.global])
|
const middlewareEntries = new Set<MiddlewareDef>([...globalMiddleware, ...nuxtApp._middleware.global])
|
||||||
for (const component of to.matched) {
|
for (const component of to.matched) {
|
||||||
@ -172,6 +173,7 @@ const plugin: Plugin<{ router: Router }> = defineNuxtPlugin({
|
|||||||
}
|
}
|
||||||
if (result || result === false) { return result }
|
if (result || result === false) { return result }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.onError(() => { delete nuxtApp._processingMiddleware })
|
router.onError(() => { delete nuxtApp._processingMiddleware })
|
||||||
|
@ -45,7 +45,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e
|
|||||||
|
|
||||||
it('default server bundle size', async () => {
|
it('default server bundle size', async () => {
|
||||||
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||||
expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"62.2k"')
|
expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"62.4k"')
|
||||||
|
|
||||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||||
expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2283k"')
|
expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2283k"')
|
||||||
|
Loading…
Reference in New Issue
Block a user