fix(nuxt3): re-enable tree-shaking definePageMeta (#3180)

This commit is contained in:
Daniel Roe 2022-02-11 08:59:52 +00:00 committed by GitHub
parent 6d4eb3da26
commit e727bb4192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -13,9 +13,10 @@ export const TransformMacroPlugin = createUnplugin((options: TransformMacroPlugi
enforce: 'post',
transformInclude (id) {
const { search, pathname } = parseURL(id)
return pathname.endsWith('.vue') || parseQuery(search).macro
return pathname.endsWith('.vue') || !!parseQuery(search).macro
},
transform (code, id) {
const originalCode = code
const { search } = parseURL(id)
// 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
// with workaround for vue-loader bug: https://github.com/vuejs/vue-loader/pull/1911

View File

@ -25,7 +25,7 @@ declare module 'vue-router' {
const warnRuntimeUsage = (method: string) =>
console.warn(
`${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.'
)