Fork me on GitHub
#shadow-cljs
<
2018-03-27
>
mhuebert12:03:47

Hmm, running shadow@latest with [com.google.javascript/closure-compiler-unshaded "v20180101"] (to avoid that nasty bug, https://github.com/google/closure-compiler/issues/2822) I am getting:

[:browser] Compiling ...
[2018-03-27 14:51:57 - WARNING] Skipping pass rewriteScriptsToEs6Modules
[2018-03-27 14:52:05 - WARNING] failed to handle server msg: {:type :start-autobuild}
java.lang.NoSuchFieldError: STRICT_MISSING_PROPERTIES
        at cljs.closure__init.load(Unknown Source)
        at cljs.closure__init.<clinit>(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at clojure.lang.RT.classForName(RT.java:2204)
        at clojure.lang.RT.classForName(RT.java:2213)
        at clojure.lang.RT.loadClassForName(RT.java:2232)
        at clojure.lang.RT.load(RT.java:450)
        at clojure.lang.RT.load(RT.java:426)
        at clojure.core$load$fn__6548.invoke(core.clj:6046)
        at clojure.core$load.invokeStatic(core.clj:6045)
        at clojure.core$load.doInvoke(core.clj:6029)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5848)
        at clojure.core$load_one.invoke(core.clj:5843)
        at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
        at clojure.core$load_lib.invokeStatic(core.clj:5887)
        at clojure.core$load_lib.doInvoke(core.clj:5868)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:659)
        at clojure.core$load_libs.invokeStatic(core.clj:5925)
        at clojure.core$load_libs.doInvoke(core.clj:5909)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:659)
        at clojure.core$require.invokeStatic(core.clj:5947)
        at clojure.core$require.doInvoke(core.clj:5947)
        at clojure.lang.RestFn.invoke(RestFn.java:2088)
        at cljs.repl$loading__5569__auto____6019.invoke(repl.cljc:9)

mhuebert12:03:50

maybe shadow now depends on a more recent closure version?

mhuebert12:03:43

or maybe it’s the latest cljs… i’ll try 2.2.18

mhuebert13:03:28

so 2.1.18 builds with the old closure. makes sense..

mhuebert13:03:21

now, trying out using devtools.api/watch:

Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http)
        at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:103)
        at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:103)
        at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:27)
        at shadow.cljs.devtools.server.supervisor$start_worker.invoke(supervisor.clj:18)
        at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:85)
        at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:76)
        at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:102)
        at shadow.cljs.devtools.api$watch.invoke(api.clj:88)
        at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:92)
        at shadow.cljs.devtools.api$watch.invoke(api.clj:88)
        at web3.build.build$watch.invokeStatic(build.clj:57)
        at web3.build.build$watch.invoke(build.clj:49)
        at web3.build.build$watch.invokeStatic(build.clj:52)
        at web3.build.build$watch.invoke(build.clj:49)

mhuebert13:03:12

oh, that was only added in 2.1.19

mhuebert13:03:23

attempted to add [org.clojure/clojurescript "1.10.145" :exclusions [com.google.javascript/closure-compiler-unshaded]], but then I get the java.lang.NoSuchFieldError: STRICT_MISSING_PROPERTIES error again

thheller13:03:34

@mhuebert the problem unfortunately is in cljs.closure. why are you pinning a specific closure version again?

mhuebert13:03:13

i was trying to get the new :shadow/requires-server thing without the latest clojure version

thheller13:03:32

why though?

mhuebert13:03:07

yes exactly

thheller13:03:34

hmm yeah I had hoped closure would release a new version by now

thheller13:03:19

and remove the problematic fields in (def warning-types ...)

thheller13:03:45

could also apply this patch

thheller13:03:23

I think I should probably add the "hack" I had for this previously

thheller13:03:44

we don't actually use cljs.closure at all .. problem is that cljs.repl imports it though

mhuebert13:03:52

what an annoying thing to keep in sync

thheller13:03:29

yeah with my patch that should get better

thheller13:03:26

the closure people probably don't expect anyone to use the static fields directly

thheller13:03:50

let me just add the hacked version again. this really shouldn't break so easily

thheller13:03:15

@mhuebert try [email protected]. should use the latest cljs version and hopefully let you use the closure v20180101

4
mhuebert14:03:57

now i can try the new watch stuff

mhuebert15:03:19

works great

mhuebert15:03:12

