Fork me on GitHub

Yeah, you should be able to pull that off with tag readers


well, as long as you can target the same env from two different build ids, I don't recall. But you can def use tag readers to conditionally require things

Alex Miller (Clojure team)13:07:06

you can do that, but you can't define new features (like :build-1 or :other-build)


Yeah, I'm not sure what the ask is there. I one time toyed around with lazy requires, where you defined whether to require lazily loaded modules via clojure-defines, with something like:

(defn get-req-form [form]
  (->> form (filter #(and (list? %) (= :require (first %)))) first))

;; maps to #lz/ns
(defn rq [[lazy-form orig-form]]
  (if (:lz/lazy? (get-env))
    (let [req-form (get-req-form orig-form)
          new-reqs (-> lazy-form rest set)
          old-reqs (-> req-form rest set)
          not-reqs (->> orig-form (filter #(not= req-form %)))]
      (concat not-reqs
        (list (concat (list :require)
                (into old-reqs new-reqs)))))))
And then in some namespace def you could do something like:
  [(:require [com.acme.eager :as eager])
   (ns lz.suspense.reagent.example
         [cljs.loader :as loader]
         [goog.dom :as gdom]
         [reagent.core :as reagent :refer [atom]]))]
(Something like that - it's been a while) Kinda ugly though


Where get-env would get you your info out of closure-defines