thheller / thheller/shadow-cljs

loading web assembly files (.wasm)

Open
#397 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
2.4k
Forks
192
Avg merge
3h 11m
Merged PRs (30d)
1

Description

I saw a question on #clojurescript about this.

Maybe we want to load a Web Assembly module in cljs like this:

(ns my.example
  (:require ["./foo.wasm" as foo]))  ;; <-- hypothetical wasm loader needed

There is work happening to integrate wasm into the normal ecmascript module loading system via:

import "./foo.wasm";  // <-- (hypothetical static import)
import("./foo.wasm"); // <-- (hypothetical dynamic import)

In the meantime, cljs core will probably wait to load these until google closure does, but maybe shadow-cljs can add a loader that does the following (source):

  1. Get the .wasm bytes into a typed array or ArrayBuffer
  2. Compile the bytes into a WebAssembly.Module
  3. Instantiate the WebAssembly.Module with imports to get the callable exports

For reference—how folks are doing it in the webpack world:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked WebAssembly JavaScript API and compare webpack’s wasm-simple example with the third-party wasm-loader. Done means determining how the proposed ClojureScript require form can load .wasm bytes, compile and instantiate the module with imports, and expose callable exports.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, wasm
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.