Crates.io | wasm2map |
lib.rs | wasm2map |
version | 0.1.0 |
source | src |
created_at | 2023-04-19 12:42:21.061942 |
updated_at | 2023-04-19 12:42:21.061942 |
description | Generates source map for .wasm file with DWARF debug info embedded as source map. |
homepage | https://github.com/mtolmacs/wasm2map |
repository | https://github.com/mtolmacs/wasm2map |
max_upload_size | |
id | 843519 |
size | 32,243 |
Generates a browser-supported sourcemap for WASM binaries containing DWARF debug information and associates it with the WASM binary, so when loaded in the browser you can see the rust line, character and source code (if available) in the debug panel and console.
NOTE: Can build without unsafe code (the only unsafe code is related to using the memmap2 crate).
cargo install cargo-wasm2map
# Build your WASM binary the way you usually do
cargo build --target wasm32-unknown-unknown
# Generate sourcemap for the target WASM (replace myproject with your project
# name).
cargo wasm2map target/wasm32-unknown-unknown/debug/myproject.wasm \
-patch -base-url http://localhost:8080
# Serve the WASM to your browser... (i.e. http://localhost:8080 or wherever
# your index.html is)
use wasm2map::WASM;
let mapper = WASM::load("/path/to/the/file.wasm");
if let Ok(mut mapper) = mapper {
let sourcemap = mapper.map_v3();
mapper.patch("http://localhost:8080").expect("Failed to patch");
}
Your contributions are welcome, especially bug reports and testing on various platforms. Feel free to open a PR if you can contribute a fix.
If you would like to contribute an API change, extension or a new trait implementation, please open an issue first and discuss before starting work on a PR. For details please read the CONTRIBUTING.md file.
Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
SPDX-License-Identifier: Apache-2.0 OR MIT