Fork me on GitHub
#duct
<
2020-02-10
>
g7s09:02:10

If anyone is using duct and develops ClojureScript using shadow-cljs I have put together a module for that https://github.com/g7s/module.shadow-cljs

🎉 8
teodorlu10:02:14

I was looking for just this a few months ago. Thanks for releasing! Are you following the Duct reloading scheme, so that Duct controls when the CLJS source is reloaded?

g7s10:02:11

The updates to the cljs source are done by shadow because AFAIK it doesn't provide an API so that we can do this programmatically. If you are willing to investigate further I will be glad to help in the process.

g7s11:02:36

Now that I think about it shadow has this kinda built in. You can pass to a build :devtools {:watch-options {:autobuild false}} and then from the repl call (shadow.cljs.devtools.api/watch-compile-all!) to trigger a compilation of all your builds. Is that something you would like to see done automatically by the duct module? say that if for a build :autobuild is false then (reset) will do the (shadow.cljs.devtools.api/watch-compile-all!) thing?

teodorlu15:02:34

No strong preference, but I'm curious about the question and any experience reports. I haven't used Duct and/or Clojurescript in a while, so I'm not certain what behavior would be best. I do remember recalling Luminus starting to become really heavy once auto-compiling CLJS was turned on, which slowed down my REPL reduced developer experience somewhat.

g7s16:02:56

I have no experience with Luminus but I know that shadow is pretty fast. I am working on a sizable project and the compile times are barely noticeable. I actually use the autobuild and I am pretty happy

👍 4
Chris C14:02:14

Hi, perhaps a silly question. I've got a bit of middleware within the config that I want to have different behaviour in the tests than in prod. I was thinking to pass the implementation I want, depending on the environment, but not sure how to do this. Thanks for the help in advance

weavejester14:02:15

You can add a :duct.profile/test profile to your configuration with the overrides you need, and only activate that in tests.

Chris C15:02:16

Sorry for the stupid question, but how do I do that? I'm rather new to Clojure. I've got a profile being used for tests, but not sure how to replace the implementation of the middleware and not the routes.

Chris C15:02:35

I'm not sure if that is too specific to the implementation to be of help

Kevin16:02:47

You can change the arguments passed into the implementation (init-key) of your middleware. :duct.profile/test can use other keys instead of your prod implementation. Then the middleware implementation can look at those keys and do whatever it needs to do based on that

weavejester16:02:00

When the test profile and base profiles are merged together, any configuration in the test profile overrides configuration in the base profile, similarly to how Leiningen profiles work.

Kevin16:02:34

Simple example (just pseudo code, not tested). Skip the auth middleware if test is running.

Kevin16:02:35

Not sure if this is really good practice, since you're putting test related logic in the middleware

Kevin16:02:22

However, if I'm not mistaken. This is how you could add arguments to keys in specific profiles