shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Aron 2020-11-20T09:31:44.117400Z

Hi, I am running into TypeError: $jscomp.inherits is not a function when I am using a third party dependency (helix), one particular macro from it does it. I already tried to update and restart everything, I also added :output-feature-set :es8 to compiler options and I really wish I could do something that's not just guesswork but actual diagnostic and work. Any ideas?

thheller 2020-11-20T09:33:47.117900Z

which shadow-cljs version? this should be fixed for several versions now

Aron 2020-11-20T09:36:54.118400Z

I never know how to easily read version information. I am used to just add --version after cli commands and they print their version

thheller 2020-11-20T09:37:11.118700Z

it is printed clearly on each startup

thheller 2020-11-20T09:37:25.118900Z

shadow-cljs - server version: &lt;version&gt; running at <http://localhost:9630>

thheller 2020-11-20T09:38:46.119300Z

shadow-cljs info also works but only in limited ways if you use deps.edn or project.clj

Aron 2020-11-20T09:39:19.120Z

i just do a shadow-cljs restart every time i need to start it, so it clear the usually stuck lock file from previous start

Aron 2020-11-20T09:39:56.120400Z

it doesn't print anything other than shadow-cljs - config: path/shadow-cljs.edn shadow-cljs - server starting .......................... ready!

thheller 2020-11-20T09:40:11.120700Z

ah you are running in the background

thheller 2020-11-20T09:40:51.121700Z

then its in the .shadow-cljs/server.stderr.log or .shadow-cljs/server.stdout.log

Aron 2020-11-20T09:40:52.121800Z

you told me to do it this way because i was having trouble managing 3 different terminal outputs. It's much better I admit

Aron 2020-11-20T09:41:43.122200Z

shadow-cljs - server version: 2.11.7

Aron 2020-11-20T09:41:55.122600Z

I am not sure this is shadow-cljs issue.

thheller 2020-11-20T09:42:36.123200Z

well there were several $jscomp related issues that I fixed recently but they should definitely be fixed in 2.11.7

thheller 2020-11-20T09:43:46.123800Z

would help to have a reproducible example

thheller 2020-11-20T09:43:53.124100Z

what is the actual build config you used?

Aron 2020-11-20T09:45:26.124600Z

not the tests, the app

thheller 2020-11-20T09:46:21.125400Z

looks fine except the :output-feature-set :es8 is only in the :release config. I'm assuming the problem you mentioned appears in watch/compile?

thheller 2020-11-20T09:47:00.125800Z

btw this is old and not needed anymore shadow.remote.runtime.cljs.browser in :preloads. you can just remove it.

Aron 2020-11-20T09:47:18.126100Z

ok, thanks

Aron 2020-11-20T09:47:47.126800Z

I will update. And the problem appears in the browser after I compiled and loaded it.

Aron 2020-11-20T09:48:49.127700Z

Didn't really wanted to do this, but I need class components because of react. I would avoid using them if I knew how, but ..

Aron 2020-11-20T09:50:11.128300Z

I see what you mean by the config only in the release. That would explain it, I will try in a minute, thanks

thheller 2020-11-20T09:51:01.128800Z

also in the :release the :modules and :output-dir are exactly the same as outside so you can remove it

Aron 2020-11-20T09:56:27.129Z

😌

Aron 2020-11-20T09:56:33.129200Z

thanks again

2020-11-20T10:16:13.130400Z

I’m assuming it’s known that running shadow-cljs with the latest clojure cli tools appears to print a warning about invoking the clojure cli tools in a (recently) deprecated way: > WARNING: When invoking clojure.main, use -M

thheller 2020-11-20T10:16:57.130800Z

hmm? news to me 🙂

2020-11-20T10:17:46.131200Z

$ clojure -Sdescribe
{:version "1.10.1.716"
 :config-files ["/usr/local/Cellar/clojure/1.10.1.716/deps.edn" "/Users/rick/.clojure/deps.edn" ]
 :config-user "/Users/rick/.clojure/deps.edn"
 :config-project "deps.edn"
 :install-dir "/usr/local/Cellar/clojure/1.10.1.716"
 :config-dir "/Users/rick/.clojure"
 :cache-dir "/Users/rick/.clojure/.cpcache"
 :force false
 :repro false
 :main-aliases ""
 :repl-aliases ""}

2020-11-20T10:19:00.132Z

ok I think the change is basically you now need to invoke clojure.main with clojure -M -m clojure.main

