mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 14:45:15 +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
|
const name = 'name' in node.callee && node.callee.name
|
||||||
if (name !== 'definePageMeta') { return }
|
if (name !== 'definePageMeta') { return }
|
||||||
|
|
||||||
const meta = node.arguments[0] as Expression & { start: number, end: number }
|
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 : '')
|
||||||
let contents = `const __nuxt_page_meta = ${code!.slice(meta.start, meta.end) || 'null'}\nexport default __nuxt_page_meta` + (options.dev ? CODE_HMR : '')
|
|
||||||
|
|
||||||
|
if(meta) {
|
||||||
function addImport (name: string | false) {
|
function addImport (name: string | false) {
|
||||||
if (name && importMap.has(name)) {
|
if (name && importMap.has(name)) {
|
||||||
const importValue = importMap.get(name)!.code
|
const importValue = importMap.get(name)!.code
|
||||||
@ -148,6 +148,7 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
s.overwrite(0, code.length, contents)
|
s.overwrite(0, code.length, contents)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user