Fork me on GitHub
#shadow-cljs
<
2018-08-14
>
pauld14:08:15

Just wanted to confirm: (:require ["react-virtualized" :refer (Column Table)]) does NOT do tree shaking.

pauld14:08:36

at least in :shadow mode

thheller14:08:11

correct. split it into two requires.

pauld14:08:57

so this is recommended (as in docs): (:require ["react-virtualized/dist/commonjs/AutoSizer" :default virtual-auto-sizer] ["react-virtualized/dist/commonjs/List" :default virtual-list]))

pauld14:08:12

cool thanks

thheller14:08:33

es or commonjs yes

thheller14:08:53

I would recommend the es versions

pauld14:08:43

? not sure if I understand

thheller14:08:58

in the path it says commonjs. "react-virtualized/dist/commonjs/AutoSizer"

pauld14:08:13

oh ok! haha

thheller14:08:13

they do actually ship 2 versions which are bundled slightly differently

thheller14:08:20

its a bit more efficient to use the es version "react-virtualized/dist/es/AutoSizer"

👍 4
urbanslug14:08:07

Is there a way to do feature flags without env vars?

thheller14:08:53

no idea what you mean by that?

urbanslug15:08:05

sorry I'll explain later

djtango15:08:20

hey folks - does anyone have any externs handy for using express?

djtango15:08:46

advanced optimisations are clobbering the lib's vars

djtango15:08:49

we already had :infer-externs :auto turned on and changing to simple (instead of advanced) solved the issue

djtango15:08:11

though there could be another interrelated setting that bungled stuff

thheller15:08:23

and you didn't get any warnings?

djtango16:08:25

Hmm just speaking with my team-member it was specifically to do with some middleware and an exception handling callback

thheller16:08:31

hmm? do you mean that the JS is accessing a property from CLJS that is getting renamed?

djtango16:08:48

I feel I can see how that might be harder to infer - let me dive a bit deeper.

djtango16:08:04

I'll see if I can put together a minimal replication

thheller16:08:09

infer works for anything where you access a JS property from CLJS

thheller16:08:13

not the other way around

djtango16:08:16

ok that's interesting, I can see a line which looks suspect so I'll take a look at that specific bit

richiardiandrea16:08:14

I receive a couple of warnings with transit-cljs, not a big deal, just wanted to report them:

------ WARNING #2 -------------------------------------------------------------- 
File: com/cognitect/transit/impl/writer.js:256:8
variable isObject is undeclared
--------------------------------------------------------------------------------
------ WARNING #3 --------------------------------------------------------------
 File: com/cognitect/transit/types.js:384:70
 variable Buffer is undeclared

richiardiandrea16:08:29

also, is there a way to disable warning colors?

thheller16:08:35

yeah. known issue. can't do anything about that

thheller16:08:10

colors off isn't exposed so I guess its not possible

richiardiandrea16:08:42

is anything we can do about that > contributing it? it is quite annoying in CI 😄

richiardiandrea16:08:06

actually...let me explore the code 😉

thheller16:08:21

