Skip to content

Commit

Permalink
fix(vite): ignore virtual imports that aren't in vfs (nuxt#4822)
Browse files Browse the repository at this point in the history
Co-authored-by: Dario Merz <dario.merz@deptagency.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
  • Loading branch information
3 people authored May 6, 2022
1 parent 5816fee commit 31c67ad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/vite/src/plugins/virtual.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>): Plugin {
const extensions = ['', '.ts', '.vue', '.mjs', '.cjs', '.js', '.json']
Expand Down Expand Up @@ -37,9 +37,11 @@ export default function virtual (vfs: Record<string, string>): 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
}
}
}
}
Expand Down

0 comments on commit 31c67ad

Please sign in to comment.