wasm-pack icon indicating copy to clipboard operation
wasm-pack copied to clipboard

Source map support?

Open KSXGitHub opened this issue 4 years ago • 6 comments

I use wasm-pack to compile wasm. I am not aware if wasm-bindgen or rustc have sourcemap support because I do not use them directly so I apologize if this is not the right place to ask.

As far as I am aware, emscripten have source map support, as demonstrated in https://github.com/KSXGitHub/wasm-source-map-emscripten.

KSXGitHub avatar Apr 03 '20 02:04 KSXGitHub

I'm also interested.

Docs say:

Therefore, debuggers currently provide limited utility, and we end up stepping through raw WebAssembly instructions emitted by the compiler, rather than the Rust source text we authored.

But I don't see why source-maps wouldn't work, givent that they work for emscripten.

irfanka avatar Jun 24 '20 16:06 irfanka

+1 this.

leonhma avatar Sep 23 '22 13:09 leonhma

+1

J-Cake avatar Nov 11 '23 23:11 J-Cake

It looks like DWARF debugging might be a more interesting approach? Here is another issue about how to make it easier accessible: https://github.com/rustwasm/wasm-pack/issues/1351

Looks like wasm-bindgen already supports it (but I didn't test it yet).

haraldreingruber avatar Dec 05 '23 14:12 haraldreingruber

It looks like DWARF debugging might be a more interesting approach? Here is another issue about how to make it easier accessible: #1351

Looks like wasm-bindgen already supports it (but I didn't test it yet).

@haraldreingruber I tried going this route and was still just stepping through assembly code. Any chance you ever got this worked out, it's incredibly frustrating to try and develop with effectively trial and error. From what I can tell you can't even console log to debug from the WASM module.

eHildy avatar Feb 08 '24 19:02 eHildy

I will try to test it, and let you know how successful I was.

From what I can tell you can't even console log to debug from the WASM module.

Check out the crate console_log. We use it for logging from WASM to the browser console. https://crates.io/crates/console_log

If you use the code on other platforms as well you just have to install another implementation for the log facade crate for that platform: https://docs.rs/log/latest/log/#available-logging-implementations For example, we use simplelog on Windows.