there is a shadow.build.warnings/*color* binding

richiardiandrea16:08:16

but yeah...will get back to you, thanks for now 😄

kenny17:08:10

If I run shadow-cljs release app, the first time I will get an error compiling my code but subsequent runs the error is not printed. This behavior does not make sense to me.

thheller17:08:48

what is the error?

kenny17:08:24

------ ERROR -------------------------------------------------------------------
 File: /home/kenny/compute_software/ui-frontend/src/compute/ui_frontend/core.cljs:41:3
--------------------------------------------------------------------------------
  38 |   []
  39 |   (s/check-asserts true)
  40 |   (set! s/*explain-out* expound/printer)
  41 |   (st/instrument)
---------^----------------------------------------------------------------------
Unable to resolve var: def-command-spec in this context at line 41 compute/ui_frontend/core.cljs
--------------------------------------------------------------------------------

kenny17:08:47

Updating to 2.5.0 to see if the problem still occurs.

thheller17:08:12

pretty sure that st/instrument is never going to work in :advanced?

kenny17:08:12

def-command-spec is a macro BTW.

kenny17:08:32

Updated to 2.5.0 and still have the issue.

kenny17:08:19

I'm not sure why that code is even getting compiled. It is located in this function:

(defn init-dev-tools
  []
  (s/check-asserts true)
  (set! s/*explain-out* expound/printer)
  (st/instrument)
  nil)
which is called like this:
(when ^boolean goog.DEBUG
  (init-dev-tools))

thheller17:08:53

I would recommend putting stuff like this into an extra ns and use :preloads

thheller17:08:12

the ns that is in will stilll have the st and expound requires otherwise

thheller17:08:22

but as far as the problem goes I'm not actually sure

thheller17:08:50

instrument is a funky macro

kenny17:08:01

Ok, I can do that. I would've thought that because that function call never occurs DCE would remove expound and st.

thheller17:08:36

yeah don't rely on DCE too much. there are lots of things that it can't remove. especially things the st ns does

kenny17:08:33

I'll try moving that stuff to a preload. FWIW, def-command-spec is a Spec'ed macro.

thheller17:08:13

I'm not entirely sure why it doesn't fail the second time though

thheller17:08:21

oh wait I actually do

kenny17:08:25

Oh, and the problem only occurs when I call def-command-spec in the same ns it is defined in.

thheller17:08:28

st/instrument is a side effecting macro

thheller17:08:49

but the ns is still cached so the side effects won't happen when using the cached code

thheller17:08:20

yeah don't ever call that in a release build. even when its supposed to be DCE'd

kenny17:08:05

Are preloads called every time code reloads?

thheller17:08:35

no but you can force it via (ns ^:dev/always your.preloads)

thheller17:08:48

just make sure that your "preload" depends on your main entries

thheller17:08:05

otherwise the st/instrument code won't actually instrument anything since your code isn't loaded yet

kenny17:08:55

Will that force everything to be reloaded every time?

thheller17:08:14

hmm? no only that ns

kenny17:08:38

Even though it depends on my main entries?

thheller17:08:55

that doesn't matter since they don't depend on the preload

thheller17:08:45

gotta go, bbl

davidst20:08:22

What's the way to resolve classpath conflicts in the most recent 2.5.0 version of shadow cljs? I have tried the re-frame conduit example. The compilation errors out because apparently an old version of re frame gets loaded. It's surprising because the dependencies vectors in shadow-cljs.edn explicitly lists a more recent version of re-frame. I have tried using exclusions but couldn't get it to work either.

thheller20:08:20

shadow-cljs deps-tree is new

thheller20:08:52

interesting error

thheller20:08:55

looking into it

thheller20:08:14

reagent is an explicit dependency but re-frame depends on reagent/reagent. guess tools.deps doesn't de-dupe those

thheller20:08:24

hmm or its just me using it wrong

thheller20:08:29

can't replicate with clj alone

thheller20:08:52

@davidst should be fixed in 2.5.1

davidst20:08:55

@thheller great thank you

pauld22:08:23

Suppose I want to use some javascript library only while in development. How would one go about setting this up?

pauld22:08:05

{:devtools {:preloads ...?

pauld22:08:16

But then do I have to require this code in a namespace that is not reachable from the build's :entries?

pauld22:08:43

or is :preloads only for clojure dependencies (not clojurescript or javascript)?

pauld22:08:46

I suppose what I want to do is just have a clojurescript file under at dev/usr.cljs.

pauld22:08:01

I'll see if I can use this code by eval'ing in cider-emacs I suppose this code that get required in dev/user.cljs will not get included in any build output provided it isn't called via code in the :entries namespaces.

thheller22:08:39

yes :preloads is for dev-only code. the ns included via :preloads must however not the required by anything else

👍 4
thheller22:08:07

otherwise you might just leave it out of :preloads entirely since it will be included anyways

richiardiandrea23:08:26

aaaarg so excited about the new runtime dep feature........

shadow.user> (shadow/reload-deps! '{specs {:local/root "../spec-cljs"}})
:shadow.cljs.devtools.api/standalone-only
shadow.user> 

richiardiandrea23:08:07

so nice that we have it in there though