-
-
Notifications
You must be signed in to change notification settings - Fork 27
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: Better prerender errors #107
Conversation
{ | ||
"type": "module" | ||
} |
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.
stack-trace
is ESM-only and I guess Vite (at least in the version we running in this repo) transpiles the config file down to the default module type, so we get a lovely require() of ES Module ...
import { promises as fs } from "node:fs"; | ||
|
||
import MagicString from "magic-string"; | ||
import { parse as htmlParse } from "node-html-parser"; | ||
import { SourceMapConsumer } from "source-map"; | ||
import { parse as StackTraceParse } from "stack-trace"; | ||
import { codeFrameColumns } from "@babel/code-frame"; |
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 was originally using simple-code-frame
, but Babel here comes for free as we're already using it for transpiling and whatnot.
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 babel's code frame also supports basic syntax highlighting which is pretty nice!
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.
Ah, well unfortunately that's not usable here. Not sure if it's Rollup or Vite, but the entire message is a flat red.
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.
Closes #106
Full example:
Certainly let me know if anyone wants to see more, less, etc.
The stack trace isn't super useful, but it comes from Rollup's
this.emit()
-- I don't think it's worth messing with.Unfortunately there's no way for us to clean up the source maps, and we need to enable them for all users running the prerender. Vite doesn't add them to the bundle, so we can't simply delete them, and it looks like they're written post
writeBundle()
, leaving us without much in the way of options to clean up after ourselves. Even if we could find a way, Vite would still likely include them in the output message which would be a bit wonky if they were then to not be there.