Fork me on GitHub
#shadow-cljs
<
2020-03-04
>
Pavel Klavík00:03:20

So I studied little bit how leiningen profiles work and moved this plugin into my user profile, so my local development works but the plugin is not used during deployment. It works as a temporary solution and we will solve a better dev setup in the future.

wilkerlucio12:03:57

hello, is there a way to keep a watch running for a release build? wanting to debug something that only happens on release

thheller12:03:46

no, that would be impractical

thheller12:03:13

just have a shadow-cljs server instance running and trigger shadow-cljs release app --pseudo-names manually when needed (or via a REPL keybind)

👍 4
thheller12:03:21

haha ... I don't know why that library exists when the closure library has a perfectly fine md5 impl 😛

thheller12:03:50

but yeah don't do that 😛

misha13:03:47

it's 7 years old, but yeah. discoverability is still somewhat a problem

misha13:03:24

thank you for shadow-cljs again, it alleviates a lot of pain

👍 4
Saikyun13:03:19

how would one use polyfill with shadow-cljs? 🙂 I need to target internet explorer... :'D

Aleed15:03:52

did you try just importing your polyfill file? you can even import in a js file and then require the cljs output yourself, i.e.

require('some-polyfill.js')
require('public/js/main.js')

Saikyun07:03:32

thanks for the info. I'm gonna try what thheller suggested first

Schpaa14:03:38

who uses shadow-cljs with devcards?

☝️ 8
yenda14:03:34

When working on react-native screens, the code is recompiled but nothing is re-rendered unless the home screen or a top bar code is changed. Is it a limitation or just poor setup? (note that rn fast refresh is disabled)

Pavel Klavík14:03:01

Hi, I am using shadow/release function to build my release. How can I detect that the build fail the rest of the build process as well?

thheller14:03:10

@yenda upgrade to the latest version and try :devtools {:reload-strategy :full} in your build config

👍 4
yenda14:03:20

dammit you are amazing

yenda14:03:00

thanks it works perfectly

thheller14:03:32

@pavel.klavik I guess if it doesn't return :done? Its really meant as an api method for the REPL so it caches and pretty-prints exceptions

thheller14:03:55

I guess I could add a release! fn that just throws and doesn't catch the error

achikin14:03:32

What happens if my js file requires e.g. semantic-ui-react itself?

achikin14:03:42

Will shadow-cljs resolve it?

thheller14:03:04

it will but there are a couple known issues so it might not work

achikin14:03:59

What kind of issues?

thheller14:03:31

well it either works or it doesnt 😛

thheller14:03:52

the biggest issue is mixing commonjs with ESM code

thheller14:03:18

since the closure-compiler thinks all npm code is commonjs it may effect how it treats the classpath js

Pavel Klavík14:03:28

@thheller thx, will take a look

achikin14:03:49

Re: babel jsx processing - is there any way to hook that into shadow-cljs server so I don’t need to run babel as a separate process?

thheller14:03:43

no, it is recommded to run it separately

Saikyun14:03:13

I tried adding :js-options {:babel-present-config {:targets {:ie 8}}} to my shadow-cljs.edn, but I still get "Promise not defined" in iexplorer... any suggestions? 😄

achikin14:03:57

:babel-preset-config

achikin14:03:05

Could be a typo

Saikyun06:03:14

oh, haha, nice catch!

thheller14:03:53

@saikyun that only affects npm code, it has no effect if your CLJS code uses js/Promise

Saikyun14:03:41

oh I see. is there a way to babel the cljs code as well?

thheller14:03:05

you can use third party polyfills like https://polyfill.io/v3/ if you want to inject the polyfills only for ie

Saikyun14:03:23

ah, cool. I'll try that then

achikin15:03:51

What is :babel-preset-config? Is there any doc for it?

thheller15:03:34

no docs no since you basically should never ever use it

yenda15:03:21

the hotreload of shadow is so much faster than react-native fast-refresh lambdalove

Saikyun06:03:20

I just want to note that if even shadow-cljs hotreload feels slow (e.g. when iterating on an animation), putting the function call you want to play around with at the top-level then using a repl + load-file gives you amazing response times 🙂

Saikyun06:03:58

e.g. like so:

(defn start-animation [] ,,,)

(start-animation)
then load-file at the repl, preferably using a hotkey 😄

👍 4
Saikyun06:03:52

if you want to go even faster (especially in a big file) you can use eval-defun, i.e. only eval the function you're modifying

Saikyun06:03:08

and that's something that's hopeless with "regular" react native

👍 4
knubie14:03:41

I’ve noticed the hot reloading stops working a lot on my build, do you guys ever run into that? Any ideas for how to debug?

yenda17:03:24

have you tried the config

:dev {:devtools {:autoload true
                            :reload-strategy :full
                            :after-load app.core/reload}}

yenda17:03:09

I had an issue with some routes never hot-reloading or only when some specific parts were changed, and :reload-strategy :full did the trick

knubie13:03:52

Haven’t tried that, but sounds promising. Thanks!

thheller15:03:47

good to know. never seen fast-refresh in action yet 😛

Chris Little16:03:43

I'm curious about a note from a couple days ago, about :devtools {:reload-strategy :full} Before enabling :deps true , live reloading would include updates to files under node_modules. Now after enabling, I have to use reload-strategy to get that functionality. I'm just curious why the deps modes are different in this way?

awb9917:03:08

is it possible to serve resources from classpath from jar files via the shadow-cljs devtools web server ?

jplaza17:03:58

Hello everyone 👋! Users of shadow-cljs: What would you tell a hesitant CLJS user like me who has been refraining from using shadow-cljs because it is not “the official tool”, to convince them of making the switch? Thanks in advance for your comments.

aisamu17:03:06

If you rely heavily on npm, don't think twice! It's not that much different, theller knows more about CLJS internals than I ever will and he's incredibly responsive here, even when we fail to read the extensive documentation :)

kasuko18:03:46

I tell you this, if you are using the official tool then you're doing it the hard way and anything including shadow-cljs will be better. Of course this assumes you're using the actual "official" way which is compiling the source by using the cljs.jar file and running it manually. If however you are under the assumption some other way is the "official" way (like figwheel) then you've been misled and you're already off the beaten path!

sogaiu23:03:17

out of curiosity, what is "the official tool"?

jplaza02:03:11

I had a misconception about shadow-cljs, I thought it was some sort of fork of the CLJS compiler

sogaiu02:03:43

thanks for the clarification

thheller17:03:18

@jplaza what makes a tool official? shadow-cljs is just as official as figwheel is?

thheller17:03:17

@hoertlehner sure, set :dev-http {8080 "classpath:foo"}

thheller18:03:17

@chrislittle1986 :reload-strategy is not affected by using :deps true or not.

awb9918:03:58

@thheller: thanks! Does :dev-http replace :devtools {:http-root "public" :http-port 8020}

thheller18:03:47

yes, it replaced that quite some time ago

jplaza18:03:57

Thanks @thheller for the reply and for creating this cool tool! I probably used an incorrect term. I’m really looking for better NPM support, having to rely on CLJS is a drag. What I’m kind of worried is: how would our source code be affected if npm support becomes official by the CLJS compiler?

jplaza18:03:37

I’m probably not understanding how things actually work and asking non-sense but was worth the try 🙂

thheller18:03:19

the method of including npm dependencies is an abtraction controlled via :js-provider. so should CLJS ever get "different" support its just another method you can select

jplaza18:03:00

Thanks again it seems I was making a big deal of it. It might be related to the fact the some years ago when I first saw shadow-cljs I thought it was some sort of cljs compiler fork

thheller18:03:41

yeah the name seems to confuse a lot of people

thheller18:03:10

but even if it became a compiler fork ... does that really matter as long as everything you write is still standard CLJS code that you can at any time compile with other tools?

thheller18:03:58

you can emulate the npm support shadow-cljs has today in regular CLJS by using the webpack method

thheller18:03:32

