-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't appear to work in an ESM browser environment #496
Comments
This should be fixed in v0.7.4. |
@eemeli That's the version I'm already using. |
According to the code snippet you've included above, you're using v0.7.3. |
Oh, you're referring to the mappings URL. I copied that from the npm docs, so I guess those need to be updated. But I have 0.7.4 of the library installed:
Even if I fix the URL, I still see the same problems. |
Ah, sorry, I misunderstood your error earlier. The code is currently shipped in two formats:
To use it in a browser's <script type="module">
import "/path/to/your/source-map/dist/source-map.js";
sourceMap.SourceMapConsumer.initialize({
"lib/mappings.wasm": "/path/to/your/source-map/lib/mappings.wasm"
});
</script> That works because the IIFE sets |
No, this still isn't working. This is what I added to my index.html:
The import works, but the next statement doesn't, and I get this in my browser console:
If I try to access
If I try similar code in my app code, I get the same kinds of errors. |
I ended up copying this snippet of code from the npm page (adjusted to reference 0.7.4 instead):
This seems to load/init the library correctly in my webapp. This is less than ideal though, because I'd like to bundle all dependencies with my app, and not have it go off and fetch something from the Internet every time its loaded. I also apparently have to reference |
I think for further help you may need to describe the exact steps to replicate the error you're seeing. For me, if I run the following commands in a shell on a unix-y machine: cd /tmp/
npm i --no-save source-map
cd node_modules Then create in <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script type="module">
import "./source-map/dist/source-map.js";
sourceMap.SourceMapConsumer.initialize({
"lib/mappings.wasm": "./source-map/lib/mappings.wasm",
});
console.log(sourceMap);
</script>
</head>
<body></body>
</html> and then run in that directory python -m http.server 8000 I can open a browser at Please repeat those steps, and see if that works for you? Note in particular that the paths start with |
Yes, those steps work for me. But when I try the same thing in a Vite dev server, I get the errors as described above. |
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?
The text was updated successfully, but these errors were encountered: