File tree Expand file tree Collapse file tree 3 files changed +41
-19
lines changed Expand file tree Collapse file tree 3 files changed +41
-19
lines changed Original file line number Diff line number Diff line change 193193 (if-not (nil? env/*compiler*)
194194 env/*compiler*
195195 (env/default-compiler-env
196- (closure/add-externs-sources opts)))))
196+ ; ; need to dissoc :foreign-libs since we won't know what overriding
197+ ; ; foreign libspecs are referring to until after add-implicit-options
198+ ; ; - David
199+ (closure/add-externs-sources (dissoc opts :foreign-libs ))))))
197200 ([source opts compiler-env]
198201 (doseq [[unknown-opt suggested-opt] (util/unknown-opts (set (keys opts)) closure/known-opts)]
199202 (when suggested-opt
Original file line number Diff line number Diff line change 19951995 (string/includes? p' " _" )
19961996 (conj (string/replace p' " _" " -" )))))
19971997 (expand-lib* [{:keys [file] :as lib}]
1998- (let [root (.getAbsolutePath (io/file file))
1999- dir (io/file file)]
2000- (if (.isDirectory dir)
2001- (into []
2002- (comp
2003- (filter #(.endsWith (.getName ^File %) " .js" ))
2004- (filter #(not (.isHidden ^File %)))
2005- (map
2006- (fn [^File f]
2007- (let [p (.getPath f)
2008- ap (.getAbsolutePath f)]
2009- (merge lib
2010- {:file p :provides (path->provides (prep-path ap root))})))))
2011- (file-seq dir))
2012- [lib])))]
1998+ (if-not file
1999+ [lib] ; ; foreign-lib override case - David
2000+ (let [root (.getAbsolutePath (io/file file))
2001+ dir (io/file file)]
2002+ (if (.isDirectory dir)
2003+ (into []
2004+ (comp
2005+ (filter #(.endsWith (.getName ^File %) " .js" ))
2006+ (filter #(not (.isHidden ^File %)))
2007+ (map
2008+ (fn [^File f]
2009+ (let [p (.getPath f)
2010+ ap (.getAbsolutePath f)]
2011+ (merge lib
2012+ {:file p :provides (path->provides (prep-path ap root))})))))
2013+ (file-seq dir))
2014+ [lib]))))]
20132015 (into [] (mapcat expand-lib* libs))))
20142016
20152017(declare index-node-modules )
24322434 (if-not (nil? env/*compiler*)
24332435 env/*compiler*
24342436 (env/default-compiler-env
2435- (add-externs-sources opts)))))
2437+ ; ; need to dissoc :foreign-libs since we won't know what overriding
2438+ ; ; foreign libspecs are referring to until after add-implicit-options
2439+ ; ; - David
2440+ (add-externs-sources (dissoc opts :foreign-libs ))))))
24362441 ([source opts compiler-env]
24372442 (env/with-compiler-env compiler-env
24382443 ; ; we want to warn about NPM dep conflicts before installing the modules
Original file line number Diff line number Diff line change @@ -130,6 +130,16 @@ case."
130130 (-requires [this] " A list of namespaces that this JavaScript requires." )
131131 (-source [this] [this opts] " The JavaScript source string." ))
132132
133+ (defn get-file [lib-spec index]
134+ (or (:file lib-spec)
135+ (some (fn [provide] (get-in index [provide :file ]))
136+ (:provides lib-spec))))
137+
138+ (defn lib-spec-merge [a b]
139+ (merge a
140+ (cond-> b
141+ (contains? a :provides ) (dissoc :provides ))))
142+
133143(defn build-index
134144 " Index a list of dependencies by namespace and file name. There can
135145 be zero or more namespaces provided per file. Upstream foreign libraies
@@ -143,7 +153,7 @@ case."
143153 (reduce
144154 (fn [index' provide]
145155 (if (:foreign dep)
146- (update-in index' [provide] merge dep)
156+ (update-in index' [provide] lib-spec- merge dep)
147157 ; ; when building the dependency index, we need to
148158 ; ; avoid overwriting a CLJS dep with a CLJC dep of
149159 ; ; the same namespace - António Monteiro
@@ -159,7 +169,11 @@ case."
159169 index provides)
160170 index)]
161171 (if (:foreign dep)
162- (update-in index' [(:file dep)] merge dep)
172+ (if-let [file (get-file dep index')]
173+ (update-in index' [file] lib-spec-merge dep)
174+ (throw
175+ (Exception.
176+ (str " No :file provided for :foreign-libs spec " (pr-str dep)))))
163177 (assoc index' (:file dep) dep))))
164178 {} deps))
165179
You can’t perform that action at this time.
0 commit comments