Search code examples
npmclojurescriptwasm-bindgenshadow-cljs

unable to import local wasm npm package in shadow-cljs project


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??


Solution

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