From 424dc8d7c0448b4bdc3051791adbeed15907220f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Sat, 26 Aug 2023 16:45:17 +0200 Subject: [PATCH] fix(nuxt): exclude resolved vite virtual modules prefix (#22834) --- packages/nuxt/src/components/transform.ts | 2 +- packages/nuxt/src/core/plugins/resolve-deep-imports.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/components/transform.ts b/packages/nuxt/src/components/transform.ts index 579cf42e7b..6d1a45af39 100644 --- a/packages/nuxt/src/components/transform.ts +++ b/packages/nuxt/src/components/transform.ts @@ -47,7 +47,7 @@ export function createTransformPlugin (nuxt: Nuxt, getComponents: getComponentsT name: 'nuxt:components:imports', transformInclude (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) { // Virtual component wrapper diff --git a/packages/nuxt/src/core/plugins/resolve-deep-imports.ts b/packages/nuxt/src/core/plugins/resolve-deep-imports.ts index ba4aaf7bd4..032117178e 100644 --- a/packages/nuxt/src/core/plugins/resolve-deep-imports.ts +++ b/packages/nuxt/src/core/plugins/resolve-deep-imports.ts @@ -7,11 +7,12 @@ import type { Nuxt } from '@nuxt/schema' import { pkgDir } from '../../dirs' export function resolveDeepImportsPlugin (nuxt: Nuxt): Plugin { + const exclude: string[] = ['virtual:', '\0virtual:', '/__skip_vite'] return { name: 'nuxt:resolve-bare-imports', enforce: 'post', 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 } id = normalize(id)