This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-25
Channels
- # adventofcode (3)
- # aleph (24)
- # architecture (8)
- # beginners (53)
- # boot (34)
- # cider (7)
- # clara (68)
- # cljs-dev (6)
- # cljsrn (3)
- # clojars (10)
- # clojure (71)
- # clojure-germany (2)
- # clojure-italy (10)
- # clojure-nl (25)
- # clojure-serbia (4)
- # clojure-spec (13)
- # clojure-uk (48)
- # clojurescript (31)
- # core-async (62)
- # cursive (13)
- # datomic (4)
- # duct (76)
- # editors (4)
- # fulcro (2)
- # immutant (1)
- # instaparse (1)
- # jobs (1)
- # lein-figwheel (1)
- # mount (1)
- # off-topic (12)
- # onyx (8)
- # re-frame (10)
- # reagent (84)
- # reitit (2)
- # ring (2)
- # shadow-cljs (159)
- # spacemacs (2)
- # specter (17)
- # sql (14)
- # tools-deps (10)
- # yada (15)
:duct.compiler/cljs {:builds [{:source-paths ["src"], :build-options {:main firds-mirror.ui.core, :output-to "/Users/daniel/work/daniel-nuvo-firds-mirror/firds-mirror/target/resources/firds_mirror/public/js/main.js", :output-dir "/Users/daniel/work/daniel-nuvo-firds-mirror/firds-mirror/target/resources/firds_mirror/public/js", :asset-path "/js", :closure-defines {goog.DEBUG false}, :verbose true, :optimizations :advanced}
@weavejester is it the last task on :prep-tasks ["javac" "compile" ["run" ":duct/compiler"]]
?
Yes - I was just in the middle of writing that 🙂
You also need a config option like :resource-paths ["resources" "target/resources"]
lein run :duct/compiler
should have output.
Have you changed your -main
function in any way?
What does your -main
function look like now?
(ns mirror.main
(:gen-class)
(:require [ :as io]
[duct.core :as duct]))
(duct/load-hierarchy)
(defn -main [& args]
(let [keys (or (duct/parse-keys args) [:duct/daemon])]
(-> (duct/read-config (io/resource "mirror/config.edn"))
(duct/prep keys)
(duct/exec keys))))
It’s what’s called via lein run
.
Perhaps try putting a (doto prn)
in the thread ->
after the read-config
Make sure there is a `:duct.compiler/cljs
(ns mirror.ui.duct-cljs
(:require [clojure.string :as str]
[duct.core :as core]
[integrant.core :as ig]))
....
(derive :mirror.ui/duct-cljs :duct/module)
(defmethod ig/init-key :mirror.ui/duct-cljs [_ options]
{:fn (fn [config]
(let [path (target-public-path config options)
main (:main options)
config (if (= :production (get-environment config options))
(core/merge-configs config (compiler-config path main))
config)]
config))})
@weavejester what makes module to be run?
Only if the derive
is in a namespace you’ve already loaded.
However, why not put the derives in duct_hierarchy.edn
? That’s what it’s designed for.
Also, remind me again why you’re forgoing figwheel in development? Is there a problem with it?
By “hot reload” you mean reloading based on file change, rather than the (reset)
command?
It needs to know that the module is a module first of all, which means checking if it derives from :duct/module
.
So the derive
needs to be in place before the module is loaded.
Right, but that ns won’t be loaded unless it knows that it’s a module.
Duct looks at the keys in your configuration, determines which are modules, then loads the appropriate namespaces.
Right - but it’s being loaded after the modules.
Duct looks at a configuration and asks “Which of these are modules?” then it loads in those modules, applies them to the configuration, and then runs ig/init
across the augmented configuration.
In order to know if a key is a module, it needs the derive
already in place.
duct_hierarchy.edn
was created to provide a fast way of loading up all the key dependencies in a project, without the need to load in their namespaces.
Namespace loading in Clojure is relatively slow, so it’s worth avoiding when we can.
Right.
many thanks @weavejester
Instead of turning off Duct’s figwheel, have you considered either (a) binding a key in your editor to save-and-reset, or (b) using a file monitor library to trigger a reset on file change?