Skip to content

Use async instantiateStreaming loading method #10

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

Merged

Conversation

phamann
Copy link
Contributor

@phamann phamann commented Jun 4, 2019

TL;DR

Refactors the createCompatibleModuleOutBundle function to return the more efficient and asynchronous streaming method to load WebAssembly modules in the browser, WebAssembly.instantiateStreaming.

Why?

Most browsers will not synchronously compile wasm modules that are greater than 4KB on the main thread. Therefore, this library doesn't work when using any larger assembly applications unless loaded inside a worker.

Both Mozilla and Google now advocate using the WebAssembly. instantiateStreaming() t compile and instantiate a modules directly from a streamed underlying source via fetch().

Notes

Interface:

Previously this function returned an Promise and not a function which returns a Promise, this differs between the inline variant which does return a promise generating function. Therefore, there wasn't consistency between to two return values. This is confusing for consumers as your documentation and examples in the readme assume that you must first invoke the returned function.

Therefore, I have refactored this method to also return a Promise generating function for consistency in your API. However, due to this, it should probably be releases as a major version as it's a breaking change.

Tests:

The repo's tests are currently in a broken state in master when cloning the repository from scratch and installing dependencies with yarn or npm. Therefore, I haven't been able to validate if the tests pass after this change. Any help fixing the underlying issue with the dependencies would be greatly appreciated. See #9 for more detail.

@happybang happybang merged commit c45f6a9 into SinaMFE:master Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants