Title: webpack / rspack load virtual module id with `/` prefix on windows caused error · Issue #421 · unjs/unplugin · GitHub
Open Graph Title: webpack / rspack load virtual module id with `/` prefix on windows caused error · Issue #421 · unjs/unplugin
X Title: webpack / rspack load virtual module id with `/` prefix on windows caused error · Issue #421 · unjs/unplugin
Description: Environment platform: windows 10 nodejs: 18.19.1 package manager: pnpm@9.11.0 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 / ...
Open Graph Description: Environment platform: windows 10 nodejs: 18.19.1 package manager: pnpm@9.11.0 Reproduction https://github.com/tmg0/unplugin Describe the bug When I try to load a virtual module with / prefix on win...
X Description: Environment platform: windows 10 nodejs: 18.19.1 package manager: pnpm@9.11.0 Reproduction https://github.com/tmg0/unplugin Describe the bug When I try to load a virtual module with / prefix on win...
Opengraph URL: https://github.com/unjs/unplugin/issues/421
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"webpack / rspack load virtual module id with `/` prefix on windows caused error","articleBody":"### Environment\n\n- platform: windows 10\r\n- nodejs: 18.19.1\r\n- package manager: pnpm@9.11.0\n\n### Reproduction\n\nhttps://github.com/tmg0/unplugin\n\n### Describe the bug\n\nWhen 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\r\n\r\nI have forked this repo and modify the test file in `virtual-module`\r\n\r\n```ts\r\n// test\\fixtures\\virtual-module\\unplugin.js\r\nconst { createUnplugin } = require('unplugin')\r\n\r\nmodule.exports = createUnplugin(() => {\r\n return {\r\n name: 'virtual-module-fixture',\r\n resolveId(id) {\r\n return id.startsWith('virtual/') ? `/__${id}` : null\r\n },\r\n loadInclude(id) {\r\n return id.startsWith('/__virtual/')\r\n },\r\n load(id) {\r\n if (id === '/__virtual/1')\r\n return 'export default \"VIRTUAL:ONE\"'\r\n\r\n else if (id === '/__virtual/2')\r\n return 'export default \"VIRTUAL:TWO\"'\r\n\r\n else\r\n throw new Error(`Unexpected id: ${id}`)\r\n },\r\n }\r\n})\r\n```\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```sh\nthrow new Error(`Unexpected id: ${id}`)\r\n ^\r\n\r\nError: Unexpected id: \\__virtual\\1\r\n at Object.load (\\unplugin\\test\\fixtures\\virtual-module\\unplugin.js:20:15)\r\n at Object.load (\\unplugin\\dist\\rspack\\loaders\\load.js:115:33)\r\n at LOADER_EXECUTION (\\unplugin\\node_modules\\.pnpm\\@rspack+core@1.0.0-rc.1_@swc+helpers@0.5.12\\node_modules\\@rspack\\core\\dist\\loader-runner\\index.js:213:23)\r\n at runSyncOrAsync (\\unplugin\\node_modules\\.pnpm\\@rspack+core@1.0.0-rc.1_@swc+helpers@0.5.12\\node_modules\\@rspack\\core\\dist\\loader-runner\\index.js:214:11)\r\n at node:internal/util:441:7\r\n at new Promise (\u003canonymous>)\r\n at runSyncOrAsync (node:internal/util:427:12)\r\n at runLoaders (\\unplugin\\node_modules\\.pnpm\\@rspack+core@1.0.0-rc.1_@swc+helpers@0.5.12\\node_modules\\@rspack\\core\\dist\\loader-runner\\index.js:695:28)\r\n\r\nNode.js v18.19.1\r\nnode:internal/errors:865\r\n const err = new Error(message);\r\n ^\r\n\r\nError: Command failed: npx rspack\r\n at checkExecSyncError (node:child_process:890:11)\r\n at execSync (node:child_process:962:15)\r\n at run (\\unplugin\\scripts\\buildFixtures.ts:37:33) {\r\n status: 1,\r\n signal: null,\r\n output: [ null, null, null ],\r\n pid: 9396,\r\n stdout: null,\r\n stderr: null\r\n}\r\n\r\nNode.js v18.19.1\n```\n","author":{"url":"https://github.com/tmg0","@type":"Person","name":"tmg0"},"datePublished":"2024-09-23T07:43:07Z","url":"https://github.com/unjs/unplugin/issues/421"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ef577c04-27b8-85df-f157-8b54d0a8f540 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D216:2714DE:2E0C018:3EA661E:6B005943 |
| html-safe-nonce | ff78447b1a45809c681856cafbfd3922976fc9d6839eed254f092764e49293ff |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjE2OjI3MTRERToyRTBDMDE4OjNFQTY2MUU6NkIwMDU5NDMiLCJ2aXNpdG9yX2lkIjoiMzc2NzIxODI1MjA4Njc5NDU2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cad1afc9ce0111be8ec061cc4c810181745c17ac5e4c8243c0b87c142b833a13 |
| hovercard-subject-tag | issue:2541828728 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/unjs/unplugin/421/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a99f0e42e4cac23fae0a04c9e18c4fdf3a3b6d65d5fd72cad9093b6ec11ce83e/unjs/unplugin/issues/421 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a99f0e42e4cac23fae0a04c9e18c4fdf3a3b6d65d5fd72cad9093b6ec11ce83e/unjs/unplugin/issues/421 |
| og:image:alt | Environment platform: windows 10 nodejs: 18.19.1 package manager: pnpm@9.11.0 Reproduction https://github.com/tmg0/unplugin Describe the bug When I try to load a virtual module with / prefix on win... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tmg0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73 |
| turbo-cache-control | no-preview |
| go-import | github.com/unjs/unplugin git https://github.com/unjs/unplugin.git |
| octolytics-dimension-user_id | 80154025 |
| octolytics-dimension-user_login | unjs |
| octolytics-dimension-repository_id | 385261169 |
| octolytics-dimension-repository_nwo | unjs/unplugin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 385261169 |
| octolytics-dimension-repository_network_root_nwo | unjs/unplugin |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | eacd927ba6112e3b01ba99c762bd699a4a4f5df7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width