Fork me on GitHub
#shadow-cljs
<
2018-03-09
>
ddrbt05:03:44

Looking at this:

(defn compile* [build-config opts]
  (util/print-build-start build-config)
  (-> (util/new-build build-config :dev opts)
      (build/configure :dev build-config)
      (build/compile)
      (build/flush)
      (build-finish build-config)))

ddrbt05:03:22

Where should I look to see where :output-to and :output-dir are getting set?

thheller08:03:21

@ddrbt it is up to each individual target to control where output goes most targets set :build-options :output-dir to a java.io.File instance

ddrbt16:03:04

Perfect! Thanks. Thinking of a PR: is opts special or can I pass in something like:

(shadow/compile :app
                     {:build-options {:output-to  "mypath/public/js"
                                      :output-dir "mypath/public/js"}})
?

ddrbt16:03:45

and then do

(defn compile* [build-config opts]
      ...
      (build/deep-merge opts)
      (build/flush)
      ...
      )))

thheller08:03:14

usually only flush should write output so you could set it like this

thheller08:03:17

(defn compile* [build-config opts]
  (util/print-build-start build-config)
  (-> (util/new-build build-config :dev opts)
    (build/configure :dev build-config)
    (build/compile)
    (assoc-in [:build-options :output-dir] (io/file "somewhere"))
    (build/flush)
    (build-finish build-config)))

thheller09:03:13

cache files are a bit different but you probably don't need to touch that

davidw11:03:12

I'm looking at switching our project over to shadow-cljs because it solves issues we're having using npm packages with cljsbuild. So far I can't see any reason not to move, pretty much everything seems to work the same or better. But experience tells me there can't be no down side at all. What are the trade-offs when using shadow-cljs?

thheller11:03:50

@davidw I guess the biggest downside currently is that pretty much all editors/tools expect you to use leiningen. so if you want to use the standalone version of shadow-cljs you have to jump through a few hoops to make it work or use it via lein.

thheller11:03:25

besides that I haven't used any other CLJS tools since 2013 and I can say with confidence that it fixes a whole lot of issues that are still present in standard CLJS

davidw12:03:28

ok. It certainly looks to fix the issues I've been having. I'll give a try and see how it goes. Thanks.

davidw12:03:48

This might be a stupid question because I don't know exactly how it works but could there ever be a situation in the future where some language feature was added to cljs that wouldn't work with shadow-cljs?

thheller12:03:49

in more than one instances features actually came to shadow-cljs before coming to CLJS itself

thheller12:03:27

but language features itself should all be supported always since we are just using the same analyzer/compiler

davidw12:03:03

that's what I thought but wanted to double check.

thheller12:03:50

feel free to ask questions if anything is unclear. helps me figure out what issues people run into when transitioning from other tools.

davidw12:03:53

thanks, I will do.

davidw12:03:56

if I do shadow-cljs watch app should that pick up changes to the dependencies in shadow-cljs.edn?

thheller12:03:31

:dependencies currently require a restart. I have some plans to fix that but its not finished yet.

thheller12:03:59

build config changes will be picked up automatically

davidw13:03:53

I'm seeing some strange behaviour with devcards. The cards display ok but don't auto reload unless I add :after-load to the :devtools config. Even if the it points to a function that does nothing.

thheller13:03:33

@davidw you can also set :autoload true. autoload is not enabled by default.

thheller13:03:56

I guess I should enable it by default to match figwheel. many people seem to expect that.

davidw13:03:38

ah, ok. I was confused because the little icon appears. I thought it was autoloading.

davidw13:03:46

So what does the little spinner icon signify then? if it's not that the code as been updated?

thheller13:03:17

comes in when the build starts and fades out when the build succeeds

davidw13:03:49

ok so it just tells you there's been a build, not that the build has been loaded?

thheller14:03:05

it is currently not coupled to the loading since we can't reliably say when the loading is completed due to async stuff you might be doing in :after-load

thheller14:03:15

but if autoload is enabled it will most likely be finished before the icon disappears

thheller14:03:28

since the animation takes a bit of time

thheller14:03:56

I never considered the fact that the loading anim shows even when autoload is disabled

