Fork me on GitHub
#duct
<
2018-05-22
>
lambder11:05:56

@weavejester I've followed your advice with slight modification. I created my own module as I need an access to the config (compile paths). Now how can I overwrite :duct.compiler/cljs in the development env?

weavejester13:05:46

@lambder I’m not sure I understand the question. You just check to see if :duct.core/environment is :development or :production, and modify things accordingly. May I ask why you want to use lein figwheel over Duct’s integrated Figwheel?

lambder13:05:10

yes, that is one way

lambder13:05:23

but using this example I have a general question

lambder13:05:37

how you can override what modules have done

lambder13:05:15

e.g. in development config I'd like to have :duct.compiler/cljs nil to remove the generated config

lambder13:05:22

is it possible ?

weavejester13:05:59

Sure. Modules are designed to defer to the user’s configuration, and if you’re writing your own module you can set it after the cljs module. Or just not include the cljs module at all.

lambder13:05:01

it would be useful if you don't control the module and you'd like to overwrite it

lambder13:05:43

so my prod uses a module which sets the compiler/cljs regardles of the environment

lambder13:05:55

I'd like to shadow it in development

lambder13:05:05

or let me ask differently

lambder13:05:28

are the modules run after the config is read?

weavejester13:05:53

The modules are functions that are applied to the configuration after it is read.

lambder13:05:07

ok, got it

weavejester13:05:08

They run after any :duct.core/includes are added.

lambder13:05:50

So there is no way to overwrite what 3rd party modules are doing to your config

weavejester13:05:34

You can, just by running after them.

lambder13:05:52

programatically ?

lambder13:05:04

or can i do it declaratively?

weavejester13:05:09

You can set a module’s dependencies, making it dependent on there being certain keys in the configuration.

weavejester13:05:45

So you can create a module that is dependent on the :duct.module/cljs key already being available, for example.

weavejester13:05:50

In the next version of Duct the dependency resolution of modules is improved further, but I’m still working on that.

weavejester13:05:47

The next version of Duct should be out in a month or two, and uses Integrant’s refs and refsets as the dependency resolution mechanism, instead of a :req key as it is currently.

weavejester13:05:25

May I also enquire why you’re using lein figwheel over the inbuilt figwheel?

iarenaza15:05:58

@weavejester I'm trying to do something quite similar, but I'm not sure I'm doing it right. I want my module to be run after duct.module/cljs has been run. I'm using :req #{duct.module/cljs} in my init-key multi-method, but when my module function is run, I don't see any of duct.module/cljs keys in the config var. Right now I'm using a dirty hack to achieve what I need: I add a #ig/ref to :duct.module/cljs in my module config map, and then invoke the :duct/module/cljs function myself before running my module's code.

weavejester16:05:47

@iarenaza That might be a result of how the modules dependencies are currently worked out. The next version should have much better dependency resolution of modules.

iarenaza17:05:39

So I guess I'll need to keep the dirty hack for the time being. Thanks anyway for your feedback (and of course for your fantastic work on Duct!)