shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
b4 2020-11-05T07:50:06.306200Z

is there anybody know how to find a clue of this error?

b4 2020-11-05T07:50:07.306300Z

1. npx create-cljs-project test-project 2. yarn add react react-dom 3. add reagent 1.0.0 into shadow-cljs.edn 4. shadow-cljs server error: [:failed-to-compare "16.13.0" "16.13.0" #error { :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null" :via [{:type java.lang.NullPointerException   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}] :trace [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14944 invoke "npm_deps.clj" 46]  [clojure.lang.Delay deref "Delay.java" 42]  [clojure.core$deref invokeStatic "core.clj" 2320]  [clojure.core$deref invoke "core.clj" 2306]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14946 invoke "npm_deps.clj" 52]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]  [shadow.cljs.devtools.server.npm_deps$main$fn__15031 invoke "npm_deps.clj" 223]  [clojure.core$complement$fn__5669 invoke "core.clj" 1441]  [clojure.core$filter$fn__5893 invoke "core.clj" 2821]  [clojure.lang.LazySeq sval "LazySeq.java" 42]  [clojure.lang.LazySeq seq "LazySeq.java" 51]  [clojure.lang.RT seq "RT.java" 535]  [clojure.core$seq__5402 invokeStatic "core.clj" 137]  [clojure.core$seq__5402 invoke "core.clj" 137]  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.core$apply invokeStatic "core.clj" 669]  [clojure.core$apply invoke "core.clj" 660]  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.core$apply invokeStatic "core.clj" 665]  [clojure.main$main_opt invokeStatic "main.clj" 514]  [clojure.main$main_opt invoke "main.clj" 510]  [clojure.main$main invokeStatic "main.clj" 664]  [clojure.main$main doInvoke "main.clj" 616]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.main main "main.java" 40]]}] [:failed-to-compare "16.13.0" "16.13.0" #error { :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null" :via [{:type java.lang.NullPointerException   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}] :trace [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14944 invoke "npm_deps.clj" 46]  [clojure.lang.Delay deref "Delay.java" 42]  [clojure.core$deref invokeStatic "core.clj" 2320]  [clojure.core$deref invoke "core.clj" 2306]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14946 invoke "npm_deps.clj" 52]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]  [shadow.cljs.devtools.server.npm_deps$main$fn__15031 invoke "npm_deps.clj" 223]  [clojure.core$complement$fn__5669 invoke "core.clj" 1441]  [clojure.core$filter$fn__5893 invoke "core.clj" 2821]  [clojure.lang.LazySeq sval "LazySeq.java" 42]  [clojure.lang.LazySeq seq "LazySeq.java" 51]  [clojure.lang.RT seq "RT.java" 535]  [clojure.core$seq__5402 invokeStatic "core.clj" 137]  [clojure.core$seq__5402 invoke "core.clj" 137]  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.core$apply invokeStatic "core.clj" 669]  [clojure.core$apply invoke "core.clj" 660]  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.core$apply invokeStatic "core.clj" 665]  [clojure.main$main_opt invokeStatic "main.clj" 514]  [clojure.main$main_opt invoke "main.clj" 510]  [clojure.main$main invokeStatic "main.clj" 664]  [clojure.main$main doInvoke "main.clj" 616]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.main main "main.java" 40]]}]

b4 2020-11-05T07:55:49.309Z

and i used shadow-cljs and i install & remove so many program even kernel .. after that it is not working anymore. im trying to find a reason. but dont have a clue.

thheller 2020-11-05T09:00:32.309500Z

@b4 which java -version do you use? and which shadow-cljs version?

b4 2020-11-05T09:01:33.309900Z

java version is openjdk 15.0.1 2020-10-20 OpenJDK Runtime Environment (build 15.0.1+9-18) OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

b4 2020-11-05T09:02:24.310500Z

shadow-cljs 2.11.7

thheller 2020-11-05T09:02:53.310900Z

do you use project.clj or deps.edn? or just shadow-cljs.edn?

b4 2020-11-05T09:03:03.311300Z

only deps.edn

thheller 2020-11-05T09:03:32.311600Z

and you have that shadow-cljs version in deps.edn?

b4 2020-11-05T09:04:15.312100Z

no.

b4 2020-11-05T09:09:03.313300Z

i found adding cljs-ajax into shadow-cljs.edn's dependencies is working but reagent and re-frame is not.

thheller 2020-11-05T09:10:27.313500Z

no means you don't use deps.edn right?

b4 2020-11-05T09:11:42.314800Z

ok. i have test two project. 1st is with deps.edn 2nd is make a project "npx create-cljs-project test-project" that is don't use deps.edn.

b4 2020-11-05T09:12:07.315500Z

both has same error.

thheller 2020-11-05T09:12:13.315700Z

I'm asking because jdk15 removed nashorn. so if you are not actually on the version you listed above that would cause the error.

thheller 2020-11-05T09:12:30.316100Z

ie. if you are on an older version. which version is listed when you start shadow-cljs?

b4 2020-11-05T09:15:39.317200Z

i can't find anything when i exec shadow-cljs server. could u tell me how can i check?

thheller 2020-11-05T09:16:03.317400Z

it is listed when you start it

thheller 2020-11-05T09:16:28.318Z

shadow-cljs server then it will print shadow-cljs - server version: &lt;version&gt; running at <http://localhost:9630> on startup

b4 2020-11-05T09:17:02.318300Z

shadow-cljs - HTTP server available at http://localhost:9999 shadow-cljs - server version: 2.9.10 running at http://localhost:9630 shadow-cljs - nREPL server started on port 9100

thheller 2020-11-05T09:17:25.318500Z

see that is an old version

thheller 2020-11-05T09:18:01.319200Z

do you maybe have an older shadow-cljs global install?

thheller 2020-11-05T09:18:10.319500Z

try npx shadow-cljs server or npm install -g shadow-cljs

b4 2020-11-05T09:23:10.320Z

it is working.!!! thanks very much.

b4 2020-11-05T09:25:14.320600Z

and thanks for ur shadow-cljs!

🦜 1
2020-11-05T13:08:50.323400Z

Does anybody know if there is a way to evaluate forms from the REPL in the context of a web-worker module? I have my main application loading my web-worker module (setup with :web-worker true in shadow-cljs), but the web-worker keeps some state in an atom that I don’t think I can access from the REPL currently?

2020-11-06T14:04:59.353Z

@victorbjelkholm429 yeah, that’s the other alternative. I have avoided that so far just because the postMessage boundary between the worker and the main thread keeps me honest (ha!), and gives a good indication of the general performance characteristics for the release build. I do something similar though when working on the worker from the REPL - I sometimes just load the namespace into the main thread, work on it in pieces in a REPL-driven way, then once I’m done saving the file updates the code in the worker context.

victorb 2020-11-05T13:33:23.323800Z

Just guessing now but my hunch is on "no", as web workers don't have access to any communication protocols/transports except "postMessage" from the web context. You would have to setup your own "proxiying" somehow (repl =&gt; web context =&gt; postMessage to worker, then back), but not sure how that'd work scratch that, was thinking of service workers, not web workers

victorb 2020-11-05T13:34:31.324Z

Alternatively, write your web-worker in a way that you can either run it embedded in the page or as a proper web worker, so in development you run it in the same scope as the web app itself, and you can use the repl normally. When you wanna release/deploy, make the embedded web worker into a proper one where you use postMessage to communicate

thheller 2020-11-05T13:44:08.325Z

@austinbirch you can REPL in the webworker just fine but no editor currently allows you selecting the runtime to eval in

thheller 2020-11-05T13:44:46.326Z

one way you can is using the UI. just tap&gt; something in the worker and it will show up in the web UI inspect

thheller 2020-11-05T13:44:53.326200Z

that has an eval window

2020-11-05T13:45:06.326400Z

Ah, right - that makes sense.

thheller 2020-11-05T13:46:07.327700Z

web workers can open websockets just fine which is the only things the shadow-cljs REPL needs

2020-11-05T13:48:36.330400Z

The actual problem I was having was that I’ve fallen into a more REPL-driven workflow, and that stopped working for the web worker. Not really a big deal though - I can just lean on the hot reloading and tap&gt; / js/console.log or whatever. Thanks for the help.

thheller 2020-11-05T13:49:11.330700Z

you can do the REPL workflow in web workers just fine

thheller 2020-11-05T13:49:44.331800Z

BUT when you open a website with code using a worker you'll have two completely separate runtimes

2020-11-05T13:49:48.332100Z

Not redefining functions etc from Cursive though? Ends up defining the functions in the ‘main thread’ rather than the web worker context?

thheller 2020-11-05T13:49:57.332500Z

one is the regular webpage and one is the worker. they don't share anything

2020-11-05T13:49:58.332700Z

Yeah, that’s it.

thheller 2020-11-05T13:50:09.333200Z

so when you eval stuff you need to "select" which runtime you actually want to work in

thheller 2020-11-05T13:50:27.333900Z

and that is unfortunately not supported by any editor at the moment so it is kind of clunky to do

2020-11-05T13:50:51.334400Z

That’s fine, I’d rather keep the REPL working for the regular webpage and just use reloading + tap&gt; for the worker context. It’s not that bad of a tradeoff, still a nice workflow.

2020-11-05T13:53:02.336300Z

If editors added support for selecting the runtime then I’d probably use that, but it’s not a huge problem.

sb 2020-11-05T13:56:28.339500Z

What is the best practice to use circleci with shadow-cljs? is there any example of config (shadow-cljs project > config.yml)? Thanks!

thheller 2020-11-05T14:04:06.344400Z

to do what exactly? you can just run the normal commands

victorb 2020-11-05T14:04:52.345500Z

@sb example config for a project I'm working on: https://github.com/instantwebsite/dashboard/blob/master/.circleci/config.yml (fairly trivial stuff though)

sb 2020-11-05T14:05:50.345900Z

thank you very much ! that is really cool example!!

👍 1
victorb 2020-11-05T14:06:11.346100Z

if you want the compiled output, just add another npx shadow-cljs compile step + archive_artifacts

👍 1
sb 2020-11-05T14:06:52.346400Z

I would like to learn from others how they create the .yml file etc (avoid fails, faster learning curve etc). Nothing extra

thheller 2020-11-05T14:09:22.346700Z

I also have it setup for shadow-cljs itself

thheller 2020-11-05T14:09:49.347200Z

although that first uses lein to do stuff since I can't use shadow-cljs only after I have built it so it should be an unconventional setup

2020-11-05T14:27:23.347500Z

> Just `tap>` something in the worker and it will show up in the web UI inspect > that has an eval window @thheller I’ve just used the Inspect UI for the first time… wow! This is so great! Thanks so much for your work on this, it’s really really helpful. Today has been a good developer tooling day for me; I’ve been trying out https://github.com/jpmonettas/flow-storm-debugger and it’s pretty smart, and now I’ve got Inspect to use as well.

👍 1
benny 2020-11-05T16:49:36.349300Z

after shadow’s dev server reloads my app, the dom appears to be reset to this:

&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;input type="text" name="history_state1" id="history_state1" style="display:none"&gt;&lt;/body&gt;&lt;/html&gt;
why isn’t it at a very minimum using the static html page i have for the react container?

thheller 2020-11-05T17:25:14.349500Z

this is not shadow-cljs doing that

thheller 2020-11-05T17:25:26.349800Z

something in your code (or libraries) is responsible for that

thheller 2020-11-05T17:26:18.350400Z

looks like you might be initializing goog.History multiple times. that does that IIRC.

benny 2020-11-05T18:36:00.350700Z

thank you so much! that was it