Fork me on GitHub
#shadow-cljs
<
2020-05-08
>
Spaceman06:05:04

I'm getting shadow-cljs stale client - you're not using the latest compilation output for some reason. I deleted my target and my out files and rebuilt using (shadow/watch :app) but I still get this prompt. How do I fix this?

Spaceman06:05:48

Also, in the repl I get

No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.

thheller07:05:02

@pshar10 you fix that by loading the correct files. seems like you maybe cleared the wrong directory or wrong server or so.

yenda11:05:09

@thheller found 1 reason to use ^:const , you can't use a def in a case

thheller13:05:25

check a few lines below this 😛

simple_smile 4
facepalm 4
yenda11:05:02

(let [test 4] (case test constants/command-state-request-transaction true false))

yenda11:05:12

evals to false

yenda11:05:27

constants/command-state-request-transaction is def to 4

thheller11:05:53

thats a bug in CLJS then

thheller11:05:05

try it in CLJ

thheller11:05:30

user=> (def ^:const y 1)
#'user/y
user=> (case 1 y true false)
false
user=> (case 'y y true false)
true

yenda11:05:48

so you mean that the fact that it works in cljs with a const is a bug?

thheller11:05:39

no clue. I never use ^:const for anything. Maybe this is intentional. Maybe it actually works in CLJ and I'm just doing something wrong. the clojure docs clearly state that the test contants are not evaluated

thheller11:05:07

so looking up the var and seeing it was a const would imply some evaluation

thheller11:05:01

IMHO that would be a bug but IMHO the entire :const impl in CLJS is a bug

yenda12:05:04

I tried to put :source-map false :source-map-include-sources-content :false in compiler options for :dev build but I still see source maps files in the output dir, does it mean it didn't work? (I cleaned all dir before recompiling)

yenda12:05:40

@thheller would it be possible to allow disabling source-maps in dev? main reason is that they are mostly useless in react-native and result in huge bundles

thheller13:05:33

@yenda how do they result in huge bundles? they aren't inlined?

yenda13:05:06

if you want to have a look that's our index.js

yenda13:05:45

btw do you think it would be possible for shadow to write index.js in a temp file and replace it only once it is done writing? to avoid the metro bundler bug

thheller13:05:32

hmm it seems I forgot that react-native actually inlines the source maps

thheller13:05:37

can't remember why though

thheller13:05:55

I can certainly allow to disable that

thheller13:05:36

ah I think that was the only way to get the source maps to work at all when running the debug-in-chrome thingy

yenda13:05:36

and how does the rewriting of the index.js works? would it be possible to do it in a temp file first ?

thheller13:05:22

I don't really like working around bugs in other tools but sure I can add that

thheller13:05:23

uhm doesn't :compiler-options {:source-map false} not already turn off the source maps?

yenda13:05:52

I tried but I could still see .map files and the index.js looked like it was same size

thheller13:05:06

hmm yeah indeed

Spaceman17:05:11

Why doesn't macro expand work in the cljs repl?

Spaceman17:05:39

I define a macro in a clj file myapp.macros

Spaceman17:05:47

and then require it in myapp.macros cljs file

Spaceman17:05:58

and then use the macro in a third file

Spaceman17:05:34

when I macro expand in the clj repl, the macroexpansion works:

(macroexpand '(db-event :foo [foo bar] [:foo foo :bar bar]))

(do
 :foo
 (clojure.core/fn
  [db__49764__auto__ [foo bar]]
  (clojure.core/apply
   clojure.core/assoc
   db__49764__auto__
   [:foo foo :bar bar])))
But in the shadow repl, this gives:
(macroexpand '(db-event :foo [foo bar] (assoc db :foo foo :bar bar)))
=> (db-event :foo [foo bar] (assoc db :foo foo :bar bar))

thheller19:05:40

@pshar10 just a guess but maybe you didn't follow the instructions I sent you before again? https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html

sergey.shvets18:05:38

That article is gold, btw! Helped me to put a macros in no time! Thank you!

thheller19:05:54

if you don't do all of those steps then macros will not work as you expect

thheller19:05:12

and you cannot define a macro from a REPL unfortunately currently

Spaceman19:05:38

that's the issue indeed.

thheller19:05:48

macros live completely in CLJ anyways so I usually just work on them via a CLJ REPL and macroexpand it there

thheller19:05:27

maybe you can get used to that workflow too if you try. works pretty well for me.

thheller19:05:31

well you can if its a CLJ REPL but that doesn't get you around the other limitations

thheller22:05:18

wrote a new post https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html for people asking about how :bundle affects shadow-cljs

👍 24