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 193
193
(if-not (nil? env/*compiler*)
194
194
env/*compiler*
195
195
(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 ))))))
197
200
([source opts compiler-env]
198
201
(doseq [[unknown-opt suggested-opt] (util/unknown-opts (set (keys opts)) closure/known-opts)]
199
202
(when suggested-opt
Original file line number Diff line number Diff line change 1995
1995
(string/includes? p' " _" )
1996
1996
(conj (string/replace p' " _" " -" )))))
1997
1997
(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]))))]
2013
2015
(into [] (mapcat expand-lib* libs))))
2014
2016
2015
2017
(declare index-node-modules )
2432
2434
(if-not (nil? env/*compiler*)
2433
2435
env/*compiler*
2434
2436
(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 ))))))
2436
2441
([source opts compiler-env]
2437
2442
(env/with-compiler-env compiler-env
2438
2443
; ; 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."
130
130
(-requires [this] " A list of namespaces that this JavaScript requires." )
131
131
(-source [this] [this opts] " The JavaScript source string." ))
132
132
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
+
133
143
(defn build-index
134
144
" Index a list of dependencies by namespace and file name. There can
135
145
be zero or more namespaces provided per file. Upstream foreign libraies
@@ -143,7 +153,7 @@ case."
143
153
(reduce
144
154
(fn [index' provide]
145
155
(if (:foreign dep)
146
- (update-in index' [provide] merge dep)
156
+ (update-in index' [provide] lib-spec- merge dep)
147
157
; ; when building the dependency index, we need to
148
158
; ; avoid overwriting a CLJS dep with a CLJC dep of
149
159
; ; the same namespace - António Monteiro
@@ -159,7 +169,11 @@ case."
159
169
index provides)
160
170
index)]
161
171
(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)))))
163
177
(assoc index' (:file dep) dep))))
164
178
{} deps))
165
179
You can’t perform that action at this time.
0 commit comments