unjs / unplugin

Unified plugin system for Vite, Rollup, Webpack, esbuild, Rolldown, and more
https://unplugin.unjs.io
MIT License
3.02k stars 109 forks source link

Webpack 5 build errors with persistent/disk cache #32

Open Akryum opened 2 years ago

Akryum commented 2 years ago

Reproduction link: https://github.com/Akryum/unplugin-icons-issue-94

  1. Build a webpack 5 project with persistent caching -> Success
  2. Build again -> Success
  3. Build again -> Error

The build crashes with errors - examples:

 error  in ./virtual:~icons/feather/smile

Syntax Error: no such file or directory, open '/home/akryum/Projects/livestorm-app/packages/frontend/virtual:~icons/feather/smile'

 error  in ./virtual:~icons/feather/x-circle

Syntax Error: no such file or directory, open '/home/akryum/Projects/livestorm-app/packages/frontend/virtual:~icons/feather/x-circle'

 error  in ./virtual:~icons/feather/x

Syntax Error: no such file or directory, open '/home/akryum/Projects/livestorm-app/packages/frontend/virtual:~icons/feather/x'

Related to https://github.com/antfu/unplugin-icons/issues/94

Akryum commented 2 years ago

Commenting the load part of the unplugin plugin (here) makes the error go away. So the issue is probably related to load.

Akryum commented 2 years ago

So when the error happens, resolveId is not called and then plugin.__vfsModules doesn't have the virtual module so it fails.

Akryum commented 2 years ago

Maybe related to https://github.com/sysgears/webpack-virtual-modules/issues/76

Akryum commented 2 years ago

Looks like there is an open PR: https://github.com/sysgears/webpack-virtual-modules/pull/128

yunsii commented 1 year ago

https://github.com/sysgears/webpack-virtual-modules/pull/164 It looks like fixed with webpack-virtual-modules@v0.5.0 but I still got the error with vercel build: image

adarshmadrecha commented 1 year ago

Since the upstream issue is resolved, we can close this issue?