-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(qwik): customize error overlay #2818
Conversation
|
@@ -115,7 +115,8 @@ | |||
], | |||
"devDependencies": { | |||
"@builder.io/qwik-dom": "2.1.19", | |||
"kleur": "4.1.5" | |||
"kleur": "4.1.5", | |||
"strip-ansi": "7.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used on vite to strip the the frame output on the error overlay. since we have the code included atm, we need the lib as well
@@ -194,6 +194,9 @@ export function ssrDevMiddleware(ctx: BuildContext, server: ViteDevServer) { | |||
|
|||
next(); | |||
} catch (e) { | |||
if (res.writableEnded) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've extended the qwik
dev server middleware to handle errors as well instead of forwarding it to the vite error middleware. this because we are otherwise unable to ship the needed CSS to modify the overlay on SSR errors. The new error handler terminates the response with an .end()
call. After that point it does no longer make sense to follow the next(e)
path at all because an header already sent
error would occur.
import { yellow, magenta, cyan } from 'kleur/colors'; | ||
import strip from 'strip-ansi'; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think about creating another PR on the vite repo to have an option to pass in some custom markdown into the vite error handler so we can remove the whole logic again on our side.
} | ||
|
||
vite-error-overlay::part(tip):before { | ||
content: "Not sure how to solve this? Visit https://qwik.builder.io or connect with the community on Discord."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just an idea. please let me know what u think about it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah if this works! i think it's ok!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does but w/o a link 😄 and can't style the url
THIS IS AMAZING!! love it, this will deserve a good tweet when we merge it |
great job @zanettin ! Looks much more readable BTW, for errors, I'd love to see the color "red" because it makes it easier to see that it's an error, immediately Plus, not sure if it's possible, but syntax highlighting would also be great, but that's not a much |
I dont think code highlighting is an easy thing to add, i would not block this PR for that, we never had it before, but i would say, i would like to see the code with a more vibrant color, the yellow for vite was cooler. |
My only take would be to add a little bit of color, the red @shairez suggested would be nice and some other |
thanks a lot @manucorporat and @shairez for your feedbacks 🙏 the concern @shairez mentioned was about the terminal output which would stay unaffected by now. regarding the formatting/highlighting: yes we are limited as long as we'd like to keep the vite error overlay web component since the error is rendered within a |
@manucorporat @shairez here are some other variations 👨🎨 😄 B1B2B3C1 |
thanks @zanettin ! I prefer B2 |
I think it's OK not to have the error message with the branded blue color, because it's an error after all :) Maybe the icons could be with that blue or something, but it's not a biggie IMO |
totally with u @shairez 🙏 let me try some variations tomorrow evening 👍 |
I think it looks great. I personally prefer not having the error message header as red and reserving the red color for highlighting the actual error in the code, like this. Giant red text just makes me feel like I'm being yelled at. I would bet that it stresses out beginners as well. Just my two cents. 👍 |
but you ARE being yelled at @nnelgxorz !! 😅😂 |
Love it, and like the idea of less red and more qwik-ish colors. But think we ship it and see how it feels and iterate. |
thanks for all the feedbacks 🙏 set the current state of this PR to the B1 version. hope that is a good starting point. if you have other wishes/requirements, pls let me know 🙏 |
B1 is cool! |
What is it?
Description
Qwikify the vite dev server error overlay. Fixes #2710.
Current Version
PR state after review session
Terminal output (stays unaffected)
Info
Todos
4.2.0
of vite which includes the changes from aboveFollow-ups
Checklist: