fix(nuxt): exclude resolved vite virtual modules prefix (#22834)

This commit is contained in:
Joaquín Sánchez 2023-08-26 16:45:17 +02:00 committed by GitHub
parent adb6ec6742
commit 424dc8d7c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -47,7 +47,7 @@ export function createTransformPlugin (nuxt: Nuxt, getComponents: getComponentsT
name: 'nuxt:components:imports', name: 'nuxt:components:imports',
transformInclude (id) { transformInclude (id) {
id = normalize(id) id = normalize(id)
return id.startsWith('virtual:') || id.startsWith(nuxt.options.buildDir) || !isIgnored(id) return id.startsWith('virtual:') || id.startsWith('\0virtual:') || id.startsWith(nuxt.options.buildDir) || !isIgnored(id)
}, },
async transform (code, id) { async transform (code, id) {
// Virtual component wrapper // Virtual component wrapper

View File

@ -7,11 +7,12 @@ import type { Nuxt } from '@nuxt/schema'
import { pkgDir } from '../../dirs' import { pkgDir } from '../../dirs'
export function resolveDeepImportsPlugin (nuxt: Nuxt): Plugin { export function resolveDeepImportsPlugin (nuxt: Nuxt): Plugin {
const exclude: string[] = ['virtual:', '\0virtual:', '/__skip_vite']
return { return {
name: 'nuxt:resolve-bare-imports', name: 'nuxt:resolve-bare-imports',
enforce: 'post', enforce: 'post',
async resolveId (id, importer, options) { async resolveId (id, importer, options) {
if (!importer || isAbsolute(id) || !isAbsolute(importer) || id.startsWith('virtual:') || id.startsWith('/__skip_vite')) { if (!importer || isAbsolute(id) || !isAbsolute(importer) || exclude.some(e => id.startsWith(e))) {
return return
} }
id = normalize(id) id = normalize(id)