mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-19 01:45:53 +00:00
perf(nuxt): allow tree-shaking empty meta from build (#19032)
This commit is contained in:
parent
523b495e1d
commit
59a1f7bae0
@ -16,7 +16,7 @@ export interface PageMetaPluginOptions {
|
||||
}
|
||||
|
||||
const CODE_EMPTY = `
|
||||
const __nuxt_page_meta = {}
|
||||
const __nuxt_page_meta = null
|
||||
export default __nuxt_page_meta
|
||||
`
|
||||
|
||||
@ -138,7 +138,7 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
|
||||
|
||||
const meta = node.arguments[0] as Expression & { start: number, end: number }
|
||||
|
||||
let contents = `const __nuxt_page_meta = ${code!.slice(meta.start, meta.end) || '{}'}\nexport default __nuxt_page_meta` + (options.dev ? CODE_HMR : '')
|
||||
let contents = `const __nuxt_page_meta = ${code!.slice(meta.start, meta.end) || 'null'}\nexport default __nuxt_page_meta` + (options.dev ? CODE_HMR : '')
|
||||
|
||||
function addImport (name: string | false) {
|
||||
if (name && importMap.has(name)) {
|
||||
|
@ -264,7 +264,7 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
||||
name: `${metaImportName}?.name ?? ${page.name ? JSON.stringify(page.name) : 'undefined'}`,
|
||||
path: `${metaImportName}?.path ?? ${JSON.stringify(page.path)}`,
|
||||
children: page.children ? normalizeRoutes(page.children, metaImports).routes : [],
|
||||
meta: page.meta ? `{...(${metaImportName} || {}), ...${JSON.stringify(page.meta)}}` : metaImportName,
|
||||
meta: page.meta ? `{...(${metaImportName} || {}), ...${JSON.stringify(page.meta)}}` : `${metaImportName} || {}`,
|
||||
alias: aliasCode,
|
||||
redirect: page.redirect ? JSON.stringify(page.redirect) : `${metaImportName}?.redirect || undefined`,
|
||||
component: genDynamicImport(file, { interopDefault: true })
|
||||
|
Loading…
Reference in New Issue
Block a user