fix(nuxt): don't add macro query to the end of id (#5413)

* fix(nuxt): don't add macro query to the end of id

* Update packages/nuxt/src/pages/macros.ts

Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
Jaemin Choi 2022-06-13 06:46:31 +09:00 committed by GitHub
parent a9c061cd2e
commit 95b38e241d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -46,7 +46,10 @@ export const TransformMacroPlugin = createUnplugin((options: TransformMacroPlugi
// with workaround for vue-loader bug: https://github.com/vuejs/vue-loader/pull/1911
const scriptImport = findStaticImports(code).find(i => parseQuery(i.specifier.replace('?macro=true', '')).type === 'script')
if (scriptImport) {
const specifier = withQuery(scriptImport.specifier.replace('?macro=true', ''), { macro: 'true' })
// https://github.com/vuejs/vue-loader/pull/1911
// https://github.com/vitejs/vite/issues/8473
const parsed = parseURL(scriptImport.specifier.replace('?macro=true', ''))
const specifier = withQuery(parsed.pathname, { macro: 'true', ...parseQuery(parsed.search) })
s.overwrite(0, code.length, `export { meta } from "${specifier}"`)
return result()
}