vite icon indicating copy to clipboard operation
vite copied to clipboard

feat(hmr): add `runtimeErrors` option

Open btea opened this issue 4 months ago • 7 comments

Description

refer to https://github.com/webpack/webpack-dev-server/pull/4773

Some runtime errors generally do not appear, and adding this option can help users find some subtle code problems.

After adding this option, an error message will appear in the pop-up window on the page.

image

btea avatar Aug 01 '25 02:08 btea

I think this is related to #2076 and #6274. I agree with the discussions in https://github.com/vitejs/vite/pull/6274#issuecomment-1087749460 and think that a toast is better here.

sapphi-red avatar Aug 08 '25 01:08 sapphi-red

Oh, I hadn't noticed that. Are we going to move forward with that?

btea avatar Aug 08 '25 01:08 btea

@btea We discussed about this feature in the team meeting. We agreed to the following points:

  • it would be nice to have this feature built in
  • the UI should be either toast style (https://github.com/vitejs/vite/pull/6274#issuecomment-1087749460) or Next.js style (below, clicking the button shows the overlay) , whichever easier to implement and less invasive if possible
  • we are not sure about the options yet and will discuss later, but that wouldn't block the implementation as adding an option later isn't difficult
  • for a richer overlay, we probably want to delegate to Vite devtools, and want to keep the built-in one simple
image

sapphi-red avatar Oct 29 '25 13:10 sapphi-red

Okay, thank you for your clear explanation. Will we continue with #6274?

btea avatar Oct 30 '25 09:10 btea

It is fine either.

sapphi-red avatar Oct 30 '25 13:10 sapphi-red

Based on the above suggestions, a basic implementation has been created.

Do you think the current solution is feasible? And regarding the error messages, do we need to perform detailed conversion processing according to #6274?

btea avatar Oct 31 '25 10:10 btea

I think it would be nice to have the sourcemap support for the runtime error like #6274 has. While #6274 processes the sourcemap mapping on the client side, I think we should do in on the Vite server side so that we don't have to send many data to the browser.

sapphi-red avatar Nov 15 '25 07:11 sapphi-red