Fork me on GitHub
#duct
<
2018-02-20
>
blackawa01:02:54

@lambder Hi. You cannot merge additional build option. module.cljs component adds :duct.server/figwheel configuration to your config. However, :duct.server/figwheel is defined as displace configuration. So you need to define all of configurations you need by yourself. About displace, see https://github.com/weavejester/meta-merge . About adding configuration to cljs build option, see https://github.com/duct-framework/module.cljs/issues/5 .

blackawa01:02:53

You can also read source code of module.cljs and you will know more. https://github.com/duct-framework/module.cljs/blob/master/src/duct/module/cljs.clj

weavejester01:02:35

Yes, unfortunately vectors aren’t easy to override. I’ll probably change this in future (or I’ll accept a PR to do so!), but in the meantime you can replace the :builds key in its entirety.

lambder11:02:36

I did it with module:

(ns mirror4.modules.foreign-libs
  (:require [integrant.core :as ig]))

(derive :mirror4.modules/foreign-libs :duct/module)

(defmethod ig/init-key :mirror4.modules/foreign-libs [_ foreign-libs]
  {:req #{:duct.server/figwheel}
   :fn  (fn [config]
          (let [builds                   (get-in config [:duct.server/figwheel :builds])
                builds-with-foregin-libs (mapv
                                           #(assoc-in % [:build-options :foreign-libs] foreign-libs)
                                           builds)
                ]

            (assoc-in config [:duct.server/figwheel :builds] builds-with-foregin-libs)
            )
          )})

lambder11:02:08

but I need 2 separate modules , one for figwheel another for prod cljs

lambder11:02:13

or do I miss something?

lambder11:02:37

One idea would be to have additional case for sequences, which checks is every element on the sequence is a map having an :id key. If that would be the case (as it is with cljs build config ) we could merge the corresponding elements (same :id)

lambder11:02:07

That simple (but I guess often) convention would work presumably for many configs.