Fork me on GitHub
#shadow-cljs
<
2020-05-03
>
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)
         )))

MatD02:05:28

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?

lilactown03:05:06

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

Lucy Wang04:05:34

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

👍 4
steveb8n05:05:05

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

steveb8n05:05:28

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

steveb8n05:05:34

also this lib is great for digging into js objs https://github.com/applied-science/js-interop

steveb8n05:05:57

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

knubie14:05:28

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

lilactown16:05:40

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

lilactown16:05:54

would be happy to be shown wrong 😄

MatD13:05:25

Thanks everyone

MatD02:05:05

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

thheller06:05:46

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.

Spaceman05:05:09

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?

sergey.shvets05:05:06

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.

thheller06:05:25

@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

sergey.shvets17:05:07

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?

thheller19:05:39

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

sergey.shvets23:05:39

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

thheller06:05:24

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

andre10:05:29

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

andre10:05:40

ReactNative app

thheller10:05:19

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

andre10:05:00

yes rn reload is disabled

thheller11:05:07

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

thheller11:05:17

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

thheller11:05:52

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

andre11:05:06

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

thheller11:05:58

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

thheller11:05:27

@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?

yenda12:05:51

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

thheller12:05:17

I saw. thats why I asked. 😉

andre12:05:27

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 🙂

jjttjj14:05:21

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?

thheller14:05:08

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

jjttjj14:05:51

awesome thanks

jjttjj14:05:03

After that I get

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

jjttjj14:05:17

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

thheller16:05:49

blame CLJS, not much I can do about that

👍 4
ak-coram16:05:31

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?

thheller19:05:47

@ak407 I recommend just post-processing the file with something like https://github.com/zeit/ncc 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.

dpsutton23:05:23

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

dpsutton23:05:54

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

dpsutton23:05:23

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

https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines 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