trunk-rs / trunk

Build, bundle & ship your Rust WASM application to the web.
https://trunkrs.dev/
Apache License 2.0
3.43k stars 251 forks source link

Proposal: Generating source map files for WASM files #851

Open Mforcen opened 1 month ago

Mforcen commented 1 month ago

I believe that having a proper way to track down stack traces into Rust code in browser DevTools. I've found this tool that generates a .map file that the browser can use to match js and wasm to rust code: https://github.com/mtolmacs/wasm2map. This tool can be used as a library or a CLI tool.

Proposal

Embed wasm2map in trunk, and adding a new step that generates the .map file to allow the browser devtools to correlate stacktrace addresses with rust source code file and lines.

ctron commented 2 weeks ago

Yes, that would be awesome!

Mforcen commented 2 weeks ago

Great! I will start working on this.

Best regards!

Mforcen commented 1 week ago

After some investigation, I've discovered that there is a pending feature in walrus that would allow wasm-bindgen to generate binaries while keeping the debug information up to date.

I'll try to start working on this first.

Best regards.