Closed mansona closed 1 year ago
Thanks.
Can we please try to match the output of the pure rust examples? For example, run cargo run ./sample/has_error.js
and you'll see that it produces a codeframe pointing at the syntax error:
swc is already tracking squrcemap-like details that enable it to produce this output. If we can just capture those and attach them to the exception, we'd be able to match the pretty output even from JS.
So it turns out this was surprisingly difficult 🙈 I don't know if it's just a result of the API that SWC has for its errors but I had to do some Rust jujitsu that was a bit outside of my confort zone to get this to work 🙃
I "stole" the implementation of the "error to string" functionality from https://github.com/swc-project/swc/blob/e4f9f734ad1f92c6f05e8cb4c2d799679cca9f79/crates/swc_error_reporters/tests/fixture.rs so I hope it's ok.
Also worth noting that I wasn't able to match the CLI version output exactly no matter what I did 🤔 I tried different handlers with different GraphicalTheme
s but nothing seemed to work. I settled for one that was as close as I could get 👍
fixes #1