-
Notifications
You must be signed in to change notification settings - Fork 362
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
Non-async source map. #331
Comments
Fetching and compiling WebAssembly is inherently async. We could add a sync API to create a If so, I can help you craft a PR that implements this. |
I'm not sure. Does node require an async interface for wasm? For reference, I'd like to use source maps with screeps (0.6.x works). Their docs for wasm is here: http://docs.screeps.com/modules.html It doesn't seem to include anything async, but I've also not tested it yet. |
A sync API is also needed for e.g. stack traces, as they are collected synchronously (evanw/node-source-map-support#206). If we can initialize whatever needs to be async ahead of time, and have a sync way of constructing and using |
Sketch of what would need to happen:
|
What if |
I would prefer not to expose the wasm directly, since it is an implementation detail, and its interface may change. If we could wrap it up and hide the internals, then that could work. |
@loganfsmyth and I discussed this topic a couple weeks ago because a sync API is important for tools like babel. |
I think the upfront-delay approach would be potentially reasonable in my mind, but it is painful in some cases. I've wanted to explore doing that for The main issue for |
PostCSS needs sync source map support as well. We use source map in throwing errors. |
I think the best option would be to load the wasm into the library source directly instead of distributing it separately. This would be a fairly trivial build step and fix this entire issue. You would need to use the sync interface of WASM ( POC sync SourceMapConsumer https://github.com/devsnek/node-source-map-support/blob/master/source_map.js |
@devsnek The difficulty there is that is that the sync interface isn't guaranteed to work. Chrome for instance throws on anything beyond 4k: webpack/webpack#6475 (comment) While your approach will work on Node, it does not offer a solution for general usage. You're not wrong though, this would likely be the way to got on the Node side of things. On the browser side, I'm curious about compiling the WASM to ASMjs-style code, but I haven't had time to explore it. |
The |
@jdalton that's pretty cool. however after a certain point it might just not be worth using wasm anymore :( |
@jdalton can you elaborate? @loganfsmyth what do you think the current size is? CC @fitzgen I'm curious what you think? |
@jasonLaster I'm also not 100% clear on what @jdalton is suggesting. |
I was pointing to various WASM related packages written in JavaScript, like this, which maybe be bundleable and used to side-step limitations imposed on native implementations. |
Is there a different implementation that doesn't rely on WASM? I don't really care about extreme performance optimizations. I just want a simple straightforward library that can read a |
Version 0.6.1 has a conventional API and seems pretty usable. Are there any important features missing from that release? Maybe someone can fork 0.6.1 and maintain a separate version of this package without the WASM dependency. |
Why can't you keep using 0.6.1? |
0.6.1 was published over a year ago. Is it actively maintained? |
I noticed a couple other problems with the WebAssembly approach:
It totally makes sense to include a WebAssembly binary for people who need these speed optimizations. But it's difficult to understand why the JavaScript reference implementation was completely eliminated. @fitzgen Would the maintainers consider bringing back the JavaScript implementation and maintaining it alongside the Rust version? If not, maybe it's time to fork this project. This issue has been open for over a year now without resolution. Thanks! |
I can appreciate that it's an unexpected speed bump, but I do question how often users would realistically do that. WASM debugging in devtools is something that will improve over time I'm sure.
Since WASM runs in a sandbox, it doesn't really have access to anything to do anything anyway AFAIK. A worst all it could do is return the incorrect result.
I think maintaining parallel implementations would be a recipe for inconsistent behavior across the module. I have thought about setting up a build step that would compile the WASM into JS code in order to address the sync case. |
Is Or is the specification merely "whatever the |
#370 is a good reason. |
In my opinion, the current API, where constructors return a Promise, is a code-smell. It is idiomatic for a constructor to return an instance of the class, such that A better API is for the Usage in the browser and node can be async like this:
Usage in node can optionally be synchronous:
Constructor semantics will be simpler because they will no longer return promises. Additionally, in ECMAScript module environments -- browser, node, or otherwise -- the async initialization step can be performed via top-level await in the ESM entrypoint file. The entire module will |
|
Hello, was there anything done regarding this solution specifically for browsers ? I like the idea of pre-fetching the wasm and maps + caching, then carrying on from there synchronously. Edit:
not sure if this was obvious but works for me. |
@cspotcode can you elaborate? I only see async APIs in those two links. |
Actually it just works, though the docs all say async stuff. import smc from '@cspotcode/source-map'
const json = JSON.parse(mapContent) as smc.RawSourceMap
const sm = new smc.SourceMapConsumer(json) |
Any news about how to get sourcemap results asynchronously ? |
Is it possible to use the new Rust wasm lib-mapping without requiring support for async/await or futures, in general?
For context, I'm writing code in a context where all async operations are disallowed, which means that I'm stuck on 0.6.x of source-map. I was hoping to get the performance benefit of the wasm implementation but requiring async is a deal breaker.
The text was updated successfully, but these errors were encountered: