wasm2map icon indicating copy to clipboard operation
wasm2map copied to clipboard

Add new API to get source paths used by the generated sourcemap

Open mtolmacs opened this issue 1 year ago • 0 comments

Background

When the browser can't find the source file in the sourcesContent field (i.e. it's null), it tries to load it from the same base url it downloaded the sourcemap from.

Currently only the sourcemap JSON can be extracted from the lib via its public API. However having access to the list of sources on the implementor side can be used to dynamically serve the files when requested by the browser.

API

Add new instance method to WASM with the following signature

pub fn get_sources(&self) -> Vec<String> {}

Note: The returned Vec not necessarily contains valid paths, so the String type is chosen here. It should be the responsibility of the implementor to resolve these fragments to actual file paths.

Success

  • The proposed new method can be called on a WASM instance
  • There is at least one test case covering this new method

mtolmacs avatar Apr 19 '23 10:04 mtolmacs