-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Clear and concise description of the problem
Currently there doesn't seem to be a dedicated way to hook into compile errors such that you can stop all subsequent hmr updates until it's fixed.
I'm needing to do this because when using something like tailwindcss in JIT mode, since tailwind has it's own watcher, whenever I for example introduce a fatal error to a svelte component, the tailwind watcher will still update the css file, which clears the browser overlay error message immediately after it shows up.
There doesn't seem to be a way to easily enact a middleware right after errorMiddleware fires to stop future hmr updates.
Suggested solution
It would be nice if there was some hook like handleError or something that allowed someone to do respond to errors.
Additional context
RIght now the way I'm doing this is by adding a post middleware in configureServer with the copied code from error.ts, and in that adding a server.hasError = true property which I then respond to in handleHotUpdate like so
handleHotUpdate (context) {
if (context.server.hasError) {
context.server.hasError = false
return []
}
return context.modules
},You can see here that with tailwind JIT running (before adding my hotfix), the css file is updated immediately after my svelte file, blowing away the overlay error message in the browser.
