Fork me on GitHub
#shadow-cljs
<
2020-08-11
>
nivekuil06:08:59

I somehow got shadow-cljs into a state where running shadow-cljs release raises a NPE. My CIDER repl hot reloading is also broken. known bug?

nivekuil18:08:58

I don't think I have anything fancy going on. I think CIDER just runs the default command, shadow-cljs server. I think this may have been a race condition from hot reload + release at the same time, but anyway it went away after a restart

steveb8n08:08:40

Q: I’ve reached the stage where using tap> and the inspector would be really helpful. I’m using 2.8.94. Should it be working in the browser app? I can’t see any runtimes even though I have a nodejs server running. and when I (tap> []) from the cljs repl, nothing happens

steveb8n08:08:02

I seem to remember it’s been disabled but I just want to ask

thheller09:08:30

@steveb8n that version is too old for inspect. it is enabled by default in newer versions.

steveb8n09:08:00

ok great. I can update and try it. Thanks. looking forward to using it

steveb8n09:08:22

btw: I agree with @mail985 shadow rocks!

steveb8n09:08:10

inspect working now. thx!

Jack Arrington11:08:15

Following examples to make a testing namespace and shadow is telling me node-test is an invalid target:

Target "node-test" for build :test was not found. The built-in targets are:
  - :browser
  - :browser-test
  - :node-script
  - :node-library
  - :npm-module
  - :karma
  - :bootstrap
Should I just be using node-script?

thheller11:08:39

:target :node-test? should exist unless you are on an ancient version

Jack Arrington12:08:46

I just installed a few minutes ago

Jack Arrington12:08:32

Looking like I am running v 2.10.21

Jack Arrington12:08:47

I think it's a problem with my namespace directories actually - error seems to be coming from https://github.com/thheller/shadow-cljs/blob/bfdda1d472198a8f352468eafc2a1080e855b747/src/main/shadow/cljs/devtools/errors.clj#L82. Looks like it's just an outdated error message 🙂.

bendlas12:08:09

I'm trying to run shadow watch for :node-script on a different (docker) host, than node app.js. :devtools-url "" yields remote-error Error: Unexpected server response: 200. What's the best way to do this?

thheller13:08:10

@mail985 looks like you might be using :target node-test. note that it must be a keyword, otherwise it'll look for (ns node-test) which indeed does not exist.

thheller13:08:41

@bendlas assuming that calling actually results in the shadow-cljs UI that should be fine? did you verify that the http connect actually works?

bendlas23:08:33

@U05224H0W it turns out, it does that, when a stale app.js tries to connect during shadow's boot up (docker volume, for sharing build results). removing app.js (and waiting for it to be re-generated) before connecting node, fixed it. thanks!

pcj15:08:32

Is it currently possible to add a dependency while shadow watch is running? If not, are there any barriers for that feature to be added? I can take a look at it 🙂

thheller15:08:34

not possible currently and not trivial to add given that it must be supported via shadow-cljs.edn, project.clj and deps.edn. I may add a shadow-cljs.edn solution some day but it is low priority. restarting occasionally is not that bad.

pcj16:08:22

Thanks for the quick response! Yeah, doing some research over the past week it doesn't look trivial 😞

thheller16:08:43

yeah manipulating the classloader at runtime is full of footguns. its easy for just .cljs files but macros and other resources is where it gets tricky

mauricio.szabo20:08:49

Hi, there's a thing with Shadow-CLJS that I really don't understand, that's almost reproducible all time. On my project: https://github.com/mauricioszabo/repl-tooling, if I try to watch :integration target, most of the time I get the following error:

File: /home/mauricio/.atom/packages/chlorine/repl-tooling/test/repl_tooling/repl_client/textual_representation_test.cljs:18:3
--------------------------------------------------------------------------------
  15 |       render/txt-for-result))
  16 | 
  17 | (cards/deftest evaluate-to-text
  18 |   (async-with-clj-repl "text repr"
---------^----------------------------------------------------------------------
Encountered error when macroexpanding cljs.core/aset.
StackOverflowError: 
        cljs.analyzer/compiler-options (analyzer.cljc:168)
        cljs.analyzer/checked-arrays (analyzer.cljc:178)
        cljs.analyzer/checked-arrays (analyzer.cljc:174)
        cljs.core/aset (core.cljc:1043)
        cljs.core/aset (core.cljc:1041)
        clojure.core/apply (core.clj:669)
      ....big stacktrace

mauricio.szabo20:08:15

I just need to open this file and save it once, then it compiles fine.

thheller20:08:52

the file looks rather macro heavy and no clue what they do. might expand to a bazillion forms for all I know 😛

mauricio.szabo21:08:35

Right you are, but not that heavier than other test files that don't cause trouble 😄

mauricio.szabo21:08:55

That's what's been on my mind for a while 😄

neural21:08:38

Hello all! need some help on :optimizations. I am working on an app using shadow/reagent/expo/react-native and the app works fine upon shadow-cljs release with :optimizations :simple but with :optimizations :advanced it looses some symbols names from google closure optimizations.

(defn root []
  (let [this (r/current-component)
        open-drawer  #(this.refs.drawer.openDrawer)]
     ....
The reference for this.refs.drawer.openDrawer is lost on advanced optimization. Some thoughts on how to circunvent this??

royalaid02:08:33

This is a pretty common problem and there are a lot of options. https://github.com/appliedsciencestudio/js-interop is my favorite, https://github.com/mfikes/cljs-bean/ is another option people seem to like. Going a bit more extreme there is https://github.com/binaryage/cljs-oops which was built specifically to address this problem. Finally you can drop down into https://clojureverse.org/t/cljs-hidden-google-closure-library-gems/2321/2

royalaid02:08:36

The point is that "dot access" breaks because the variable names change on advanced optimization and your CLJS code doesn't

thheller08:08:04

(defn root []
  (let [^js this (r/current-component)
        open-drawer  #(.. this -refs -drawer -openDrawer)]

thheller08:08:14

this should be all you need. don't need a library or anything. if you have externs inference turned on you should be getting a warning https://shadow-cljs.github.io/docs/UsersGuide.html#externs

thheller09:08:11

@U0S3YK6HK using those libraries to fix externs issues is pretty much an anti-pattern these days and should not be used for that

royalaid15:08:25

TIL, thanks!

neural19:08:10

@U05224H0W tks! that works! TIL !!