-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Synchronously importing wasm modules in the main chunk #6615
Comments
Yes, it is not implemented currently. But it is very much in the cards IIUC |
I've updated the issue title to specifically refer to the main check as @sendilkumarn points out that synchronous imports are supported in non-main chunks! |
is this fixed, i was able to build a |
I just bumped into this. |
@jjpe A lot of issue and plans, sorry, feel free to send a PR |
The priority should be on the WebAssembly<>JavaScript Module integration specificiation. In the initial chunk, synchronously loading the wasm module is complicated and not considered at the moment. Note that if you dynamicaly load a chunk, you can then use synchronous imports. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
So has it been fixed? How do we fix it? |
/cc @sendilkumarn |
wasm-simple seems solved this problem, but it doesn't work for me even I copied the template code entirely. Just saw " prefetching doesn't work for WASM yet" in #9802 as a known problem, will webpack-5 solve this problem? I'm trying to write a wasm based web-framework currently, and expecting this feature deadly 🦀 |
webpack 5 follows the updated wasm-esm-integration spec ( |
In case anyone finds this in the future and doesn't want to upgrade to Webpack 5, the solution I used is to just define an entry point that asynchronously loads the actual entry point. This makes the initial chunk ~empty and introduces another roundtrip for the initial page load, but if you're using webassembly in the initial page load anyway, there's no difference between doing this and asynchronously loading the wasm file from a main chunk. Webpack configuration of entry point: https://github.com/MaxBittker/sandspiel/blob/master/webpack.config.js#L11 |
I do confirm it does the job for me. |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Currently when a wasm module is imported like:
then
wepack
will report "Sync WebAssembly compilation is not yet implemented"If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
Both
import('./foo.wasm')
andimport { foo } from './foo.wasm';
to work. It looks like this is intentionally unimplemented though, so I was wondering if it'd be good to have a tracking issue for this feature? Or maybe such an issue already exists!If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
The text was updated successfully, but these errors were encountered: