Fork me on GitHub
#shadow-cljs
<
2018-04-05
>
troglotit08:04:57

hey! where I can find :id-of-build which is needed to connect to cljs build? Described like here: https://github.com/thheller/shadow-cljs/wiki/Cider

thheller08:04:45

your :builds {:id-of-build ...}. :app or so.

troglotit09:04:09

yeap, it worked, thank you!

sleepyfox11:04:33

I've noticed that upon first use, shadow-cljs downloads maven deps and stores them in ~/.m2 - is there a way of configuring this location?

thheller11:04:55

not currently no

sleepyfox11:04:27

That's a shame, it's making CI builds more painful than they need to be

thheller11:04:00

hmm thats a standard maven thing so I'd expect there to be solutions for this with CI

thheller11:04:09

dunno if I can make configurable

sleepyfox11:04:27

Are you delegating to lein/mvn or doing it yourself?

thheller11:04:30

currently using https://github.com/cemerick/pomegranate which is the same lein is using. might switch to tools.deps in the future.

thheller11:04:58

looks like its configurable though

sleepyfox11:04:13

OK, I'll give that a go

thheller11:04:25

try setting :local-repo "wherever" in your shadow-cljs.edn config

thheller11:04:38

need to delete .shadow-cljs/classpath.edn though

thheller11:04:50

that currently does not account for :local-repo changing

sleepyfox11:04:58

Working correctly, thanks

hmaurer17:04:15

@thheller in clojurescript I recall you have to tag functions with ^:export to avoid the names being re-written by advanced compilation, however I see no mention of that with shadow (for the :node-module target). What’s the behaviour?

thheller17:04:01

not required, the compiler knows what it needs to know due to the :main config

hmaurer17:04:03

Also, can I benefit from dead code elimination with :node-module or simialr by specifying a namespace containing my “API”, and get everything that the API doesn’t depend on to be eliminated by Closure?

thheller17:04:45

for :npm-module everything you don't ^:export is fair game and will most likely be removed

hmaurer17:04:19

I don’t quite get the difference between :node-library and :node-module then

hmaurer17:04:22

I’ll re-read the doc

thheller17:04:05

:node-library generates ONE file object with exports. so you end up with ONE require("the-thing")

thheller17:04:31

:npm-module leaves the namespaces intact so you can require individual namespaces require("the-thing/some.ns")

hmaurer17:04:43

@thheller so that’s similar to using :node-module and writing a special namespace myself, e.g. “api”, which contains my functions?

hmaurer17:04:01

:node-library generates a single file mapping to various functions in various namespaces?

thheller17:04:32

with :node-library you specify the :exports in the config. they can be from different namespaces yes.

hmaurer17:04:36

but with :node-module, as you said, I need to mark any function that I wish to use post-compilation with ^:export, right?

hmaurer17:04:10

ok. Thank you! 🙂

hmaurer17:04:58

Do you have a recommended way to integrate shadow with other js projects? e.g. would you generate a npm package and symlink it from your other projects?

hmaurer17:04:06

I tried various approaches yesterday night

hmaurer17:04:15

Just curious if you have one in mind

hmaurer17:04:38

specifically to get live-reload to work nicely with create-react-app/parcel/webpack/else

thheller17:04:18

ideally you let shadow-cljs compile the JS completely

thheller17:04:32

integrating the other way around is always going to be lossy

thheller17:04:00

in particular live-reload .. that pretty much goes out the window if you let anything else bundle the code

thheller17:04:07

basically took the entire create-react-app project. moved some things around but didn't change one line of code.

thheller17:04:25

and use shadow-cljs to compile it some some extra help from babel

thheller17:04:48

but thats nowhere near reliable enough now .. but thats the direction I was going with

thheller17:04:07

integration with webpack is easy enough and really depends on how your JS project is setup

thheller17:04:16

you could create a dummy npm package for the JS output

thheller17:04:42

or just output it into some directory and refer to the files directly via either relative paths

thheller17:04:47

or webpack resolve config help

hmaurer17:04:11

I didn’t realise shadow could bundle javascript as well

hmaurer17:04:18

interesting

hmaurer17:04:28

and could i mix cljs, cljc and js sources this way?

hmaurer17:04:55

Basically I am working on a project for which the “core” is written in clojurescript, but I want to develop the interface with React in JS

thheller17:04:23

app.cljs uses foo.js which uses bar.cljs

thheller17:04:25

full interop

thheller17:04:04

unfortunately all of this is not totally finished yet since you need to run babel manually currently

hmaurer17:04:06

is this kind of “mixed” project documented?

hmaurer17:04:24

I’ll try to replicate the example though 🙂

thheller17:04:26

very experimental

hmaurer18:04:12

While I am at it: you mentioned using the REPL only through your editor. If I wish to use a REPL through the command line, and have the ability to reload namespaces that changed on the fly, how could I do it?

hmaurer18:04:24

Right now my project is set up with boot. Most of the project is composed of cljc files

hmaurer18:04:52

I use the Clojure (not clojurescript) REPL, and wrote a function to reload namespaces (that I call manually, (reload); it looks for files that changed and reloads the namespaces)

thheller18:04:29

rlwrap npx shadow-cljs clj-repl (reload)

hmaurer18:04:18

oh there is a built-in reload function?

hmaurer18:04:43

ah you meant I should expose mine

hmaurer18:04:58

yeah, which goes back to my question on loading a namespace by default when starting the repl

hmaurer18:04:00

but I can figure that out

thheller18:04:10

shadow-cljs really isn't meant for Clojure though

thheller18:04:26

if you want reload for CLJS I recommend using the build-in reload stuff

hmaurer18:04:39

I wouldn’t mind using the clojurescript repl

hmaurer18:04:45

so long as I can get stuff auto-reloaded

hmaurer18:04:48

or manually reloaded somehow

thheller18:04:43

which REPL though? if you let webpack process your sources the REPL and live-reload pretty much don't work

hmaurer18:04:08

that would just be to debug the “core”, which is entirely written in clojurescript

thheller18:04:19

so shadow-cljs browser-repl or so?

hmaurer18:04:21

it’s basically a library of functions

thheller18:04:40

(require 'some.ns :reload) should do it then

denik18:04:47

@thheller have been watching your commits. Slow compiles where always my biggest pet peeve with big project cljs builds! DX just got much more pleasant. 💯 thanks for the performance tweaks!

thheller18:04:53

I think there is still lots of tuning that could be done. just need time to do it 🙂

💯 4
tony.kay22:04:08

on hot code update: renaming a namespace seems to give shadow-cljs some problems. It complains that it can’t find the namespace anymore

thheller08:04:13

just renaming the file?

tony.kay17:04:54

refactor in IntelliJ: which renames the file. Then shadow complains the file is missing and I have to restart it