Fork me on GitHub
Lucy Wang00:05:06

The find there is a very easy to reproduce bug when using start-build/stop-build: 1. in a "yarn shadow-cljs clj-repl", run "(shadow/watch-set-autobuild! :app false)", then followed by "(shadow/watch-set-autobuild! :app true)" 2. now the cljs repl won't work anymore

missing cljs.user, repl not properly configured (must have analyzed cljs.user by now)                                                                       (1/8 results) [30/121]
ExceptionInfo: missing cljs.user, repl not properly configured (must have analyzed cljs.user by now)

Lucy Wang00:05:39

could be fixed by commenting out two lines:

--- a/src/main/shadow/cljs/devtools/server/worker/impl.clj
+++ b/src/main/shadow/cljs/devtools/server/worker/impl.clj
@@ -772,8 +772,8 @@
     ;; compile immediately, autobuild is then checked later
     (-> worker-state
         (assoc :autobuild true)
-        (build-configure)
-        (build-compile)
+        #_(build-configure)
+        #_(build-compile)


Could anyone share how they work with logging (for debugging) using shadowcljs on Node? js/console.log sucks to print clojure map I found reference to shadowcljs inspect, which seems nice, but I can't make it work any other suggestions?


unfortunately connecting devtools to Node.js doesn't support custom formatters 😞

Lucy Wang04:05:34

just call cljs.core.str(foo) manually 🙂

👍 4

Personally, I connect a REPL and put (def foo foo) inside fns I want to debug. then just repl.


basically the same flow as scope-capture on the jvm. I can’t figure out how to use it on node


also this lib is great for digging into js objs


although I’ve heard good things about cljs-bean as well


@U4YGF4NGM Are you sure? I could have sworn I’ve used it with node before.


I might be wrong, but I remember running into that at some point


would be happy to be shown wrong 😄


Thanks everyone


(to be more precise, shadowcljs inspect works in the repl, but not inside a test (deftest))


inspect just works based off tap> so it should work everywhere that the shadow.remote runtime runs. if you use :node-test that won't work currently since it immediately exits after running the tests.


When I make any changes in my app, shadow seems to rebuild the app (the build message is shown in the repl), but I see the following:

scheduler.development.js:108 Uncaught TypeError: lastCallbackNode is not a function
    at flushFirstCallback (scheduler.development.js:108)
    at flushWork (scheduler.development.js:220)
    at MessagePort.globalValue.port1.onmessage (scheduler.development.js:612)
in the console, and when I refresh the page, the app still seems to be in the older state. How do I fix this?

Lucy Wang05:05:54

looks like your own application's problem. What's the lib scheduler.js?


Hi! Is it possible that when I'm importing namespace like (ns (:require [imported.but.never.used])) shadow just removes this namespace? I have a macro in it that should run some code on first namespace load and it doesn't seem to be ever triggered.


@bear-z no shadow-cljs will never remove a require. relying on a macro side effect is a bad idea since the behavior will be different depending on many factors like parallel compilation and caching


I think I don't understand how require works. If in the namespace impored.but.never.used I have a js/console.log at the top level, should it fire when I require it for the first time?


require means that the runtime will ensure that the required namespace will be loaded before the namespace that required it


And when namespace is loaded then any code that is not wrapped in function should be executed right away?


@wxitb2017 please report reproducible bugs to the shadow-cljs github. reports just get lost in slack.


hi, I see this in logs after code is reloaded, but code reloaded just fine, I can see changes in the UI


ReactNative app


looks like an error from metro? did you disable every kind of reload provided by metro directly?


yes rn reload is disabled


I suspect metro might just be too eager in reading the file?


I mean starting to read the while it is still being written?


its a large file so might take a couple of ms to construct


mhm, yeah sounds reasonable, so its something related to metro not shadow, thanks, probably we shouldn't watch js changes because we don't use react native reload


the bundling failed message definitely isn't from shadow-cljs yes


@andre how do you like viz.js? I've been meaning to add a nice namespace dependency graph to the shadow-cljs UI but so far haven't found anything that is actually readable in larger projects. is viz.js useful or rather stay away?


@thheller he shared a screenshot of it in #re-frame


I saw. thats why I asked. 😉


I've never worked with such libs, so I looked a few, and kinda liked this one, because of simple API, lots of configurations if needed, dynamic nodes and edges, haven't had any issues with it, renders pretty fast and smooth, so for re-frisk it was a best fit , though I haven't tried other libraries, I'm totally fine with this one 🙂


I'm suddenly getting the error

The required namespace "" is not available, it was required by "cljs/util.cljc".
"clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?
For a bootstrap build. Is it possible to see where the cljs.util namespace is being brought in somehow?


you can create an dummy clojure/java/io.cljs in your source path with just (ns )


awesome thanks


After that I get

The required namespace ".File" is not available, it was required by "cljs/util.cljc".


which doesn't seem to be "cured" by creating a File.cljs (actually I tried, not Edit: ok tried both and neither works


blame CLJS, not much I can do about that

👍 4

hi, I'd like to bundle a node-script target including their dependencies into a single js-file (via :js-provider :shadow ). It's working, but I have to specify the entirety of the node standard library in :js-options :resolve to be already included, which doesn't seem to be the right way to go. Anything else I can do?


@ak407 I recommend just post-processing the file with something like without any :resolve config

Tim Smart23:05:10

How do you access process.env in a Node script? (:-env js/process) is returning nil for me.


ClojureScript 1.10.597
cljs.user=> (.-env js/process)
#object[Object [object Object]]
i think your interop is off. you want .- not :-


:-env is a keyword so invoking that is looking up in js/process for an entry at that keyword


and to be a bit more precise :-env is trying to look up something at that key, finding a non-associative object and returns nil.

Tim Smart23:05:41

Haha yes, was just about to report back that it should be .-env, thanks.

Tim Smart23:05:54

This leads to my next question… Is it possible to have a development only file (ignored in SCM) like secrets.edn, and then have a release version that uses (.-env js/process)?

Tim Smart23:05:59

secrets.edn example: {:api-key "asdfasdf1234"} Then in release build {:api-key (.. js/process -env -API_KEY)}

Tim Smart23:05:14

How would you do it? Can you have a development only source path? In node I would usually use dotenv

dpsutton23:05:47 are useful. At dev time you define a debug/development boolean and when that's set, read in dev-config.edn. otherwise use env or read prod-config.edn

👍 4