2020-11-20T10:19:10.132300Z

see here: https://insideclojure.org/2020/09/04/clj-exec/

thheller 2020-11-20T10:19:25.132800Z

well does that work with older versions? if not then I'm not changing that for a while

2020-11-20T10:20:34.133600Z

probably not

thheller 2020-11-20T10:20:39.133800Z

the command it runs is clojure -m shadow.cljs.devtools.cli --npm ...

2020-11-20T10:21:05.134600Z

sorry yeah you’ll need clojure -M -m shadow.cljs.devtools.cli ...

thheller 2020-11-20T10:21:06.134700Z

I haven't followed tools deps recently so dunno what changed

2020-11-20T10:21:11.134900Z

A lot

2020-11-20T10:23:14.136400Z

The main thing is the new :exec-fn and :exec-args stuff; which is pretty awesome actually… It could be interesting thinking about what it might mean for shadow-cljs… Though I imagine it’s a lot easier to just carry on with shadow-cljs.edn as it is 🙂

2020-11-20T10:23:35.137Z

either way though it may open up some new options for you

thheller 2020-11-20T10:23:58.137500Z

yeah I'm not going to enforce using deps.edn on anyone. I don't use it on a single project of mine either.

thheller 2020-11-20T10:24:30.137800Z

its nice to see its moving forward but its still nowhere near lein for me

thheller 2020-11-20T10:25:00.138400Z

or shadow-cljs for CLJS of course 😉

😆 1
2020-11-20T10:25:09.138600Z

I certainly know what you mean… it’ll be interesting to see what happens with tools.build

2020-11-20T10:27:01.139900Z

but the :exec-fn stuff at least now provides a way to integrate tooling to build a library and deploy it

2020-11-20T10:27:49.141300Z

it’s not yet as easy as it should be… but it would be pretty straightforward to make it as easy as lein to do this bit.

thheller 2020-11-20T10:27:52.141400Z

sure. if that some day is less than a 5 lines project.clj + lein deploy clojars I might support it 😉

thheller 2020-11-20T10:28:19.141800Z

but good thing is I don't have to do anything. everyone can already use it if they want

thheller 2020-11-20T10:29:08.143Z

still relevant and also still accurate describing why it won't use :exec-fn anytime soon

2020-11-20T10:32:09.143100Z

not less than yet… but it could at least now be made more or less equivalent. I currently have it down to about 30 lines of deps.edn with maybe 4 lines of bash: https://github.com/RickMoynihan/pom-update/blob/37d7bdb0eceb69af0f4796f4b9e7334db3f364a2/deps.edn#L13-L39

thheller 2020-11-20T10:32:55.143400Z

yikes 😛

2020-11-20T10:34:22.143600Z

IKR… if these libs were integrated together (I’ve done it already in a proprietary project which has slightly more bespoke needs - it could be done as easily as with lein)

2020-11-20T10:34:51.144Z

give or take a few LOCs

thheller 2020-11-20T10:37:22.144200Z

yeah its interesting to see work in this area but so far everything looks kinda clunky

2020-11-20T10:38:24.144400Z

It’s definitely clunky — but :exec-fn makes things much better and feels like it could well be a decent foundation for new tooling

2020-11-20T10:42:05.147900Z

Yeah I definitely agree with your stance in that article… but I think :exec-fn is still relevant for shadow-cljs. i.e. if the shadow-cljs api defines entry point tooling functions to just be a single map of data, then they can work with :exec-fn, so users have more options for integration.

2020-11-20T10:43:00.148900Z

So shadow won’t need to mandate tools.deps and :exec-fn; but it could still be an option for users. Providing perhaps a few reasonable constraints are maintained

2020-11-20T10:44:30.149800Z

Anyway, as always thank you for your time 🙇 Shall I create a GH issue about the warning for you, just so there’s a record of it?

thheller 2020-11-20T10:46:42.150100Z

yes please

defa 2020-11-20T12:02:16.151500Z

Regarding character encoding in the repl. I'm connections via repl to a react-native app running on device:

lein repl :connect 9876                                        
Connecting to nREPL at 127.0.0.1:9876
REPL-y 0.4.4, nREPL 0.7.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 1.8.0_265-bre_2020_10_20_12_24-b00
...
shadow.user=&gt; (println "Smørrebrød")
Smørrebrød
nil
shadow.user=&gt; (shadow/repl :app)
To quit, type: :cljs/quit
[:selected :app]
cljs.user=&gt; (println "Smørrebrød")
Sm??rrebr??d
nil
In the "Java REPL" encoding is okay, in the "JS REPL" it is broken... any ideas on how to fix that?