davidw14:03:12

yes that seems strange to me

davidw14:03:42

it really suggests that I'm getting the latest changes when icon is displayed.

thheller14:03:10

yes, but what seems strange to you is that autoload is not enabled by default.

thheller14:03:18

if it was enabled by default you'd probably never notice

thheller14:03:50

the reason why its not enabled by default is simple

thheller14:03:01

I still have some code in production that does not use react

thheller14:03:29

autoloading only really works if you use react otherwise it can cause problems

thheller14:03:49

but I guess I should enable it by default just because of figwheel

thheller14:03:07

sames to be the more optimal choice given what people expect

davidw14:03:00

no, I don't think that's what's strange. if I was changing the code I didn't see the icon I would assume it's not autoloading and go look for how to turn it on. it's more that if the browser that I'm looking at isn't getting changes why have the icon show at all?

davidw14:03:06

and also why have the websocket connection?

davidw14:03:45

as soon as I pressed enter that popped into my head 🙂

thheller14:03:09

also you will still see warnings and errors even with autoload disabled

mhuebert16:03:50

Is there a way to indicate to shadow whether to use yarn or npm for installing packages it finds in deps.cljs files in dependencies?

mhuebert16:03:01

trying to figure out how to manage JS dependencies that are pulled in from other deps. let’s say I am requiring library "a", and it only comes from some library Lib my app depends on. step 1, first compile: shadow-cljs installs version 1 of "a" because that is what is listed in a deps.cljs file in Lib. This is added to the local package.json. step 2: Lib updates their deps file to version 1.1 of "a". step 3: after upgrading to new version of Lib, we compile again. The local, auto-installed version of "a" will not be upgraded, but a warning is printed. I think the only thing one can do here is manually update the local package.json file whenever a warning like this appears?

colindresj17:03:44

That’s what I’ve been doing @mhuebert, I hope there’s a better way, but haven’t spent the time to investigate

colindresj17:03:21

Any time I see the warning I pretty much just yarn remove a then run shadow again

justinlee18:03:31

shouldn’t i be able to change ["react-dnd-html5-backend" :default HTML5Backend] into [react-dnd-html5-backend :as react-dnd-html5-backend :refer (default) :rename {default HTML5Backend}]? When I do that, I get a perplexing runtime error: Uncaught ReferenceError: react_dnd_html5_backend is not defined on this line of code (react-dnd/DragDropContext HTML5Backend). I’m confused that it complains about react_dnd_html5_backend instead of complaining about default or HTML5Backend maybe.

justinlee18:03:06

hm well just referring to react_dnd_html5_backend/default works, so nevermind

theasp19:03:15

I don't recall seeing these before, but everything seems to work regardless:

------ WARNING #1 --------------------------------------------------------------
 File: bide/impl/helpers.js:29:41

 variable toString is undeclared
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: com/cognitect/transit.js:649:8

 variable module is undeclared
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: com/cognitect/transit/impl/writer.js:256:8

 variable isObject is undeclared
---------------------------------------

theasp20:03:16

nm, doesn't happen in 2.2.6

thheller21:03:05

@theasp the bide warning ios definitely correct. https://github.com/funcool/bide/blob/master/src/bide/impl/helpers.js#L29 toString is not declared. the transit warnings are also correct but its in conditional node code so it doesn't matter much.

theasp21:03:46

shadow-cljs ftw

theasp21:03:42

I hate how common things like this are: '[object Array]' == toString.call(val)

thheller21:03:08

@mhuebert conflict resolution with :npm-deps is icky. yarn will be used if a yarn.lock exists. there is this obscure and totally not official :node-modules {:managed-by :yarn} setting you can set in the shadow-cljs.edn top level as well.

thheller21:03:09

@lee.justin.m shadow-cljs complains like this?

justinlee21:03:48

@thheller shadow-cljs compiled it just fine. the error i got was runtime

justinlee21:03:16

it’s not a big deal because using the default property is really fine

justinlee21:03:36

i don’t want to use the string literal requires because it stops my linter from working

thheller21:03:01

there is definitely something weird going on with the rename

thheller21:03:18

please open a github issue so I don't forget