Skip to content

Commit

Permalink
CLJS-3219: Problem with asserts namespace inside goog.math.Long
Browse files Browse the repository at this point in the history
move more shareable logic into cljs.repl.bootstrap - do the goog.isProvided_
monkeypatch there - go ahead and keep a reference to the original just in case we
need it in the future.

tweak goog.require monkey patch to check if we're in the goog.module loader
and in that case return the module. This is only for goog.module - nothing
we would ever generate in ClojureScript
  • Loading branch information
swannodette committed Mar 29, 2020
1 parent bdee308 commit d3f6e57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/main/clojure/cljs/repl/bootstrap.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
"Install a version of goog.require that supports namespace reloading.
IMPORTANT: must be invoked *after* loading cljs.core."
[repl-env env]
;; monkey patch goog.provide - it throws when namespaces are loaded multiple times
;; we never care how many times a namespace is loaded it doesn't matter if
;; Google Closure Library or ClojureScript
(repl/evaluate-form repl-env env "<cljs repl>"
'(set! (.-require__ js/goog) js/goog.require))
'(set! (.-isProvided__ js/goog) js/goog.isProvided_))
(repl/evaluate-form repl-env env "<cljs repl>"
'(set! (.-isProvided_ js/goog) (fn [x] false)))
;; monkey-patch goog.require
(repl/evaluate-form repl-env env "<cljs repl>"
'(set! (.-require__ js/goog) js/goog.require))
(repl/evaluate-form repl-env env "<cljs repl>"
'(set! (.-require js/goog)
(fn [src reload]
Expand All @@ -38,4 +45,7 @@
(let [ret (.require__ js/goog src)]
(when (= reload "reload-all")
(set! (.-cljsReloadAll_ js/goog) false))
ret))))))
;; handle requires from Closure Library goog.modules
(if (js/goog.isInModuleLoader_)
(js/goog.module.getInternal_ src)
ret)))))))
3 changes: 0 additions & 3 deletions src/main/clojure/cljs/repl/node.clj
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@
(str "require("
(platform-path (conj root-path "node_repl_deps.js"))
")"))
;; monkey-patch isProvided_ to avoid useless warnings - David
(node-eval repl-env
(str "goog.isProvided_ = function(x) { return false; };"))
;; load cljs.core, setup printing
(repl/evaluate-form repl-env env "<cljs repl>"
'(do
Expand Down

0 comments on commit d3f6e57

Please sign in to comment.