Fork me on GitHub
#shadow-cljs
<
2020-09-15
>
borkdude08:09:25

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?

thheller09:09:53

@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

thheller09:09:27

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

borkdude09:09:42

will this JS also be optimized when building with release?

borkdude09:09:51

:thumbsup: :)

thheller09:09:19

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

borkdude09:09:21

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

😍 3
thheller09:09:07

hmm why xterm?

borkdude09:09:55

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

borkdude09:09:03

otherwise, it could have just been a text area probably

thheller09:09:58

nah I mean that we can probably do better than a text-only interface these days 🙂

thheller09:09:27

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

thheller09:09:56

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

thheller09:09:02

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

borkdude09:09:10

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

borkdude09:09:34

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

👍 3
thheller09:09:19

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

borkdude09:09:55

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

thheller09:09:47

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

thheller09:09:21

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

thheller09:09:46

I vaguely remember having that problem too before

borkdude09:09:56

thanks, I'll make an issue about it

Michaël Salihi10:09:10

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

borkdude10:09:46

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

borkdude10:09:03

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

borkdude10:09:33

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

borkdude10:09:51

The issue is registered

Eugen10:09:11

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 .

Eugen10:09:51

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

borkdude10:09:07

maybe an advanced compilation problem which renames that property access

borkdude10:09:11

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

Eugen10:09:12

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

Eugen10:09:29

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

Eugen10:09:58

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

henrik10:09:56

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)

thheller11:09:19

@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.

henrik11:09:11

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

thheller11:09:55

yeah datomic is a common cause

henrik11:09:39

Why can’t we just be friends

thheller11:09:20

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

thheller11:09:56

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

henrik11:09:00

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

thheller11:09:51

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

thheller11:09:05

depends on how you project is organized I guess

henrik11:09:26

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

thheller11:09:32

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

thheller12:09:32

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

👍 3
borkdude14:09:49

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

👍 6