Fork me on GitHub
#shadow-cljs
<
2020-05-10
>
lilactown03:05:44

hmm I don't even see the commit for 2.9.0

Eliraz06:05:48

Hey, I'm  trying to move from React to Reagent using `shadow-cljs` but for some reason I don't understand, I keep getting this message *shadow-cljs - Stale Client! You are not using the latest compilation output!*

Eliraz06:05:57

When I add break points on any piece of code it seems like it gets to it but does not really execute it. not even `(js/alert "lala")`

Eliraz07:05:03

any help would be appreciated

thheller07:05:52

@mss that is a version conflict. you have the incorrect clojurescript version. 2.9.0 needs cljs 1.10.758,

👍 4
thheller07:05:42

@eliraz.kedmi157 that means that the code you are loading is not the code produced by the watch you have running. commonly that happens if you configure a different :output-dir or :modules without updating the references in your HTML to actually use those files.

thheller08:05:13

FWIW I pushed 2.9.0 yesterday which was bumped to 2.9 because of the classpath indexing changes. this should make startup a little faster and have less issues with bad jar contents (containing compiled CLJS output). I hope it doesn't have any other negative effects, so if something weird starts to happen in your apps let me know.

thheller08:05:54

@yenda in 2.9.0 you can also turn of source maps for react native via :compiler-options {:source-map false}

yenda09:05:02

Nice thanks

Eliraz10:05:08

@thheller Thank you, that make sense 😛

Eliraz10:05:40

is there a way to know what the js filename would be?

Eliraz10:05:23

I got it. it's the same filename as the cljs one

thheller13:05:40

the module id is the name :modules {:main {...}} produces main.js in :output-dir

armed17:05:54

@eliraz.kedmi157 I always get stale client error when forgot to turn of caching in chrome dev tools.

Eliraz18:05:29

Thank you! the issue actually was that no js was loaded

Eliraz18:05:36

the path in the HTML was wrong

Eliraz18:05:46

I wish there was a better error message to it

Sam G18:05:22

Hello! I am trying to add Quil to my project but when I try to compile it tells me that The required JS dependency "p5" is not available, it was required by "cljsjs/p5.cljs". I close the repl, npm install p5, it tells me that it adds + [email protected] and I can see the folder in /node_modules/ , but when I lein dev it fires back up and eventually tells me that it is still missing p5. What else should I be doing to fix this?

lilactown18:05:47

is your project based off of some sort of template?

Sam G19:05:48

I started with lein new re-frame and added retit and now quil

dpsutton19:05:15

I see “required by cljsjs/p5 there which is problematic in shadow

thheller19:05:44

@dpsutton no it isn't. that is already the stub file mapping the cljsjs package to p5

thheller19:05:51

@skiracer1292 I don't know what lein dev does so I can't help much. make sure you are in the correct directory and so on. also make sure lein dev isn't resetting your node_modules or so

thheller19:05:07

I must say I'm getting a little tired of lein-shadow ...

dpsutton19:05:51

(Sorry for misreading and derailing)

Sam G19:05:04

I am still pretty new to clojure and was recommended the re-frame template to start but if you don't recommend using the lein-shadow plugin that comes packaged with it I will look into setting the project back up to just use shadow and see if I can avoid this all together.

thheller19:05:32

@skiracer1292 just make sure you are actually in the correct directories ... lein-shadow sort of starts out without a package.json and if you run npm install p5 in a directory without a package.json then all bets are off where it actually installs things

thheller19:05:24

make sure there is a package.json in the dir of your project.clj

thheller19:05:36

if there isn't one you can just run npm init -y

Sam G19:05:20

I am in the project base directory when I install and can see the folder created in ~/project/node_modules/, if I have a finder window watching the node_modules I see the p5 folder get culled out. I tried adding "p5": "1.0.0" to the existing package.json and also watch that get replaced when I lein dev, which is defined as ["with-profile" "dev" "do" ["shadow" "watch" "app"]] in alases and {:dependencies [[binaryage/devtools "1.0.0"]]  :source-paths ["dev"]} in profiles

thheller19:05:17

dunno why it does that. its not shadow-cljs doing that. I tried to convince the authors not to use lein-shadow but somehow this is supposed to be easier with it ...

superstructor23:05:18

Could you please provide some concrete information behind this @thheller. Why ? What is the disadvantage ?

thheller19:05:25

:face_vomiting:

thheller19:05:50

please open a bug report with the re-frame template ...

Sam G19:05:03

