https://github.com/oasislabs/wasm-sourcemap
Source Map Utility for WASM Buffers
https://github.com/oasislabs/wasm-sourcemap
sourcemap tooling wasm
Last synced: 3 months ago
JSON representation
Source Map Utility for WASM Buffers
- Host: GitHub
- URL: https://github.com/oasislabs/wasm-sourcemap
- Owner: oasislabs
- License: other
- Created: 2019-05-23T17:33:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T04:54:46.000Z (over 2 years ago)
- Last Synced: 2024-12-14T22:16:07.573Z (about 1 year ago)
- Topics: sourcemap, tooling, wasm
- Language: JavaScript
- Size: 66.4 KB
- Stars: 9
- Watchers: 25
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
WASM Sourcemaps
===
Sourcemaps provide a working path to step-through
debugging in WebAssembly code, but with a caveat:
The interface for execution of WebAssembly is
```javascript
WebAssembly.instantiate(bufferSource, importObject);
```
Where the module is provided as a byte buffer, divorced
from it's provinance, of where the source was loaded from.
As such, there's no way for relative source maps to be loaded,
since the browser cannot connect what such a URL is relative to.
This module allows runtime re-writing of the source code link
to address this annoyance.
Usage
---
```javascript
const wasmmap = require('wasm-sourcemap');
bufferSource = wasmmap.SetSourceMapURLRelativeTo(
bufferSource,
window.location.href);
```
API
---
* `GetSourceMapURL` returns the URL set as the sourcemap URL for a buffer, if set.
* `RemoveSourceMapURL` returns a stripped version of a WASM buffer stripped of its sourcemap URL section, if present.
* `SetSourceMapURL` returns an updated version of a WASM buffer with its sourcemap URL updated to a provided absolute URL.
* `SetSourceMapURLRelativeTo` returns an updated version of a WASM buffer with its sourcemap URL updated to an absolute URL relative to a provided URL.