Fork me on GitHub
#shadow-cljs
<
2022-06-02
>
barrell10:06:29

I started using meta data to flag some functions in different namespaces. I wrote a shadow-cljs hook that compiles a manifest based off of the metadata of functions in different file. This worked great for development. However, no matter the optimization level I choose, when I go to do a release the value of (get-in build [:compiler-env :cljs.analyzer/namespaces]) is nil. Is this sort of data located somewhere else for release builds? If not, is there a recommended approach for providing such data to a release build? edit: actually the :compiler-env key is not present at all ๐Ÿ˜ž

thheller10:06:19

that info is unaffected by the optimizations and should always be available

thheller10:06:38

which stage are you using it in?

thheller10:06:53

:compiler-env is also present always? otherwise pretty much everything would fail ๐Ÿ˜›

barrell10:06:44

This is the printed value from (pprint (sort (keys build))) :thinking_face:

barrell10:06:24

the hook runs in :configure and :compile-prepare

thheller10:06:59

at neither of those stages has any CLJS been compiled so :cljs.analyzer/namepaces will indeed be missing or empty?

thheller10:06:31

I guess during development you are relying on caching or watch re-entering the :compile-prepare with data from the previous compile?

barrell10:06:41

haha probably

barrell10:06:00

my hooks currently cause it to always rebuild twice (havenโ€™t looked into that yet) thatโ€™s probably what was saving me

thheller10:06:29

are you creating files in that hook that will then be used in the compilation? if so don't ๐Ÿ˜‰

barrell10:06:31

accidental driven development

barrell10:06:51

It generates a routing manifest thatโ€™s used by the router ๐Ÿ˜ญ

barrell10:06:12

so I can mark which functions are routes for which url

thheller10:06:16

just use a macro?

barrell10:06:34

all of the routes are code split

thheller10:06:44

just use a macro in each split? ๐Ÿ˜›

barrell10:06:50

then there is a base app that loads the files and renders the route

barrell10:06:04

how would the app know which routes are availble from a macro?

barrell10:06:23

since that macro would only effect the code in the respective split

thheller10:06:55

well what you could do in the hook is generate is manifest that you actually load dynamically at runtime

thheller10:06:01

like .json file or something

barrell10:06:09

I can just only spit the file when :compiler-env is present, and rely on an outdated version for now

barrell10:06:32

actually yeah that could work - I guess I could load that from the index.html

thheller10:06:07

I've been thinking about how to do compile-on-demand in hooks

thheller10:06:20

but still no clue how to get that all working properly with caching and hot-reload and everything else ๐Ÿ˜›

barrell10:06:28

would like to avoid a index.html loading app loading manifest loading split loading component situation ๐Ÿ˜…

barrell10:06:46

> but still no clue how to get that all working properly with caching and hot-reload and everything else you and me both! ๐Ÿ˜‰

thheller10:06:55

if you generate the .json in a hook

thheller10:06:01

you could inline that json in your HTML

thheller10:06:13

saves that extra load you are worried about ๐Ÿ˜‰

barrell10:06:27

well good thing I also have a hook for inlining build data into hiccup files to build my html awesome

barrell10:06:52

I will do what you said

barrell10:06:56

ty for the quick response

p-himik14:06:24

This looks wild, and awesome.

๐Ÿ‘ 5
1
grav16:06:55

What's the source?

geraldodev15:06:19

Daylight testimony that in shadow we trust ๐Ÿ™‚

Sturm22:06:18

If I want to include re-frame10x as a dependency, am I safe to include it under the top-level :dependencies and rely on it being dead-code-eliminated when it's not loaded in a production build? Or is there a better place to specify it as a dependency?