Fork me on GitHub
#shadow-cljs
<
2021-03-04
>
dpsutton07:03:22

we're working on adding an :npm-module output into a webpacked js frontend at work. One footgun is that forgetting to mark things with ^:export has no consequence during dev time but is obviously catastrophic at release time. Is it possible to have the dev build munge names so that we can kinda feel this pain under dev settings and not just in CI or (gasp) released?

thheller08:03:28

@dpsutton no, the closure compiler does the munging and that is not used in dev builds

thheller08:03:55

you might want to use :target :esm. there the exports are configured in the build config so no ^:export there

dpsutton08:03:41

yeah that builds up a big build config so probably better to just go with ^:export

dpsutton08:03:23

also, is there a way to get around enumerating every namespace in the :entries vector? Basically everything will be compiled either directly or transitively so would be nice to just get all namespaces for free.

dpsutton08:03:39

i was a cljs dev for 3 or so years and i'm excited that i'll finally be able to use shadow in a work product. its all been lein-figwheel because the projects were set up when that was the only game in town and wasn't worth changing over

thheller08:03:45

@denik that is not possible if you want to use :advanced optimizations (which you should for browser builds). with one small adjustments you can just interpret the EDN though: turn functions into actual data. for [example](https://github.com/thheller/shadow-cljs/blob/f0a2ae8e9cfdbadc19641bd89327b3fb496733d3/src/main/shadow/cljs/ui/components/inspect.cljs#L107) in the stuff I'm building you'd say :on-click {:e :some.ns/foo! :with "some" :other "args" :maybe true} (just data). yes that limits you to only using events that already exist but that might be enough for you

denik17:03:18

makes sense. thanks @thheller!

thheller08:03:35

@dpsutton I recently changed the logic back so that an emptry :entries [] is allowed again

thheller08:03:45

that'll just give you all found namespaces

dpsutton08:03:57

oh nice. i saw a spec error that indicated it needed at least one simple simple. maybe we need a newer version

ribelo08:03:23

@denik I did something very similar for fun. I had a re-frame on the front. Using sente I both passed hiccup data that was written to the db, and instead of sending functions, I sent re-frame event keys. If you wanted to send functions though, you could use sci

denik17:03:07

interesting idea to use sci! I’ll ponder it

ribelo09:03:50

reagent interprets hiccup in runtime, so you can fetch data from the db and simply render it when received.

mkvlr14:03:17

@thheller you recomment letting shadow bring in the ClojureScript dep, correct? Asking because I want to give https://github.com/clojure/clojurescript/commit/715cdc07dbb1d595af91ea12affb6faf0b615d4b a try

mkvlr14:03:01

do you expect issues when requiring a cljs version explicitly?

mkvlr14:03:51

seeing this now:

Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1).
com.google.javascript.jscomp.AnonymousFunctionNamingPolicy

thheller16:03:28

it might work if you use master yes. I still haven't checked all the closure-library/compiler related changes and verified they work

thheller16:03:59

that AnonymousFunctionNamingPolicy issue is fixed but there might be others I'm not yet aware of since the closure-lib has undergone some rather big changes too

thheller16:03:35

I'll likely test the CLJS master myself later or tomorrow if you want to wait 😉

👍 6
thheller21:03:32

tested CLJS master with the latest closure-compiler and library and everything appears to work fine

🎉 12