the non-standard things are cleary marked in the docs and you don't have to use them

jplaza18:03:37

I will definitely give it a try these days. Not having up-to-date npm deps is sometimes frustrating.

thheller18:03:04

besides that as long as you don't use shadow-cljs specific features (there aren't that many) then you can just compile with the "default" cljs tools

kasuko18:03:27

@thheller I'm here for the same problem as @chrislittle1986 though I'd like to clarify a bit. We are using shadow-cljs inside of a monorepo. We have other pure Javascript libraries in that monorepo. For development purposes we have been using npm link to symlink the dependencies inside our node_modules and that has been working great! If we make a change to the Javascript library shadow-cljs would pick-up the changes via the symlink and recompile and everything was awesome! However, we recently switched to using tools.deps for our maven dependencies so we could the use :local provider and get the same setup for our Clojurescript libraries. It seems like enabling :deps true has in some way prevented shadow-cljs from picking up changes to our Javascript files and recompiling now. These seems strange to me and probably is something else but I'm not sure where else to look.

thheller18:03:46

in general node_modules code is not hot-reloadable or only in a very limited way but I don't see how deps.edn affects it in any way

kasuko18:03:08

Is there any difference between watching changes to required .cljs file and watching changes to required .js files?

thheller18:03:24

node_modules is watched differently yes but thats always the case. again not related to :deps true

kasuko19:03:49

Yep, you are right it appears to be a version thing. I bisected the change down to version 2.8.67 will pick up changes to .js files where as 2.8.68 no longers picks up changes to .js files

thheller19:03:14

right yes I changed node_modules watching

thheller19:03:28

since it was commonly watching way too many files that weren't hot-reloadable anyways

thheller19:03:09

but yeah npm link behavior would likely change

kasuko19:03:40

Would it be difficult to restore but behind a configuration flag? We rely pretty heavily on this feature.

kasuko19:03:07

I can open an issue on GitHub and give it a go if you're open to an MR.

thheller19:03:50

you rely on it how? the new logic only watches the package.json for modification (timestamp is enough) so "touch package.json" should be enough to trigger a shadow-cljs compile?

kasuko19:03:25

For example we have a Javascript library that we write all of our GraphQL queries in .graphql files. This library uses graphql-tag webpack-loader to compile those files into queries for ApolloClient (the GraphQL client we use) webpack watches for any changes to the .graphql files and will output new .js files which shadow-cljs read in from the node_modules directory (due to npm link) and would then reload any namespaces that use those compiled queries.

kasuko19:03:58

We can just constantly touch the package.json file but that's pretty much the equivalent of just re-running compile every time we make a change

thheller19:03:05

what kind of code does this generate? why do you have to do this as a npm module?

thheller19:03:42

if you open an issue I can take a look. I didn't consider that people would be actively working on npm packages while using them in shadow-cljs

thheller19:03:59

so I might reconsider supporting that again but I need to think about it first

kasuko19:03:12

Okay, would an example setup in a repository help?

thheller19:03:31

it was definitely causing issues for other people since checking thousands of files every second is quite a lot of work that is pointless 99% of the time 😛

thheller19:03:06

examples always help yes

kasuko19:03:44

Cool, I will get that set up and then create an issue

Chris Little19:03:54

Are there options in shadow-cljs to tell it to watch a specific folder under node_modules? That wouldn't be ideal in our case, since we'd have to start maintaining a list of npm link'd packages, but it seems like we have to do that for the "local" overrides in deps.edn anyway

thheller18:03:10

the only "difference" that deps.edn might have is that more code can come from local files vs .jar files

thheller18:03:18

so if anything it might start reloading more?

jplaza18:03:00

Thanks again it seems I was making a big deal of it. It might be related to the fact the some years ago when I first saw shadow-cljs I thought it was some sort of cljs compiler fork

Saikyun06:03:20

I just want to note that if even shadow-cljs hotreload feels slow (e.g. when iterating on an animation), putting the function call you want to play around with at the top-level then using a repl + load-file gives you amazing response times 🙂