Skip to content

Commit 514274c

Browse files
authored
Merge pull request #108 from clojure/cljs-3330
CLJS-3330: Flag for legacy loading of goog.object & goog.array
2 parents 76ac6bf + 1a9a10f commit 514274c

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/main/clojure/cljs/analyzer.cljc

+8-2
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,14 @@
815815
(defn goog-module-dep?
816816
[module]
817817
(let [[module _] (lib&sublib module)
818-
module-type (get-in @env/*compiler* [:js-dependency-index (str module) :module])]
819-
(= :goog module-type)))
818+
module-str (str module)
819+
options (compiler-options)]
820+
;; CLJS-3330: flag for loading some old things in the old way to give time
821+
;; for library authors to migrate
822+
(if (and (:global-goog-object&array options)
823+
(#{"goog.object" "goog.array"} module-str))
824+
false
825+
(= :goog (get-in @env/*compiler* [:js-dependency-index module-str :module])))))
820826

821827
(defn confirm-var-exists
822828
([env prefix suffix]

src/main/clojure/cljs/closure.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
:watch :watch-error-fn :watch-fn :install-deps :process-shim :rename-prefix :rename-prefix-namespace
214214
:closure-variable-map-in :closure-property-map-in :closure-variable-map-out :closure-property-map-out
215215
:stable-names :ignore-js-module-exts :opts-cache :aot-cache :elide-strict :fingerprint :spec-skip-macros
216-
:nodejs-rt :target-fn :deps-cmd :bundle-cmd})
216+
:nodejs-rt :target-fn :deps-cmd :bundle-cmd :global-goog-object&array})
217217

218218
(def string->charset
219219
{"iso-8859-1" StandardCharsets/ISO_8859_1

src/test/clojure/cljs/compiler/glib_module_test.clj

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
(deftest test-glib-module-compile
77
(testing "glib modules compiled to Closure Compile expectations"
8-
(let [src (env/with-compiler-env (env/default-compiler-env)
8+
(let [src (env/with-compiler-env (env/default-compiler-env )
99
(comp-tests/compile-form-seq
1010
'[(ns test.foo
1111
(:import [goog.module ModuleLoader]))
@@ -14,6 +14,18 @@
1414
(is (re-find #"test\.foo\.goog\$module\$goog\$module\$ModuleLoader = goog\.module\.get\('goog.module.ModuleLoader'\)" src))
1515
(is (re-find #"test\.foo\.module_loader = \(new test\.foo\.goog\$module\$goog\$module\$ModuleLoader\(\)\)" src)))))
1616

17+
(deftest cljs-3330-global-goog-object&array
18+
(testing "migration path for goog.module impact on goog.object & goog.array"
19+
(let [src (env/with-compiler-env
20+
(env/default-compiler-env {:global-goog-object&array true})
21+
(comp-tests/compile-form-seq
22+
'[(ns test.foo
23+
(:require [goog.object :as gobj]
24+
[goog.array :as garray]))
25+
(def module-loader (ModuleLoader.))]))]
26+
(is (re-find #"goog\.require\('goog\.object\'\)" src))
27+
(is (re-find #"goog\.require\('goog\.array\'\)" src)))))
28+
1729
(comment
1830

1931
(test/run-tests)

0 commit comments

Comments
 (0)