This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-30
Channels
- # aleph (25)
- # announcements (20)
- # babashka (29)
- # babashka-sci-dev (12)
- # beginners (27)
- # biff (3)
- # clojure (29)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojurescript (3)
- # clr (5)
- # code-reviews (4)
- # data-science (7)
- # datahike (6)
- # datascript (3)
- # emacs (9)
- # fulcro (5)
- # graalvm (10)
- # malli (15)
- # nbb (7)
- # off-topic (17)
- # pathom (9)
- # polylith (4)
- # practicalli (15)
- # reitit (3)
- # releases (2)
- # rum (1)
- # shadow-cljs (73)
- # squint (34)
- # tools-deps (3)
- # xtdb (11)
I'm currently migrating to shadow-cljs (from using cljsbuild directly for prod, lein-figwheel for dev) and have some issues with promises that I handle through <p!
. I require core.async like this:
[cljs.core.async :as async :refer [go >! <!]]
[cljs.core.async.interop :refer [<p!]]
and work with promises like this (heavily abridged)
(let [p+ (.readFile ^js (.-promises ^js FS) dict-path)]
(try (go (let [p (<!p p+)] ...))
(catch default e (println e)))
which prints the error
TypeError: aa.setTimeout is not a function
so it feels like I'm missing externs for core.async? any ideas? /cc @thhellerhard to say. core.async does not require externs. what is the full stacktrace? not sure where setTimeout
is used? and which build :target
is this?
build target is browser, though that could be it - this is the main process script for an electron app
would nodejs be more suitable?
I don't know. electron has a bunch of different contexts. not all have the regular JS primitives like setTimeout
available
this is a release build. it used to run with a vanilla cljs.build build, so I feel browser should work as a target?
try running the build with npx shadow-cljs release app --pseudo-names
to figure out what the aa
is supposed to be
ah, scratch that, we used :target :nodejs
should this be :node-script then?
no, this is for the main process, not renderer
ok, will try that
I think it worked 🎉 thanks so much
one more thing (well, I'm sure there will be more)... some externs aren't inferred, but also don't complain on compilation
what could cause that?
we often pass in js objs (e.g. node Path) as args, could this be the culprit?
I can't say. need actual code examples. there are a billion things you could be doing
(defmethod integrant/init-key :app.system/x [_ system]
(let [{:keys [App]} system]
(.setAsDefaultProtocolClient App "foo")
e.g. this did not warn about App
ok, will dig deeper
what’s the simplest way to compile some cljs snippet from the clojure repl? Or asked differently, could I call cljs.analyzer.api/emit
and cljs.analyzer.api/analyze
and with what state/env args so it knows symbols from my running shadow build?
(I’ve used shadow.cljs.devtools.api/cljs-eval
but I only want the js code, not the result)
after that there is a :repl-state
key in the build state, which contains a bunch of :repl-actions
basically all of those need to happen before the last repl/process-input
can be eval'd
can I also use the running shadow watch and compile a string as if came in the end of my file?
I mean in theory yes, but none of the targets have the necessary hooks or functionality to do that
and there’s no cljs.analyzer.api/analyze
compatible state/env available either with shadow, is that right?
so for Clerk’s render functions are currently quoted form that are evaluated through sci
like https://github.com/nextjournal/clerk/blob/626ea1e8c07359c3996d63cfd5fff6e34dc0989b/src/nextjournal/clerk/viewer.cljc#L703 or sometimes just symbols like https://github.com/nextjournal/clerk/blob/626ea1e8c07359c3996d63cfd5fff6e34dc0989b/src/nextjournal/clerk/viewer.cljc#L714
@mkvlr if the quoted form is known at compile time, why do you even quote it and not just compile it as regular cljs?
seems like that's a recurring problem, but.. trying to use @openfin/excel - and getting the following problem:
WARN:
shadow-cljs - failed to load module$node_modules$$openfin$excel$openfin_excel
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
eval @ app.excel.js:2
goog.globalEval @ main.js:566
env.evalLoad @ main.js:1659
(anonymous) @ main.js:2574
main.js:1661 An error occurred when loading app.excel.js
env.evalLoad @ main.js:1661
(anonymous) @ main.js:2574
ReferenceError: fin is not defined
at shadow$provide.module$node_modules$$openfin$excel$openfin_excel (:3900/js/cljs-runtime/module$node_modules$$openfin$excel$openfin_excel.js:17:34)
at shadow.js.jsRequire (:3900/js/cljs-runtime/shadow.js.js:34:18)
at shadow.js.require (:3900/js/cljs-runtime/shadow.js.js:59:20)
at eval (:3900/js/cljs-runtime/app.excel.js:2:64)
at eval (<anonymous>)
at goog.globalEval (main.js:566:21)
at env.evalLoad (main.js:1659:12)
at main.js:2574:12
using shadow-cljs 2.11.5
tried changing https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider and https://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules
any ideas?sorry never used that lib. don't know what fin
is supposed to be. looks to be expecting to be running in excel? but looks like you are running this in a browser?
it's excel adapter - translating JS to some .net API i think.
it's present when you run with the openfin container - but this happens when loading code that simply requires the dependency (invocation is wrapped in an (exists? js/fin)
check - so it never gets called).
solved the issue by splitting modules (so i can isolate those dependencies which require special runtime) - and including that from a HTML script element - when needed. potentially could have done shadow-cljs https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_module_import? but using target :browser
so will just stick with this approach.
cheers!
I have a question about avoiding these kind of errors:
throw new Error('Namespace "' + name + '" already declared.');
I'm basically trying to use ViteJS and ShadowCLJS together but the hot reloading of Vite wants to recall goog.provide
for everything when my ShadowCLJS ESM modules changes.
I found an https://github.com/minimal-xyz/minimal-shadow-cljs-webpack/blob/master/lib/page.js#L1-L5 that might workaround the issue, but I wanted to check with anyone if that seems correct, or if there is a better way to avoid calling all of the goog.provide
functions again. Thanks in advance 🙏
I don't recommend using the vite reloading together with shadow-cljs. it is very likely to break everything. why not just let shadow-cljs reload its code?
the already declared exception you can get rid of by basically replacing goog.provide
as done here https://github.com/thheller/shadow-cljs/blob/0275661910fd356ae3312e834ef76546a42777d6/src/main/shadow/cljs/devtools/client/env.cljs#L152-L161
Well I'm trying to hot reload custom JS components with Vite but ignore the Shadow-CLJS ESM module somehow and just let Shadow handle that. But that's tricky because Vite sees the shadow module changing and triggers a recall of those provide functions. Is there a reason to not always override goog.provide?
Hey there, I have two builds, each with an http dev server defined. But they both appear to launch, even when I'm only launching one build:
{:test {:target :browser-test
...
:devtools {:http-port 8021 ...}}
:dev {:target :browser
...
:devtools {:http-port 8022 ...}}}
Only launching :dev
:
$ clojure -M:cljs/dev:cljs/client watch dev
shadow-cljs - HTTP server available at
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.20.2 running at
shadow-cljs - nREPL server started on port 60050
shadow-cljs - watching build :dev
[:dev] Configuring build.
[:dev] Compiling ...
[:dev] Build completed. (512 files, 0 compiled, 0 warnings, 4.21s)
Am I doing something wrong?http servers are not build related and the config in the build config has been deprecated for 5+ years now. use https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http instead