shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
borkdude 2020-09-15T08:39:25.311900Z

When I have a local npm dep and make changes to it, can I get reloading for that, or do I have to npm install + restart my build process every time?

thheller 2020-09-15T09:15:53.312800Z

@borkdude shadow-cljs no longer watches individual files in node_modules (there were just tooooo many). you can touch node_modules/that-package/package.json though to trigger a recompile

borkdude 2020-09-15T09:16:29.313Z

thanks!

thheller 2020-09-15T09:17:27.313600Z

or in case you are writing the whole thing yourself anyways just go with direct includes via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js

borkdude 2020-09-15T09:17:42.313900Z

will this JS also be optimized when building with release?

thheller 2020-09-15T09:17:47.314100Z

yep

borkdude 2020-09-15T09:17:51.314300Z

:thumbsup: :)

thheller 2020-09-15T09:18:19.314700Z

even going through :advanced unlike node_modules which is only :simple

borkdude 2020-09-15T09:19:21.315300Z

First project using shadow (inherited from @plexus) https://babashka.org/xterm-sci/

๐Ÿ˜ 1
thheller 2020-09-15T09:21:07.315800Z

hmm why xterm?

borkdude 2020-09-15T09:21:16.316Z

dunno :)

borkdude 2020-09-15T09:21:55.316900Z

it was plexus's idea, I thought I'd take a stab at it, since he was using implementation details of sci, I forced myself into making those things public

borkdude 2020-09-15T09:22:03.317200Z

otherwise, it could have just been a text area probably

thheller 2020-09-15T09:22:58.317600Z

nah I mean that we can probably do better than a text-only interface these days ๐Ÿ™‚

thheller 2020-09-15T09:23:27.318100Z

I'm sad if that is the best we can do

thheller 2020-09-15T09:23:56.318600Z

well the shadow-cljs UI is at least my attempt to do better ... not yet sure if it actually is ๐Ÿ˜‰

borkdude 2020-09-15T09:24:50.319Z

sure

thheller 2020-09-15T09:25:02.319500Z

maybe a codemirror input (or any editor) and outputting some kind of DOM is better than xterm

borkdude 2020-09-15T09:25:10.319700Z

that wasn't the point of this exercise from my angle, I'm sure there are lots of nice things you can do visually

borkdude 2020-09-15T09:25:34.320100Z

yes, I already have that here: https://borkdude.github.io/sci.web/ (this is an older version of sci, I should update it)

๐Ÿ‘ 1
thheller 2020-09-15T09:30:19.321500Z

I played with xterm too in the UI a while ago. it is definitely a decent way to get a functional terminal-ish interface going quickly

borkdude 2020-09-15T09:30:55.321900Z

@thheller I used local-echo but it had issues with quoting. Made an issue + fix for it

thheller 2020-09-15T09:31:47.322400Z

