fix(nuxt, vite): ignore nuxt_component ssr style and isVue (#20679)

This commit is contained in:
Anthony Fu 2023-05-04 18:19:03 +02:00 committed by GitHub
parent 8c75961f74
commit 1f38863c06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,11 @@ export function isVue (id: string, opts: { type?: Array<'template' | 'script' |
const query = parseQuery(search) const query = parseQuery(search)
// Component async/lazy wrapper
if (query.nuxt_component) {
return false
}
// Macro // Macro
if (query.macro && (!opts.type || opts.type.includes('script'))) { if (query.macro && (!opts.type || opts.type.includes('script'))) {
return true return true

View File

@ -93,7 +93,7 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {
async transform (code, id) { async transform (code, id) {
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href)) const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
const query = parseQuery(search) const query = parseQuery(search)
if (!pathname.match(/\.(vue|((c|m)?j|t)sx?)$/g) || query.macro) { return } if (!pathname.match(/\.(vue|((c|m)?j|t)sx?)$/g) || query.macro || query.nuxt_component) { return }
if (options.shouldInline && !options.shouldInline(id)) { return } if (options.shouldInline && !options.shouldInline(id)) { return }
const relativeId = relativeToSrcDir(id) const relativeId = relativeToSrcDir(id)