Skip to content

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