无法在 shadow-cljs 项目中导入本地的 wasm npm 包。

huangapple go评论69阅读模式
英文:

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

问题

我正在尝试在我的shadow-cljs项目中导入wasm包,它被捆绑在一个npm包中,但我一直遇到这个错误:

所需的JS依赖项 "canvas" 不可用,它是由 "canvas/core.cljs" 所需的。

这是我的项目结构:

. <- rust包的根目录
├── canvas
│   ├── env
│   ├── node_modules
│   │   ├── ...
│   │   ├── canvas -> ../../pkg <- 我的本地包
│   │   └── ...
│   ├── resources
│   ├── src
│   └── target
├── pkg <- 我的本地包
├── src
├── target
└── tests

这是我的package.json(来自ClojureScript项目):

{
  "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"
  }
}

我运行了 npm install 并在我的项目中像这样添加了canvas模块(在core.cljs中):

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

这里似乎有什么问题?

英文:

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 &quot;canvas&quot; is not available, it was required by &quot;canvas/core.cljs&quot;.

this is my project structure:

. &lt;- root of the rust crate
├── canvas
│&#160;&#160; ├── env
│&#160;&#160; ├── node_modules
│&#160;&#160; │&#160;&#160; ├── ...
│&#160;&#160; │&#160;&#160; ├── canvas -&gt; ../../pkg &lt;- my local package
│&#160;&#160; │&#160;&#160; └── ...
│&#160;&#160; ├── resources
│&#160;&#160; ├── src
│&#160;&#160; └── target
├── pkg &lt;- my local package
├── src
├── target
└── tests

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

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

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

(ns canvas.core
  (:require
    ...
    [&quot;canvas&quot; :as canvas]))

What seems to be the problem here??

答案1

得分: 0

WebAssembly "bundling"不受shadow-cljs支持。

英文:

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

huangapple
  • 本文由 发表于 2020年1月3日 23:27:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/59581167.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定