how is wasm support nowadays? I think I will try to get https://github.com/antelle/argon2-browser working. I installed it from npm and tried requiring it in cljs, but it looks like something can't even read the wasm magic header: {:line 1, :column 0, :message "Character '\0' (U+0000) is not a valid identifier start char"}
@kevin842 bundling wasm is not supported. you can still use wasm, just not bundle it
yeah, but I figured I would try to get it working like in https://github.com/thheller/wasm-pack-cljs
or is it still too far away to bother?
it all depends on the generated JS that comes with the .wasm file
some works fine out of the box. some will never work.
well, reading the generated JS doesn't seem that bad, being only ~600 lines prettified, but I wish there were better error messages to even see what's going on
https://unpkg.com/browse/argon2-browser@1.15.2/lib/argon2.js if thats it all the import
stuff needs to go
as well as the require stuff
the rest looks straightforward
ah nevermind that wasn't the generated file
hmm yeah the generated file looks much worse
how so? some of the code in there is for node.js, so maybe that's why.. but I am having trouble even figuring out what to look for, is there a resource?
I didn't write anything beyond the example repo I made
not aware of anyone else doing stuff with wasm
what doesn't work is any kind of JS that expects the bundler to provide the .wasm file
if there is a variant that uses fetch or xhr to load the .wasm file then this variant should be used
and you just copy the .wasm file somewhere and provide the path (assuming thats possible)
unfortunately the emscripten generated code is quite terrible and contains a lot of useless loading code
all this dynamic figuring out which runtime it is in needs to be removed
that's unfortunate.. you think the rust wasm toolchain is friendlier than emscripten?
last time I checked it generated better JS yes
its been a while since I looked at it though and it was completely different the time I checked before that
don't think the "standard" for this is any further along too
so no clue. I only follow casually
this one seems to work out of the box: https://github.com/Daninet/hash-wasm
I wonder what the difference is. anyway thanks for the help :)
So I’m trying to upgrade shadow-cljs from 2.8 to 2.11.5, and I’m having some problems. Specifically, my build compiles without errors, but my ‘core’ ns doesn’t get loaded when I open my app in a browser. Instead, I see the following error in the browser:
react_devtools_backend.js:2450 Failed to load foo/core.cljs SyntaxError: Unexpected identifier
at eval (<anonymous>)
at Object.goog.globalEval (base.js:577)
at Object.shadow$cljs$devtools$client$browser$script_eval [as script_eval] (browser.cljs:23)
at Object.shadow$cljs$devtools$client$browser$do_js_load [as do_js_load] (browser.cljs:35)
at eval (browser.cljs:56)
at eval (env.cljs:232)
at Object.shadow$cljs$devtools$client$env$do_js_reload_STAR_ [as do_js_reload_STAR_] (env.cljs:204)
at Function.eval [as cljs$core$IFn$_invoke$arity$4] (env.cljs:240)
at Object.shadow$cljs$devtools$client$browser$do_js_reload [as do_js_reload] (browser.cljs:48)
at eval (browser.cljs:92)
Any idea what might be causing this, or how I can fix it?Alright, good to know.
Any idea why it would break my code?
not a clue
okay 🙂
Okay I figured it out. I had a function marked as ^:export
, and it started working as soon as I removed that keyword. Has ^:export
been deprecated, or could there be something else going on?
…I assume that ^:export
is intended to work, considering that it’s mentioned in the documentation: https://shadow-cljs.github.io/docs/UsersGuide.html#_working_with_optimizations
:export
has not been changed. it works just like before.
I can't get shadow-cljs to bundle an npm library with a node-script target. I've installed the lib via npm, its in my packages.json, also added a deps.cljs:
{:npm-deps {"xmlhttprequest" "1.8.0"}}
it's required like this:
["xmlhttprequest" :refer [XMLHttpRequest]]
no complaints on compilation but get
Error: Cannot find module 'xmlhttprequest'
at runtime. What am i missing?@afhammad node builds don't bundle their dependencies by default since node can just load them from node_modules
directly. so either just include the node_modules
whereever you are running it or post process the file with something like https://github.com/vercel/ncc
got it, thanks
is is possible to target specific node_modules dependencies to be compiled with :advanced? like:js-provider :closure but for specific modules, not the whole app