defa 2020-11-20T12:05:04.151700Z

For me it looks like the JavaScript environment on device uses a different character encoding.

thheller 2020-11-20T12:12:52.152Z

that might be. I don't have a clue about react-native sorry

defa 2020-11-20T12:13:13.152200Z

It's a little strange that the JVM "runs" on US-ASCII

lein repl :connect 9876
shadow.user=&gt; (System/getProperty "file.encoding")
"US-ASCII"
despite the fact that -Dfile.encoding=UTF-8 is in the arguments of the java process of lein?

thheller 2020-11-20T12:13:38.152600Z

ah

thheller 2020-11-20T12:14:32.152900Z

someone had this issue before. I cannot remember the details

defa 2020-11-20T12:14:38.153100Z

So I suspect I should have the same char encoding in the Java world than in the JavaScript world running on device.

thheller 2020-11-20T12:14:43.153300Z

how is shadow-cljs launched?

defa 2020-11-20T12:16:00.153500Z

shadow-cljs watch app

thheller 2020-11-20T12:16:03.153700Z

I have a JVM_OPTS environment variable with -Dfile.encoding=UTF8

thheller 2020-11-20T12:16:25.153900Z

and you have :lein true or something in shadow-cljs.edn?

defa 2020-11-20T12:16:48.154100Z

no

defa 2020-11-20T12:17:07.154300Z

I'm using tools.deps

thheller 2020-11-20T12:17:08.154500Z

then why did you mention is in the arguments of the java process of lein`? `?

defa 2020-11-20T12:17:16.154700Z

i only start the repl with lein

thheller 2020-11-20T12:17:29.154900Z

right but the shadow-cljs server process needs to have the same encoding

thheller 2020-11-20T12:17:32.155100Z

otherwise that won't work

thheller 2020-11-20T12:17:49.155300Z

so you can set :jvm-opts ["-Dfile.encoding=UTF8"] in shadow-cljs.edn

defa 2020-11-20T12:18:02.155500Z

Same issue/problem with the repl when running in IntelliJ with Cursive

defa 2020-11-20T12:18:09.155700Z

I'll try....

defa 2020-11-20T12:19:45.155900Z

Of course the US-ASCII is not from the lein-JVM but from the shadow-JVM... stupid me!

defa 2020-11-20T12:24:42.156100Z

Okay, thanks, cool. Setting :jvm-opts ["-Dfile.encoding=UTF8"] in shadow-cljs.edn fixed the problem.

defa 2020-11-20T12:25:14.156300Z

Why is it US-ASCII bei default? When I launch clj I get:

% clj 
Clojure 1.10.1
user=&gt; (System/getProperty "file.encoding")
"UTF-8"

defa 2020-11-20T12:27:06.156500Z

Although UTF8 works, I guess it should be UTF-8.

Eugen 2020-11-20T13:46:54.158600Z

how can I depend on a local built jar (path to jar) ? I'm working to patch https://github.com/titonbarua/shadow-cljs-gjs-target/pull/2 to allow for Gnome Extension to be built. I need to make [[titonbarua/shadow-cljs-gjs-target "0.1.0"] -&gt; [[ shadow-cljs-gjs-target "0.2.0-gnome-extension-patch"]] I can build the patch locally

thheller 2020-11-20T13:50:15.159600Z

@eugen.stan you can run lein install to install it locally

thheller 2020-11-20T13:51:31.160300Z

or in the examples :source-paths you can just direclty include the code via "../../src" and no :dependencies

Eugen 2020-11-20T13:53:40.161500Z

thanks, I will try both

Eugen 2020-11-20T13:56:29.162600Z

including source-paths in shadow-clj.edn of example/gnome-extension.. project does not work (it will not pull the dependencies of that one)

Eugen 2020-11-20T13:56:40.163Z

I can use lein install

thheller 2020-11-20T13:58:04.163300Z

https://github.com/titonbarua/shadow-cljs-gjs-target/blob/master/project.clj#L6 but it doesn't have dependencies?

Eugen 2020-11-20T23:37:31.163800Z

(after nap) Thanks, I was using the wrong path. I can compile and work on the integration now. Made some progress but not quite there yet. It's doable though and we will be able to build GTK apps for gnome shell (Gnome extensions) in ClojureScript