Fork me on GitHub
#shadow-cljs
<
2022-05-20
>
motform09:05:45

Is there a gotcha for using npm modules that call into wasm? I have added https://github.com/drbh/wasm-flate as a dependency and I can :require it, but the namespace just returns an empty js obj (ie #js {}), which predictably results in no actual functions to call. The https://drbh.github.io/wasm-flate/ mention the use of wasm bindgen to create the JS files needed, but it seems like that is also unnecessary when using the npm version`?

motform09:05:22

I guess either this is a specific problem with flate and you can disregard it or there is something I'm missing about working with wasm in shadow

thheller09:05:29

shadow-cljs does not support bundling wasm files

thheller09:05:42

depending on how the lib is used you may however just copy the wasm file manually and load it

thheller09:05:09

some js libs support this. can't say anything about this one in particular

motform10:05:03

OK, thanks! I'll see if I can do it manually then, or just use some pure js-equivalent.

p-himik16:05:12

Do you have any clue on what this warning means?

14 | (defn app-view []
------------^-------------------------------------------------------------------
 Receiver reference in function app.core.app_view changes meaning when namespace is collapsed.
 Consider annotating @nocollapse; however, other properties on the receiver may still be collapsed.
--------------------------------------------------------------------------------

thheller17:05:14

@p-himik hmm no clue. maybe you have app defined in externs somehow?

p-himik17:05:16

Oh, seems like just this is enough to reproduce it.

(defn f []
  (this-as this))

p-himik17:05:11

Gonna speculate a bit since I have no idea what's going on. GCC sees this ("receiver reference") while f belongs to app.core - it thinks that the value of this is expected to be an instance of app.core

thheller17:05:04

thats not valid. this would be undefined here?

thheller17:05:38

but yes that is the problem. can't use this-as on namespaced "vars"

p-himik17:05:38

> this would be undefined here? Not if you use .bind. :)

thheller17:05:07

hmm there is an annotation for this I believe (not @nocollapse though)

thheller17:05:56

what are you binding this to though?

p-himik17:05:06

It's just a random observation that I got curious about - not a serious attempt at something. E.g. adding this still results in the same warning:

((.bind f #js {}))