0

I am playing arounf trying to import wasm packages in my shadow-cljs project. It is bundled in a npm package, but i keep getting this error:

The required JS dependency "canvas" is not available, it was required by "canvas/core.cljs".

this is my project structure:

. <- root of the rust crate
├── canvas
│   ├── env
│   ├── node_modules
│   │   ├── ...
│   │   ├── canvas -> ../../pkg <- my local package
│   │   └── ...
│   ├── resources
│   ├── src
│   └── target
├── pkg <- my local package
├── src
├── target
└── tests

and this is my package.json (from the clojurescript project):

{
  "devDependencies": {
    "shadow-cljs": "^2.8.83"
  },
  "dependencies": {
    "canvas": "file:../pkg",
    "create-react-class": "^15.6.3",
    "react": "^16.4.0",
    "react-dom": "^16.4.0"
  }
}

I ran npm install and added the canvas module to my project like so (in core.cljs):

(ns canvas.core
  (:require
    ...
    ["canvas" :as canvas]))

What seems to be the problem here??

Le Marin
  • 135
  • 1
  • 12

1 Answers1

0

WebAssembly "bundling" is not supported by shadow-cljs.

Thomas Heller
  • 3,842
  • 1
  • 9
  • 9
  • 1
    I don't know. wasm-bindgen has now several different output types and they have evolved over time. Nothing in that area is standardized yet so it varies a lot. Each package is different and there is no standard answer. The problem isn't in the `.wasm` file, that works without issue. The issue is with the generated "glue" JS code that is required to actually use the wasm code. – Thomas Heller Jan 04 '20 at 10:47