there is also a linefeed issue. (dotimes [x 1000] (prn x)) (might be because I'm on windows?)

thheller 2020-09-15T09:32:21.322800Z

81
  982
     983
        984
           985
              986
                 987
                    988
                       989
                          990
                             991
                                992
                                   993
                                      994
                                         995
                                            996
                                               997
                                                  998
                                                     999
nil
user=> ^C
user=> 

thheller 2020-09-15T09:32:46.323100Z

I vaguely remember having that problem too before

borkdude 2020-09-15T09:33:56.323300Z

thanks, I'll make an issue about it

2020-09-15T10:13:10.326400Z

@borkdude @thheller > (might be because I'm on windows?) FYI same behaviour on Linux.

borkdude 2020-09-15T10:13:46.327Z

yeah, I know what the issue is actually. I'm only replacing the last \n with \r\n (which the terminal needs), not the intermediate ones

borkdude 2020-09-15T10:14:03.327400Z

I think I should support *print-fn* in sci instead of only *out* which works better for CLJS

borkdude 2020-09-15T10:14:33.328100Z

In this REPL I'm flushing everything first to a buffer and print it at the end which is kind of sub-optimal

borkdude 2020-09-15T10:14:51.328300Z

The issue is registered

Eugen 2020-09-15T10:20:11.329200Z

hi, I'm trying to figure out why a simple access works in development mode and not with release.

(re-frame/reg-event-db
 ::check-web3
 (fn-traced [db [_ js-window]]
            (let [web3-enabled (exists? (.-ethereum js-window))]
              (js/console.log (str "Browser is web3? " web3-enabled " " (.-ethereum js-window) " " js-window))
              (assoc db :web3-enabled? web3-enabled))))
I'm trying to check for window.ethereum which is a proxy object added by http://MetaMask.io extension .

Eugen 2020-09-15T10:20:51.330200Z

the code woeks with lein watch but fails to work when I do lein release and load the app via static server

borkdude 2020-09-15T10:21:07.330600Z

maybe an advanced compilation problem which renames that property access

borkdude 2020-09-15T10:23:11.331800Z

@eugen.stan I think your best bet with property access in CLJS in general may be goog.object/get

Eugen 2020-09-15T10:24:12.333300Z

thanks @borkdude. I am a bit surprised because the use case seems simple. I just started a build with disabled optimisations

borkdude 2020-09-15T10:24:12.333400Z

another good library for this is https://github.com/applied-science/js-interop

Eugen 2020-09-15T10:37:29.334Z

yes, it is an optimisation issue. Thanks @borkdude. I'll reread the docs.

Eugen 2020-09-15T10:47:58.335700Z

Adding the ^js type hint fixes the issue with advanced compilation (fn-traced [db [_ ^js js-window]] . Thanks again.

henrik 2020-09-15T10:50:56.336600Z

For some reason, I had to add com.google.guava/guava {:mvn/version "23.0"} manually to my deps today, because of:

[2020-09-15 12:49:30.646 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError com/google/common/collect/Streams
	com.google.javascript.jscomp.deps.DependencyInfo$Require.asSymbolList (DependencyInfo.java:60)
	com.google.javascript.jscomp.deps.DependencyInfo$Base.getRequiredSymbols (DependencyInfo.java:163)
	com.google.javascript.jscomp.Compiler.findModulesFromInput (Compiler.java:1914)
	com.google.javascript.jscomp.Compiler.findModulesFromEntryPoints (Compiler.java:1870)
	com.google.javascript.jscomp.Compiler.parseInputs (Compiler.java:1679)
	com.google.javascript.jscomp.Compiler.parseForCompilationInternal (Compiler.java:954)
	com.google.javascript.jscomp.Compiler.lambda$parseForCompilation$4 (Compiler.java:937)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:129)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:843)
	com.google.javascript.jscomp.Compiler.parseForCompilation (Compiler.java:935)
	com.google.javascript.jscomp.Compiler.compile (Compiler.java:693)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
Caused by:
ClassNotFoundException com.google.common.collect.Streams
	jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:581)
	jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:178)
	java.lang.ClassLoader.loadClass (ClassLoader.java:522)
	com.google.javascript.jscomp.deps.DependencyInfo$Require.asSymbolList (DependencyInfo.java:60)
	com.google.javascript.jscomp.deps.DependencyInfo$Base.getRequiredSymbols (DependencyInfo.java:163)

thheller 2020-09-15T11:19:19.337600Z

@henrik typical dependency conflict. you may want to investigate where this conflict is from, otherwise the other code depending on the other version may have issues.

henrik 2020-09-15T11:50:11.338500Z

Gotcha @thheller. Only mention of Guava seems to be from dev-local, maybe thatโ€™s the culprit.

com.datomic/dev-local 0.9.195
  com.google.errorprone/error_prone_annotations 2.3.4
  com.datomic/client-api 0.8.54
  com.cognitect/anomalies 0.1.12
  com.google.guava/listenablefuture 9999.0-empty-to-avoid-conflict-with-guava

thheller 2020-09-15T11:52:55.338700Z

yeah datomic is a common cause

henrik 2020-09-15T11:54:39.339400Z

Why canโ€™t we just be friends

thheller 2020-09-15T11:55:04.339600Z

thats fine

thheller 2020-09-15T11:55:20.339900Z

looks like you are on an older shadow-cljs version?

henrik 2020-09-15T11:55:35.340100Z

2.11.4

thheller 2020-09-15T11:56:56.340700Z

ah right. the check is still running but you can ignore it. you may want to consider keeping your CLJ deps out of your CLJS alias

henrik 2020-09-15T11:58:00.341700Z

Didnโ€™t know that goods practice. Iโ€™m on a pretty cljc-heavy codebase, might be a bit finicky?

thheller 2020-09-15T11:58:51.342200Z

don't know. I keep my stuff usually completely separate. CLJS managed by shadow-cljs.edn only and CLJ by project.clj

thheller 2020-09-15T11:59:05.342500Z

depends on how you project is organized I guess

henrik 2020-09-15T11:59:26.343400Z

Yeah, itโ€™s just laziness talking. It sounds like a good thing to do.

thheller 2020-09-15T11:59:32.343600Z

if I were to use deps.edn only I'd have a :frontend alias and a :backend alias

thheller 2020-09-15T12:00:32.344200Z

just to avoid conflicts like these .. you won't be using REBL or dev-local in your CLJS builds anyways

๐Ÿ‘ 1
borkdude 2020-09-15T14:17:49.345700Z

@thheller printing issue should be fixed: (run! prn (range 500)) https://babashka.org/xterm-sci/

๐Ÿ‘ 2