I'm trying to use this library for the first time, and it doesn't appear to work in a browser correctly (in an ESM webapp). My init code is very simple and taken from the docs:
import { SourceMapConsumer } from 'source-map';
SourceMapConsumer.initialize({
'lib/mappings.wasm': 'https://unpkg.com/source-map@0.7.3/lib/mappings.wasm',
});
But this has a type error:

Then I'm trying to apply a source map, basically like this:
await SourceMapConsumer.with(result.contents, null, (consumer) => {
positions.forEach((position) => {
console.log(consumer.originalPositionFor(position));
});
});
And I'm getting this in the browser console:
Uncaught (in promise) ReferenceError: __dirname is not defined
at read-wasm.js:34:34
at new Promise (<anonymous>)
at readWasm (read-wasm.js:33:12)
at wasm (wasm.js:25:16)
at source-map-consumer.js:247:14
at async _SourceMapConsumer.with (source-map-consumer.js:68:22)
at async Object.handleAddFiles [as onAddFiles] (App.tsx?t=1692066785254:100:9)
Looking at the code, I can see that this library thinks it's running in a Node environment, but it's clearly not, so maybe the environment detection code is not right?
I'm trying to use this library for the first time, and it doesn't appear to work in a browser correctly (in an ESM webapp). My init code is very simple and taken from the docs:
But this has a type error:
Then I'm trying to apply a source map, basically like this:
And I'm getting this in the browser console:
Looking at the code, I can see that this library thinks it's running in a Node environment, but it's clearly not, so maybe the environment detection code is not right?