mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-28 19:43:13 +00:00
fix(vite): ignore virtual imports that aren't in vfs (#4822)
Co-authored-by: Dario Merz <dario.merz@deptagency.com> Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
parent
5816fee892
commit
31c67ad9b4
@ -1,7 +1,7 @@
|
|||||||
import { dirname, isAbsolute, join, resolve } from 'pathe'
|
import { dirname, isAbsolute, join, resolve } from 'pathe'
|
||||||
import type { Plugin } from 'rollup'
|
import type { Plugin } from 'rollup'
|
||||||
|
|
||||||
const PREFIX = 'virtual:'
|
const PREFIX = 'virtual:nuxt:'
|
||||||
|
|
||||||
export default function virtual (vfs: Record<string, string>): Plugin {
|
export default function virtual (vfs: Record<string, string>): Plugin {
|
||||||
const extensions = ['', '.ts', '.vue', '.mjs', '.cjs', '.js', '.json']
|
const extensions = ['', '.ts', '.vue', '.mjs', '.cjs', '.js', '.json']
|
||||||
@ -37,10 +37,12 @@ export default function virtual (vfs: Record<string, string>): Plugin {
|
|||||||
load (id) {
|
load (id) {
|
||||||
if (!id.startsWith(PREFIX)) { return null }
|
if (!id.startsWith(PREFIX)) { return null }
|
||||||
const idNoPrefix = id.slice(PREFIX.length)
|
const idNoPrefix = id.slice(PREFIX.length)
|
||||||
|
if (idNoPrefix in vfs) {
|
||||||
return {
|
return {
|
||||||
code: vfs[idNoPrefix],
|
code: vfs[idNoPrefix],
|
||||||
map: null
|
map: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user