From 31c67ad9b4d8707270fe97f993304dece093039c Mon Sep 17 00:00:00 2001 From: Dario Merz Date: Fri, 6 May 2022 15:33:32 +0200 Subject: [PATCH] fix(vite): ignore virtual imports that aren't in vfs (#4822) Co-authored-by: Dario Merz Co-authored-by: Daniel Roe --- packages/vite/src/plugins/virtual.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/plugins/virtual.ts b/packages/vite/src/plugins/virtual.ts index 748a0928c0..f1c2ff9996 100644 --- a/packages/vite/src/plugins/virtual.ts +++ b/packages/vite/src/plugins/virtual.ts @@ -1,7 +1,7 @@ import { dirname, isAbsolute, join, resolve } from 'pathe' import type { Plugin } from 'rollup' -const PREFIX = 'virtual:' +const PREFIX = 'virtual:nuxt:' export default function virtual (vfs: Record): Plugin { const extensions = ['', '.ts', '.vue', '.mjs', '.cjs', '.js', '.json'] @@ -37,9 +37,11 @@ export default function virtual (vfs: Record): Plugin { load (id) { if (!id.startsWith(PREFIX)) { return null } const idNoPrefix = id.slice(PREFIX.length) - return { - code: vfs[idNoPrefix], - map: null + if (idNoPrefix in vfs) { + return { + code: vfs[idNoPrefix], + map: null + } } } }