-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
esbuild generates different sourcemaps from ts-node in coverage reports #870
Comments
It's true that esbuild and TypeScript don't generate identical source maps. That's not a bug though, that's just because they do slightly different things. For example, esbuild doesn't put source mappings at the end of identifiers, only at the start, because they aren't relevant for stack traces and removing them makes the generated source map smaller. You have just said they are different but you haven't said why that matters to you. For example, why not log a bug with ts-node saying their source maps are different than esbuild? Is there something specific about esbuild's source map output that is incorrect? I have a source map debugging tool here: http://evanw.github.io/source-map-visualization/. If you can point to an incorrect source mapping in esbuild, then that's something I can fix. |
Thanks for your quick response. The source maps that esbuild generates are working well enough for my debugging. I'm not suggesting esbuild's sourcemap is buggy or something. What I intended to inform is esbuild+c8 generated an obviously incorrent coverage report like this: I'm not familiar to coverage reports and I don't know if the incorrectness was caused by esbuild. If not, I will close this issue. Also a lot thanks for your debugging tool. I will investigate on it with my example. |
Ah, I see. For debugging you only need mappings at the start of I guess the problem is that whatever program you're using to generate that visualization is looking up into the source map at the |
I just checked the source maps of another popular JavaScript transformation toolchain ( This happens to work with the TypeScript compiler because TypeScript happens to preserve all tokens in their AST. I'm not totally sure why they do this but I believe this is somewhat unusual. Most JavaScript tools follow the ESTree AST specification in which |
One thing I can do is generate a source mapping at the start of blocks (so before the |
Closing for the reason described above. I don't believe esbuild is doing anything incorrect or unusual here, and it seems like the issue is with the visualization tool you're using instead. |
I know this may be a complex issue.
ts-node
I used
ts-node/register/transpile-only
.esbuild
I used a register script written by myself: https://github.com/koishijs/koishi/blob/next/build/register.ts
The text was updated successfully, but these errors were encountered: