Skip to content

Browser support + marginally smaller modules #1

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
merged 3 commits into from
May 28, 2025

Conversation

CountBleck
Copy link
Member

Browsers don't have Buffer, but we can use fetch with data URIs with WebAssembly.instantiateStreaming.

One caveat: AssemblyScript supports Node v18+, but WebAssembly.instantiateStreaming was added in v18.1.0. This means AssemblyScript would have to bump its engines.node to be >=18.1.0, which is a breaking change but not a particularly impactful one. We can also just bump it to >=20 since Node v18 has reached end-of-life.

This is just a small micro-optimization using converge and inline.always
to remove a few bytes off of the final .wasm size. Sadly, we can't use
"shrinkLevel": 3 since that gives imprecise results.
This confused me for a couple minutes when testing out "shrinkLevel": 3.
Browsers don't have Node.js's Buffer, nor do they have any reasonable
way to decode base64. Luckily, `WebAssembly.instantiateStreaming` allows
using the results of `fetch`, which in turn can accept base64 data URIs.
@CountBleck CountBleck requested a review from HerrCai0907 May 28, 2025 18:09
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.

2 participants