Fork me on GitHub
#shadow-cljs
<
2021-03-19
>
superstructor13:03:01

If I want to rewrite cljs sources during compilation is there a way to use build hooks to get the result of reading the forms and manipulate the forms prior to macro expansion ? The only way I have figured out so far is hooking into compile-prepare and replacing every cljs file in build state with one at a different tmp path that has been modified. Thoughts ?

thheller13:03:19

what kind of "rewrite" are you thinking about?

thheller13:03:49

currently there is no way to hook into the compiler at that level

pfeodrippe14:03:21

Hi there o/ Is there any way that I could create standalone js files for each of the entries (or modules)? Or should I create a new build for each (could I watch them all at the same time, I guess it's doable from my part if this is the only way o/)? In the example below, it outputs a shared.js file, it's fine, but standalone would be good for now (I'm trying to use Cypress).

{:builds :....
 {:target :browser
  :output-dir "out/testtt"
  :compiler-options {:infer-externs :auto}
  :modules {:shared {:entries [cypress.core]}
            :cypress.blablabla.edit-test
            {:entries [cypress.blablabla.edit-test]
             :depends-on #{:shared}}

            :cypress.blablabla.add-test
            {:entries [cypress.blablabla.add-test]
             :depends-on #{:shared}}}}}
And thanks for this very awesome piece of software, Thomas o/

mauricio.szabo14:03:34

@pfeodrippe IFAIK, when you compile the release version, each module will be a single JS file

👍 4
thheller14:03:09

I don't understand the question? the whole point of modules is creating multiple files? if you only want one file only use one module?

pfeodrippe15:03:40

Oh sorry, I want to create a standalone file for each cypress.blablabla... namespace, right now it creates a thin js file for each, it gives me SHADOW_ENV is not defined error. The only way to do this is through a build (maybe any other dynamic way)?

thheller15:03:22

I'm missing some basic information I guess. you are supposed to load the shared.js first before loading the other module

thheller15:03:33

(that is where SHADOW_ENV comes from)

thheller15:03:08

why does it have to be a standalone file?

thheller15:03:29

I have never used cypress so I don't have a clue how it works

thheller15:03:56

but to answer your question: no, there is no way to make modules standalone using shadow-cljs

thheller15:03:25

you could do it yourself by just concatenating shared.js + the module file

thheller15:03:31

but I don't get why you'd need to do that

pfeodrippe15:03:05

Oh, thanks. Yes, to load shared.js before appears to be the best approach, I just wanted to check if there was another way. Thanks, @thheller and @mauricio.szabo o/

thheller15:03:56

well technically the :target abstraction in shadow-cljs would allow for a :target :cypress and then just take the minimum amount of config to emit the output that fits best for cypress

thheller15:03:20

but that is going to be a bit of work since none of the underlying code is documented 😉

pfeodrippe15:03:28

Oh very nice! Well, I can check how karma (or some simpler one) works, thanks again o/