duct

g7s 2020-02-10T09:41:10.021300Z

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

🎉 2
teodorlu 2020-02-10T10:27:14.021600Z

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?

g7s 2020-02-10T10:31:11.021800Z

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.

g7s 2020-02-10T11:02:36.022Z

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?

teodorlu 2020-02-10T15:05:34.025800Z

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.

g7s 2020-02-10T16:08:56.026400Z

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

👍 1
Chris C 2020-02-10T14:53:14.025500Z

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

weavejester 2020-02-10T14:55:15.025600Z

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

Chris C 2020-02-10T15:13:16.026Z

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 C 2020-02-10T15:13:35.026200Z

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

2020-02-10T16:13:47.026600Z

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

weavejester 2020-02-10T16:14:00.026800Z

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.

2020-02-10T16:19:34.027Z

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

2020-02-10T16:20:35.027500Z

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

2020-02-10T16:21:22.027700Z

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