mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +00:00
fix(nuxt): make pageMeta ast undefineable in transformation
This commit is contained in:
parent
f55f747984
commit
dfd935bee6
@ -122,10 +122,10 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
|
||||
const name = 'name' in node.callee && node.callee.name
|
||||
if (name !== 'definePageMeta') { return }
|
||||
|
||||
const meta = node.arguments[0] as Expression & { start: number, end: number }
|
||||
|
||||
let contents = `const __nuxt_page_meta = ${code!.slice(meta.start, meta.end) || 'null'}\nexport default __nuxt_page_meta` + (options.dev ? CODE_HMR : '')
|
||||
const meta = node.arguments[0] as (Expression & { start: number, end: number }) | undefined
|
||||
let contents = `const __nuxt_page_meta = ${meta ? code!.slice(meta.start, meta.end) || 'null' : 'null'}\nexport default __nuxt_page_meta` + (options.dev ? CODE_HMR : '')
|
||||
|
||||
if(meta) {
|
||||
function addImport (name: string | false) {
|
||||
if (name && importMap.has(name)) {
|
||||
const importValue = importMap.get(name)!.code
|
||||
@ -148,6 +148,7 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
s.overwrite(0, code.length, contents)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user