mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-02 02:17:15 +00:00
fix(nuxt3): re-enable tree-shaking definePageMeta
(#3180)
This commit is contained in:
parent
6d4eb3da26
commit
e727bb4192
@ -13,9 +13,10 @@ export const TransformMacroPlugin = createUnplugin((options: TransformMacroPlugi
|
|||||||
enforce: 'post',
|
enforce: 'post',
|
||||||
transformInclude (id) {
|
transformInclude (id) {
|
||||||
const { search, pathname } = parseURL(id)
|
const { search, pathname } = parseURL(id)
|
||||||
return pathname.endsWith('.vue') || parseQuery(search).macro
|
return pathname.endsWith('.vue') || !!parseQuery(search).macro
|
||||||
},
|
},
|
||||||
transform (code, id) {
|
transform (code, id) {
|
||||||
|
const originalCode = code
|
||||||
const { search } = parseURL(id)
|
const { search } = parseURL(id)
|
||||||
|
|
||||||
// Tree-shake out any runtime references to the macro.
|
// Tree-shake out any runtime references to the macro.
|
||||||
@ -27,7 +28,9 @@ export const TransformMacroPlugin = createUnplugin((options: TransformMacroPlugi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parseQuery(search).macro) { return }
|
if (!parseQuery(search).macro) {
|
||||||
|
return originalCode === code ? undefined : code
|
||||||
|
}
|
||||||
|
|
||||||
// [webpack] Re-export any imports from script blocks in the components
|
// [webpack] Re-export any imports from script blocks in the components
|
||||||
// with workaround for vue-loader bug: https://github.com/vuejs/vue-loader/pull/1911
|
// with workaround for vue-loader bug: https://github.com/vuejs/vue-loader/pull/1911
|
||||||
|
@ -25,7 +25,7 @@ declare module 'vue-router' {
|
|||||||
const warnRuntimeUsage = (method: string) =>
|
const warnRuntimeUsage = (method: string) =>
|
||||||
console.warn(
|
console.warn(
|
||||||
`${method}() is a compiler-hint helper that is only usable inside ` +
|
`${method}() is a compiler-hint helper that is only usable inside ` +
|
||||||
'<script setup> of a single file component. Its arguments should be ' +
|
'the script block of a single file component. Its arguments should be ' +
|
||||||
'compiled away and passing it at runtime has no effect.'
|
'compiled away and passing it at runtime has no effect.'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user