Skip to content

Commit 0b8cff8

Browse files
anmonteiroswannodette
authored andcommitted
CLJS-2309: :module foreign-libs order not preserved
this patch adds a test that demonstrates the issue is no longer reproducible
1 parent f5cd5f9 commit 0b8cff8

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

src/test/cljs_build/loader_test/foo.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
(:require [goog.dom :as gdom]
33
[goog.events :as events]
44
[cljs.loader :as loader]
5-
;[my.foreign]
6-
)
5+
[foreign.a]
6+
[foreign.b])
77
(:import [goog.events EventType]))
88

99
(enable-console-print!)

src/test/cljs_build/loader_test/foreign.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
global.foreignA = function() {
2+
console.log("I'm foreign!")
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
global.foreignB = function() {
2+
console.log("I'm foreign too!");
3+
};

src/test/clojure/cljs/build_api_tests.clj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,11 @@
186186
{:output-dir output-dir
187187
:optimizations :none
188188
:verbose true
189-
;:foreign-libs [{:file "loader_test/foreign.js"
190-
; :provides ["my.foreign"]}]
189+
:foreign-libs [{:file "src/test/cljs_build/loader_test/foreignA.js"
190+
:provides ["foreign.a"]}
191+
{:file "src/test/cljs_build/loader_test/foreignB.js"
192+
:provides ["foreign.b"]
193+
:requires ["foreign.a"]}]
191194
:modules
192195
{:foo
193196
{:output-to (str (io/file output-dir "foo.js"))
@@ -213,7 +216,13 @@
213216
(test/delete-out-files out)
214217
(let [{:keys [inputs opts]} (merge-with merge (loader-test-project out)
215218
{:opts {:optimizations :whitespace}})]
216-
(build/build (build/inputs inputs) opts)))))
219+
(build/build (build/inputs inputs) opts)))
220+
(testing "CLJS-2309 foreign libs order preserved"
221+
(test/delete-out-files out)
222+
(let [{:keys [inputs opts]} (merge-with merge (loader-test-project out)
223+
{:opts {:optimizations :advanced}})]
224+
(build/build (build/inputs inputs) opts)
225+
(is (not (nil? (re-find #"foreignA[\s\S]+foreignB" (slurp (io/file out "foo.js"))))))))))
217226

218227
(deftest test-npm-deps
219228
(test/delete-node-modules)

0 commit comments

Comments
 (0)