Skip to content
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

wasm-only modules #858

Open
SebastienGllmt opened this issue Dec 6, 2024 · 0 comments
Open

wasm-only modules #858

SebastienGllmt opened this issue Dec 6, 2024 · 0 comments

Comments

@SebastienGllmt
Copy link

SebastienGllmt commented Dec 6, 2024

Previously, when using Deno with WASM, you had to create a JS file that would instantiate your WASM module

const wasmInstance = WebAssembly.instantiateStreaming(fetch("./add.wasm"));

However, as of Deno 2.1, this is no longer necessary and you can just import wasm directly while still getting proper type checking: import { add } from "./add.wasm";

Given this, I feel for a lot of WASM packages that are Deno-first, there is no need to include JS/Typescript at all in some cases. Currently you still need JS glue for non-numeric types (see this issue on what will happen with wasm-bindgen: rustwasm/wasm-bindgen#4287), but not sure how this will evolve over time

This fits a bit weird with the jsr narrative of Made for TypeScript & ESM if we're now packaging JSR projects that are just a single .wasm file as the export (or a wasm file and minimal JS glue). However, I feel like Deno definitely won't be only tool to support these kind of wasm-only packages, so I feel there needs to be a natural way to publish these

Is there though for best practices for this kind of WASM-only project? And perhaps JSR will need some additional functionality to generate information around these packages like it does for ESM ones

I added a related issue for this in the wasm-pack repo here: rustwasm/wasm-pack#1454

Some additional thoughts

One of the biggest issues with using WASM packages historically is that tree-shaking is non-existent on the JS/WASM side of things. That is to say, if you have 2 WASM packages that (on the Rust side) depended on the same tool, there is no de-duplication which can lead to very large bundle sizes. Solving this is not entirely in the scope of JSR, but it's something people need to be aware of when it comes to publishing WASM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Triage
Development

No branches or pull requests

1 participant