Title: webpack: ENOENT on cached virtual modules when resolveId is skipped · Issue #618 · unjs/unplugin · GitHub
Open Graph Title: webpack: ENOENT on cached virtual modules when resolveId is skipped · Issue #618 · unjs/unplugin
X Title: webpack: ENOENT on cached virtual modules when resolveId is skipped · Issue #618 · unjs/unplugin
Description: Environment unplugin: latest (also present on current main) webpack: 5 Also seen with Next.js webpack (next dev) when the filesystem cache is enabled Reproduction On current main, this unit test fails with ENOENT on _virtual_~demo: pnpm ...
Open Graph Description: Environment unplugin: latest (also present on current main) webpack: 5 Also seen with Next.js webpack (next dev) when the filesystem cache is enabled Reproduction On current main, this unit test fa...
X Description: Environment unplugin: latest (also present on current main) webpack: 5 Also seen with Next.js webpack (next dev) when the filesystem cache is enabled Reproduction On current main, this unit test fa...
Opengraph URL: https://github.com/unjs/unplugin/issues/618
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"webpack: ENOENT on cached virtual modules when resolveId is skipped","articleBody":"### Environment\n\nunplugin: latest (also present on current main)\nwebpack: 5\nAlso seen with Next.js webpack (`next dev`) when the filesystem cache is enabled\n\n### Reproduction\n\nOn current main, this unit test fails with ENOENT on `_virtual_~demo`:\n\n```\npnpm exec vitest run test/unit-tests/webpack/virtual-cache.test.ts\n```\n\nThe case that fails fakes a skipped `resolveId` (a resolver already returns the `_virtual_` path). That is the same skip webpack does when it restores the path from its on-disk cache.\n\nA PR with that test and a fix is at https://github.com/unjs/unplugin/pull/617.\n\nThe on-disk cache path was reproduced by starting and stopping a Next.js webpack app with the filesystem cache enabled. After a restart, compile fails with ENOENT on `_virtual_…` until the placeholder is created again.\n\n### Describe the bug\n\nOn webpack, unplugin serves modules that are not real files by creating an empty placeholder in memory during `resolveId` and pointing the module at a made-up `_virtual_` path. The plugin's `load` hook supplies the real source.\n\nWebpack then stores that `_virtual_` path in its on-disk cache. The placeholder never reaches disk, so a new process starts without it.\n\nWhen the cache is reused, webpack already knows the path and skips `resolveId`. It then opens the path and fails with ENOENT.\n\nThis shows up after a `next dev` restart, or a CI or Vercel build that reuses `.next/cache`.\n\nI have a PR for this: https://github.com/unjs/unplugin/pull/617.\n\n### Additional context\n\nDownstream report: https://github.com/unplugin/unplugin-icons/issues/206\n\nSame family as https://github.com/unjs/unplugin/issues/32 (that issue used the older `virtual:~icons/…` path).\n\n### Logs\n\n```sh\nError: ENOENT: no such file or directory, open '/…/_virtual_~demo'\n```","author":{"url":"https://github.com/rosslh","@type":"Person","name":"rosslh"},"datePublished":"2026-09-22T15:47:19Z","url":"https://github.com/unjs/unplugin/issues/618"}
| 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:526eff77-6a52-cb88-f3a2-414fbf67fabf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8AFE:2C45C0:23CC37:325C32:6B006949 |
| html-safe-nonce | 7f55a80679604919e677059c55f4b00a7c2e5927c57270e66e764ba5e0c56eb4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUZFOjJDNDVDMDoyM0NDMzc6MzI1QzMyOjZCMDA2OTQ5IiwidmlzaXRvcl9pZCI6Ijc0NTg4NzMxNzk5Mzk4MjU5OTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 257e9b8a8242180b42af37ee9a2e6d44757c7580a6d17ae092eea712037e7d05 |
| hovercard-subject-tag | issue:5541900582 |
| 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/618/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a6e1257532de3c36a3ce0a59afe3a434a40da5ff2de491bf19dfcfa15525b39/unjs/unplugin/issues/618 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a6e1257532de3c36a3ce0a59afe3a434a40da5ff2de491bf19dfcfa15525b39/unjs/unplugin/issues/618 |
| og:image:alt | Environment unplugin: latest (also present on current main) webpack: 5 Also seen with Next.js webpack (next dev) when the filesystem cache is enabled Reproduction On current main, this unit test fa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rosslh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa |
| 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 | 46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width