This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-18
Channels
- # announcements (12)
- # babashka (6)
- # beginners (62)
- # calva (3)
- # cider (41)
- # clerk (5)
- # clojure (192)
- # clojure-bay-area (1)
- # clojure-europe (14)
- # clojure-norway (97)
- # clojure-uk (6)
- # clojuredesign-podcast (4)
- # clojurescript (30)
- # code-reviews (7)
- # cursive (32)
- # datahike (4)
- # datomic (35)
- # docker (8)
- # emacs (8)
- # events (1)
- # fulcro (13)
- # helix (19)
- # hoplon (4)
- # hyperfiddle (37)
- # jobs-discuss (10)
- # membrane (11)
- # missionary (19)
- # off-topic (28)
- # polylith (8)
- # portal (10)
- # practicalli (8)
- # re-frame (31)
- # reitit (6)
- # shadow-cljs (39)
- # timbre (3)
- # vim (1)
- # xtdb (6)
I’m looking to use some NPM packages with Weird Shit™ in them (WASM and whatnot). Is there a good guide for configuring shadow + webpack to work together, including the webpack part (of which I have no previous experience)?
usually you want to follow the npm package guide on how to package them with webpack
also as I recently learned some packages just work with shadow-cljs, no webpack required
besides setting :js-provider :external
and knowing its not easy to reload npm deps when you do this, there isnt much needed for shadow to produce js files consumable by webpack
https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external: serves as a decent reference though
Totally understand that! This was more a question as to whether such an example or guide exists, not a demand to have all answers served on a platter 🙂 I need to look into https://automerge.org/, which has popped up previously I saw, and there are no easy answers with that one. However, I got basic webpack up and running (without Automerge), so that’s fine. What’s odd is that first compile works fine, and then when shadow recompiles, it can’t infer the types of some things it seems.
I’m guessing this might have something to do with the output of webpack, but why first compile works and recompile does not is kind of weird.
go
is pretty bad when it comes to inference and type hinting, so thats pretty common. try to move all code that does any kind of interop out of go
blocks
using webpack generally means that shadow-cljs is not processing the JS code, therefore has less information about potential externs
OK, that’s definitely good to know. Shadow has been forgiving with me up until webpack. It’s a wrapper around Auth0, so I might have to do some promise interop instead of returning channels then.
don't use core.async for promise interop, if that is the only use of core.async you have
https://clojureverse.org/t/promise-handling-in-cljs-using-js-await/8998 much less pain involved with this
No, not the only reason, it’s part of a larger async chunk of stuff happening. But I can move the border of core.async away from being that far into the Auth0 stuff, shouldn’t be a problem.
Btw, speaking of async stuff, I don’t know if you’ve played with virtual threads on the JVM yet, but I’m really impressed by it. They’ve more or less found a way around function coloring. I can’t think of a less intrusive async solution out there.
Alright, starting to see why this is hopeless now. I’d forgotten that I have dealt with WASM loading before, when writing a plugin for an editor. The methodology is to make module loads async, and basically have your own code be the last in a long chain of async loads.
You probaly know about it already but the promesa library can make this type of async waiting (e.g. for wasm module load) much saner. It is probably also possible to inline the wasm code to base64 (or ArrayBuffer definition) into your build so it doesn't have to wait for a network request.
Thanks @UUSQUGUF3! In this case, I don’t have control over the loading behaviour, since I’m not the one developing the library. And I do want to stay up-to-date with the lib if possible. Otherwise, indeed, I could control the loading of the WASM. I ended up compiling a different JS file for Automerge, put it in a different script tag, and then I await it being fully loaded before utilizing it. I delay loading the main app until AM is fully loaded, since I don’t want async code to infect every aspect of the app.
Hi! Regarding the dependency tree – the docs list either deps.edn / leiningen option – what can be used if the dependencies are listed directly in the shadow-cljs.edn
-file? Should I just move them to deps.edn and use the -Stree option or is there some command that can be used to see the deps tree in this case?
That worked perfectly. Thanks!
Has anyone ever experienced a chrome browser error when importing two separate things from a single javscript package and know how best to resolve?
react-dom.development Warning: Encountered two children with the same key, `AS`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
my imports are setup like so:
(:require
["libphonenumber-js" :refer [getExampleNumber parsePhoneNumber formatIncompletePhoneNumber]]
["libphonenumber-js/mobile/examples" :as exampleNumbers])
i think you are seeing an error from the runtime react as described here: https://sentry.io/answers/defining-proper-key-in-props/
ie, you have a collection of items and two of them have the same key so react is getting confused. it doesn’t have a good “name” for each item