I really like this setup. Now I have a single watch command which first compiles the necessary static assets (hiccup->html, garden->css) and then starts the shadow watch process

sleepyfox17:03:23

I am encountering the Error: Could not find or load main class clojure.main error when following the doco, there's obviously something that I've missed

sleepyfox17:03:28

I have a hello world app with the following shadow-cljs.edn:

{:source-paths ["src"]
 :dependencies []
 :builds {:server    {:target    :node-script
                      :main      server.main/main!
                      :output-to "target/main.js"}}}

sleepyfox17:03:11

and a file ./src/server/main.cljs

(ns server.main

(defn main! [& cli-args]
    (prn "hello world"))

sleepyfox17:03:26

Any help appreciated

sleepyfox17:03:35

I am invoking shadow-cljs compile server, and shadow-cljs -v returns: shadow-cljs - config: /var/app/shadow-cljs.edn version: 2.2.20

sleepyfox17:03:32

java -version shows openjdk version "1.8.0_141"

thheller17:03:24

@sleepyfox can you paste the output of npx shadow-cljs clj-repl? the error looks like there is no clojure on the classpath which is very weird

sleepyfox17:03:35

exactly the same error:

shadow-cljs - config: /var/app/shadow-cljs.edn version: 2.2.20
shadow-cljs - starting ...
Error: Could not find or load main class clojure.main

thheller17:03:02

hmm so strange

sleepyfox17:03:05

shadow-cljs was installed using npm install -g shadow-cljs

thheller17:03:44

delete .shadow-cljs/classpath.edn and try the above again?

sleepyfox17:03:46

this is a node v9.9.0 environment

sleepyfox17:03:32

ah, now appears to be doing something useful

sleepyfox17:03:40

downloading the internets

thheller17:03:54

shadow-cljs --cli-info should also print some useful info

sleepyfox17:03:23

missing paren

sleepyfox17:03:32

compiling again...

sleepyfox17:03:01

OK, success. Thanks very much. Might consider adding that little trick to the doco

thheller17:03:25

missing paren?

sleepyfox17:03:41

No, the delete .shadow-cljs/classpath.edn part

thheller17:03:13

this should never be necessary. I don't know how you ended up there.

sleepyfox17:03:23

Me neither 😕

sleepyfox17:03:44

But... computers. And PEBKAC

sleepyfox17:03:00

Thanks anyway.

thheller17:03:27

if it happens again please post the output of shadow-cljs --cli-info (before deleting anything)

sleepyfox17:03:33

If it happens again I'll capture the info you requested.

thheller17:03:46

thanks. the above is how it should look.

sleepyfox18:03:37

I suspect it was something to do with the environment, I've been creating a Docker image to try this stuff out in and it's possible an older jvm or node vm may have been causing an issue.

mitchelkuijpers18:03:37

shadow-cljs -d org.clojure/tools.nrepl:0.2.13 -d cider/cider-nrepl:0.17.0-SNAPSHOT server
the -d options does not seem to work when :lein true is enabled is this expected?

thheller18:03:13

oh. hmm yeah it doesn't pass that along to lein

thheller18:03:25

I'll see about adding that

sleepyfox18:03:53

OK, same error on recreating the Docker image, diagnostic output is:

thheller18:03:52

@sleepyfox are you creating a docker image that saves the .shadow-cljs directory but not ~/.m2?

sleepyfox18:03:41

Yup, I think you've hit the nail on the head. I'm just mounting . to /var/app

mitchelkuijpers18:03:21

Btw I am trying it out without leiningen since cider added shadow-cljs support ^^

sleepyfox18:03:55

I'll mount the src, target and other files independently instead of just using COPY . /var/app

thheller18:03:25

I never tried running shadow-cljs in docker. I could add a safeguard to test whether the classpath files still exist and if not invalidate the classpath and regenerate

thheller18:03:34

but that seems like it would download the deps over and over again

eoliphant18:03:36

hi i just upgraded to 2.2.20 and I’m getting an error, I couldn’t determine if it had something to do with what you guys have been discussing

Exception in thread "main" java.lang.ClassNotFoundException: com.google.javascript.jscomp.CompilerInput$ModuleType, compiling:(shadow/build/cljs_closure.clj:3:1)
Did a --cli-info everything looks right
=== Version
cli:            2.2.20
jar-version:    2.2.20
config-version: 2.2.20

thheller18:03:15

@eoliphant do you have a specific closure-compiler version picked in your deps? or clojurescript for that matter?

thheller18:03:20

unfortunately clojurescript is very picky about which closure-compiler version gets used

mitchelkuijpers18:03:52

Hmm I want to use standalone shadow-cljs but duplication all deps from leiningen is too painfull how do other people handle this? Or do they just use leiningen?

thheller18:03:44

I think for now that can't be helped since cursive doesn't look at shadow-cljs.edn 😞

eoliphant18:03:39

this is a recent fulcro project

eoliphant18:03:54

doesn’t look like it

thheller18:03:28

@eoliphant which clojurescript and closure versions are mentioned in --cli-info?

eoliphant18:03:34

umm neither lol

MacBook-Pro:fm-ng-ui ericholiphant$ shadow-cljs --cli-info
shadow-cljs - config: /Users/ericholiphant/projects/fm-ng-ui/shadow-cljs.edn version: 2.2.20
=== Version
cli:            2.2.20
jar-version:    2.2.20
config-version: 2.2.20

=== Paths
cli:     /Users/ericholiphant/projects/fm-ng-ui/node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.cli.js
config:  /Users/ericholiphant/projects/fm-ng-ui/shadow-cljs.edn
project: /Users/ericholiphant/projects/fm-ng-ui
cache:   .shadow-cljs

=== Java
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

=== Source Paths

=== Dependencies
cache-file: /Users/ericholiphant/projects/fm-ng-ui/.shadow-cljs/classpath.edn

thheller18:03:01

its in the dependencies 😉

eoliphant18:03:24

ah ok 🙂 clojure is just 1.9.0, there’s no explicit dependency for closure. In looking at the resolved dependencies in intellij, closure is v20170910

eoliphant18:03:54

sorry you said clojurescript, that’s 1.9.946

thheller18:03:43

hmm are you using lein?

eoliphant18:03:11

using the recent fulcro setup which does set :lein true

eoliphant18:03:41

im executing with npx shadow-cljs ....

thheller18:03:52

hmm try bumping clojurescript to 1.10.238 ... the shadow.build.cljs-closure ns was added today to work around a different problem with CLJS+Closure

thheller18:03:58

seems like I can't win this fight

eoliphant18:03:12

ugh. that’s no fun 😞

eoliphant18:03:21

dependency hell

eoliphant18:03:35

good luck will try 1.10..

eoliphant18:03:10

yeah that seems to have fixed it

thheller18:03:07

@mitchelkuijpers do you know the lein command line to inject stuff? can't find it

mitchelkuijpers18:03:15

update-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.13\"\ \:exclusions\ \[org.clojure/clojure\]\] -- update-in :plugins conj \[refactor-nrepl\ \"2.4.0-SNAPSHOT\"\]

mitchelkuijpers18:03:23

Oh you found it already

thheller18:03:47

hmm plugins is going to be bad

mitchelkuijpers18:03:55

you don't need that

mitchelkuijpers18:03:14

refactor-nrepl only works for clojure not clojurescript

thheller18:03:30

hmm but it seems like you could just stick to lein? not really worth pretending to use shadow-cljs which then just delegates to lein

thheller18:03:43

when cider support for lein is better anyways?

mitchelkuijpers18:03:56

Yeah but we have some trouble when running shadow in leiningen within our repl instead of running it standalone

mitchelkuijpers18:03:13

The shadow-cljs integration in cider works pretty slick

mitchelkuijpers18:03:20

But maybe I should just fix our project somehow

thheller18:03:51

I wish all of this would just work but tools really only look at clojure stuff

thheller18:03:30

and only one at a time so you are pretty much forced into lein when you want actual clojure support

mitchelkuijpers18:03:03

Yeah but cider is making nice progress, i can now only run shadow-cljs without leiningen ^^

mitchelkuijpers18:03:18

Just duplicated all of our deps in shadow-cljs.edn and it just works

mitchelkuijpers18:03:05

Hmm cannot upload images to slack anymore...

hlolli21:03:19

A lazy persons bug report. Not sure if anyone uses moment.js regularly, probably closure bug, but the npm module for moment.js requireing it like this ["moment" :as Moment] and give it a timestamp (str (Moment "2018-10-03 18:48:05.123")) produces nicely human readable date but after compilation (guessing npm modules go trough :simple optimizations) the timestamp becomes unix timestamp (ex. 1522141700340) Someone else experienced something similar. Too busy tonight to open ticket, but can do so this weekend.