Open
Description
Environment
- platform: windows 10
- nodejs: 18.19.1
- package manager: [email protected]
Reproduction
https://github.com/tmg0/unplugin
Describe the bug
When I try to load a virtual module with /
prefix on windows, id path has been converted from /
to \
, and this issue caused unplugin-vue-router
doesn't work with rspack and webpack
I have forked this repo and modify the test file in virtual-module
// test\fixtures\virtual-module\unplugin.js
const { createUnplugin } = require('unplugin')
module.exports = createUnplugin(() => {
return {
name: 'virtual-module-fixture',
resolveId(id) {
return id.startsWith('virtual/') ? `/__${id}` : null
},
loadInclude(id) {
return id.startsWith('/__virtual/')
},
load(id) {
if (id === '/__virtual/1')
return 'export default "VIRTUAL:ONE"'
else if (id === '/__virtual/2')
return 'export default "VIRTUAL:TWO"'
else
throw new Error(`Unexpected id: ${id}`)
},
}
})
Additional context
No response
Logs
throw new Error(`Unexpected id: ${id}`)
^
Error: Unexpected id: \__virtual\1
at Object.load (\unplugin\test\fixtures\virtual-module\unplugin.js:20:15)
at Object.load (\unplugin\dist\rspack\loaders\load.js:115:33)
at LOADER_EXECUTION (\unplugin\node_modules\.pnpm\@[email protected]_@[email protected]\node_modules\@rspack\core\dist\loader-runner\index.js:213:23)
at runSyncOrAsync (\unplugin\node_modules\.pnpm\@[email protected]_@[email protected]\node_modules\@rspack\core\dist\loader-runner\index.js:214:11)
at node:internal/util:441:7
at new Promise (<anonymous>)
at runSyncOrAsync (node:internal/util:427:12)
at runLoaders (\unplugin\node_modules\.pnpm\@[email protected]_@[email protected]\node_modules\@rspack\core\dist\loader-runner\index.js:695:28)
Node.js v18.19.1
node:internal/errors:865
const err = new Error(message);
^
Error: Command failed: npx rspack
at checkExecSyncError (node:child_process:890:11)
at execSync (node:child_process:962:15)
at run (\unplugin\scripts\buildFixtures.ts:37:33) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 9396,
stdout: null,
stderr: null
}
Node.js v18.19.1