mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): don't generate separate chunk for stubs (#26291)
This commit is contained in:
parent
e272b2f2e1
commit
814859d769
@ -364,6 +364,7 @@ export default defineNuxtModule({
|
||||
const rule = nitro.options.routeRules[path]
|
||||
if (!rule.redirect) { continue }
|
||||
routes.push({
|
||||
_sync: true,
|
||||
path: path.replace(/\/[^/]*\*\*/, '/:pathMatch(.*)'),
|
||||
file: resolve(runtimeDir, 'component-stub')
|
||||
})
|
||||
|
@ -444,9 +444,16 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
||||
}
|
||||
|
||||
const file = normalize(page.file)
|
||||
const metaImportName = genSafeVariableName(filename(file) + hash(file)) + 'Meta'
|
||||
const pageImportName = genSafeVariableName(filename(file) + hash(file))
|
||||
const metaImportName = pageImportName + 'Meta'
|
||||
metaImports.add(genImport(`${file}?macro=true`, [{ name: 'default', as: metaImportName }]))
|
||||
|
||||
if (page._sync) {
|
||||
metaImports.add(genImport(file, [{ name: 'default', as: pageImportName }]))
|
||||
}
|
||||
|
||||
const pageImport = page._sync && page.mode !== 'client' ? pageImportName : genDynamicImport(file, { interopDefault: true })
|
||||
|
||||
const metaRoute: NormalizedRoute = {
|
||||
name: `${metaImportName}?.name ?? ${route.name}`,
|
||||
path: `${metaImportName}?.path ?? ${route.path}`,
|
||||
@ -456,8 +463,8 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
||||
component: page.mode === 'server'
|
||||
? `() => createIslandPage(${route.name})`
|
||||
: page.mode === 'client'
|
||||
? `() => createClientPage(${genDynamicImport(file, { interopDefault: true })})`
|
||||
: genDynamicImport(file, { interopDefault: true })
|
||||
? `() => createClientPage(${pageImport})`
|
||||
: pageImport
|
||||
}
|
||||
|
||||
if (page.mode === 'server') {
|
||||
|
@ -44,6 +44,8 @@ export type NuxtPage = {
|
||||
* @default 'all'
|
||||
*/
|
||||
mode?: 'client' | 'server' | 'all'
|
||||
/** @internal */
|
||||
_sync?: boolean
|
||||
}
|
||||
|
||||
export type NuxtMiddleware = {
|
||||
|
Loading…
Reference in New Issue
Block a user