vitejs / vite

Next generation frontend tooling. It's fast!
http://vitejs.dev
MIT License
67.43k stars 6.07k forks source link

virtual file system is broken in v6 #18223

Open himself65 opened 3 hours ago

himself65 commented 3 hours ago

Describe the bug

import { createServer } from 'vite'

const server = await createServer({
  plugins: [
    {
      name: 'virtual-fs',
      resolveId (id) {
        if (id === 'my-virtual-file') {
          return id + '.js'
        }
      },
      load (id) {
        if (id === 'my-virtual-file.js') {
          return 'export default "Hello, world!"'
        }
      }
    }
  ]
})

console.log(await server.ssrLoadModule('my-virtual-file.js'))

await server.close()

This is working in v5, but broken in v6.

Reproduction

https://stackblitz.com/edit/stackblitz-starters-prwdrf?file=index.js

Steps to reproduce

No response

System Info

N/A

Used Package Manager

npm

Logs

No response

Validations

stackblitz[bot] commented 3 hours ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.