will do. it is easy to get it to pop up in a fresh re-frame template project

thheller20:05:18

but yeah consider moving away from lein-shadow completely

mikethompson03:05:31

In an attempt to stop support issues hitting this channel, we have added to the docs: https://github.com/day8/re-frame-template#how-to-add-dependencies

thheller07:05:32

that is precisely why. npm should be in charge of it and npm should be used as is. consider that there might be people coming from the JS ecosystem familiar with npm (or yarn) and then suddenly things don't work as expected

thheller07:05:55

people might just want to use npm as is ... maybe they want scripts, maybe they want other things in package.json

thheller07:05:11

you just wiping it without considering this is bad practice

thheller07:05:32

also I always point people towards my docs and even the error message tells people to run npm install whatever

thheller07:05:42

which then doesn't apply since you do things differently

thheller07:05:30

I completely disagree with doing everything in project.clj ... that counts for shadow-cljs.edn as well since you lose a bunch of features by doing that

thheller07:05:50

eg. config auto-reload. shadow-cljs watches shadow-cljs.edn for build changes etc.

thheller07:05:21

suiddenly that is gone because use has to edit project.clj or the changes are gone

thheller07:05:47

people may also prefer to use yarn over npm ... but they can't

thheller07:05:40

one thing npm does better than anything in CLJ(S) is npm install some-package without having to know the version

thheller07:05:45

that is also gone ...

thheller07:05:15

IMHO you are not fixing anything npm related by moving it and just make it look like it doesn't exist.

thheller07:05:25

that is bad ..

superstructor08:05:19

Thanks for the feedback @thheller, but its still not clear why the recommendation you propose is better for common use cases for ClojureScript devs

thheller08:05:00

writing a longer reply on the github issue right now ...

superstructor08:05:57

Ok will await that 🙂 Thanks.

thheller20:05:58

FWIW I looked at the source and it seems like you are supposed to add :npm-deps {"p5" "1.0.0"} to your project.clj

lilactown20:05:52

yeah I used lein-npm at my last gig and it was awful and confusing

lilactown20:05:07

> It also manages your npm dependencies in the :npm-deps key, checking for any changes on every run.

Sam G20:05:11

where are you seeing these docs? I have looked around for lein-shadow docs and found nothing 😞 I just found https://gitlab.com/nikperic/lein-shadow/-/blob/master/examples/lein-shadow-example/project.clj and tried to mimic their :npm-deps key with :npm-deps  [[p5 "1.0.0"]] and it still culls out my p5 library. same with :npm-deps {"p5" "1.0.0"

thheller20:05:34

no clue why that example has figwheel and cljsbuild in it ...

thheller20:05:40

doesn't look like a good example

nsauce20:05:56

@thheller ever come across this issue?

errors in file: /Users/njam/Github/nsauce/cannabit-lp/node_modules/request-compose/compose.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es8", :goog-module nil, :js-warnings [], :resource-name "node_modules/request-compose/compose.js", :js-requires [], :js-errors [{:line 140, :column 3, :message "primary expression expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false}
ExceptionInfo: errors in file: /Users/njam/Github/nsauce/cannabit-lp/node_modules/request-compose/compose.js

thheller20:05:32

probably not a JS file

thheller20:05:35

might be JSX

nsauce20:05:17

can confirm it is a js file

thheller20:05:43

maybe its a node-only package?

nsauce20:05:24

interesting, it’s not a direct dependency of my project

thheller20:05:33

yeah quick glance at the code it is pretty clear this isn't intended to run in the browser

nsauce20:05:57

yeah not sure why it’s being included on the client app compile process,

thheller20:05:12

something required it somewhere

nsauce20:05:23

yeah, i’ll have to hunt it down

nsauce20:05:27

thanks for the help!

nsauce20:05:02

hm, turns out I had a cljs file that was completely empty in a dependency, removing this file and repackaging my dependency fixed the issue

nsauce20:05:47

so there might an issue with the compiler and empty files

nsauce20:05:24

recently updated to 2.8.107

nsauce20:05:40

anyway it’s working so thanks again!

thheller20:05:42

empty files will definitely not add random dependencies 😛

nsauce20:05:00

totally, but it might be an issue reading the file?

nsauce20:05:07

hm, nope adding another empty file does not cause the issue to reappear

nsauce20:05:21

so I guess this was a corrupted dependency

nsauce20:05:37

I dunno, its working so im happy

folcon23:05:44

Is there any way to get shadow-cljs to watch changes in js files?