shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
dpsutton 2021-03-04T07:33:22.225800Z

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?

thheller 2021-03-04T08:14:28.226300Z

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

thheller 2021-03-04T08:14:55.226900Z

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

dpsutton 2021-03-04T08:16:41.228700Z

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

dpsutton 2021-03-04T08:17:23.230100Z

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.

dpsutton 2021-03-04T08:18:39.231500Z

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

thheller 2021-03-04T08:18:45.231700Z

@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

thheller 2021-03-04T08:19:35.232200Z

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

thheller 2021-03-04T08:19:45.232600Z

that'll just give you all found namespaces

dpsutton 2021-03-04T08:19:57.232900Z

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

2021-03-04T08:47:23.233100Z

@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

2021-03-04T09:39:50.233300Z

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

mkvlr 2021-03-04T14:07:17.234100Z

@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

mkvlr 2021-03-04T14:13:01.235200Z

do you expect issues when requiring a cljs version explicitly?

mkvlr 2021-03-04T14:22:51.235400Z

seeing this now:

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

mkvlr 2021-03-04T14:38:56.235800Z

oh, I see thatโ€™s fixed by bumping shadow and getting https://github.com/thheller/shadow-cljs/commit/d0451aba279689bc74ae5340e83b2466e4bdb237

thheller 2021-03-04T16:20:28.236700Z

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

thheller 2021-03-04T16:20:59.237300Z

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

thheller 2021-03-04T16:24:35.238Z

I'll likely test the CLJS master myself later or tomorrow if you want to wait ๐Ÿ˜‰

๐Ÿ‘ 2
denik 2021-03-04T17:25:18.238400Z

makes sense. thanks @thheller!

denik 2021-03-04T17:26:07.238600Z

interesting idea to use sci! Iโ€™ll ponder it

thheller 2021-03-04T21:43:32.239400Z

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

๐ŸŽ‰ 4