feat(ssr): better DX with sourcemaps, breakpoints, error messages#3928
feat(ssr): better DX with sourcemaps, breakpoints, error messages#3928aleclarson wants to merge 15 commits intovitejs:mainfrom
Conversation
..for better sourcemap support
The "vm" module uses filenames when possible (for breakpoint support), so we need to tolerate a falsy `rawSourceMap`. In other words, the `url` of each stack frame will be a file path instead of a Vite URL when using the "vm" module.
…in classes use the same constructor
This reverts commit 72b4bc5.
For some reason, sourcemap tracing with `columnOffset: 1` misbehaves, while updating the sourcemap manually does not.
c5544d9 to
10d959a
Compare
| await injectSourcesContent(map, mod.file, moduleGraph) | ||
| } | ||
|
|
||
| ssrModuleImpl += `\n` + convertSourceMap.fromObject(map).toComment() |
There was a problem hiding this comment.
The inline sourcemap is appended in both production and development, as new Function still handles sourcemaps somewhat, but vm.runInThisContext actually respects breakpoints.
| const { map } = result | ||
| if (map?.mappings) { | ||
| if (mod.file) { | ||
| await injectSourcesContent(map, mod.file, moduleGraph) |
There was a problem hiding this comment.
Honestly not sure if this call is needed in production. Someone needs to test with and without to see the difference (as it may affect stack traces?). Otherwise, in development, this ensures that changes to local modules will not appear while debugging an earlier version of a module.
|
Neat... I actually regularly run into problems with source maps. It'd be lovely to have this merged although I'm not sure who could review this? I'm thinking maybe we could merge this unreviewed @patak-js |
|
I think we still didn't get approval for this one, maybe it can be discussed in our next team meeting 👍🏼 |
How'd the team meeting go? |
|
@richarddavenport we couldn't get to this one, we'll try to review it in the next one |
|
Any update on a timeline for this being included? Is something still not working with it? |
|
@aleclarson would you clean up this one when you have some time? Looks like we never got to it at the end. |
|
any update here? would be great for this to go in |
|
I don't have the bandwidth to carry this forward. If someone wants to finish what I started, go right ahead :) |
|
Thanks Alec - this is becoming more and more of a need especially as Sveltekit gains popularity. Where can we help in getting this merged in? |
Description
This PR adds the following features to SSR only:
@babel/code-frameto show the snippet related to any error from instantiating a module.vm.runInThisContextfor breakpoint support.Additional context
Breakpoints may still be buggy in some cases, due to an issue with ESBuild (see here).
Fixes #3288
cc @brillout
Todo
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).