Open ohana54 opened 8 months ago
Start a new pull request in StackBlitz Codeflow.
The package
functions-have-names
is used as a development dependency, but it is used in the source code, which is not downloaded, so a not found error is reported.
@RedJue I know, that's the reproduction case - I'm claiming that in this case (or a syntax error in a transitive dependency) vite crashes. Instead, I expect it to remain open and only show the error shown in your screenshot.
Describe the bug
When there is an error from
esbuild
during deps optimization, vite can crash with an unhandled rejection. The problem can be a missing transitive dependency, or a syntax error in a transitive dependency. From my debugging, I think it happens due to this promise's rejection not being handled: https://github.com/vitejs/vite/blob/4cedcdc99ca8ad38a67f46cf94dd3be65a567955/packages/vite/src/node/optimizer/optimizer.ts#L627In the reproduction case, I'm importing a dependency that imports another dependency which doesn't exist in node_modules. This causes an unhandled rejection due to the unhandled promise above.
Reproduction
https://stackblitz.com/edit/vitejs-vite-s2mweu?file=index.html
Steps to reproduce
vite dev
is run in the terminal, and index.html is opened in the preview framevite dev
crash in the terminalSystem Info
Used Package Manager
npm
Logs
No response
Validations