Fork me on GitHub

I fear I’m missing something really basic, but can someone help me work out how to call goog.string functions in a project compiled with auto-bundling? The problem seems to only be with goog.string - I’m able to call plenty of other Javascript functions. I can reproduce the problem in a toy example: 1. Create a project with lein new figwheel-main hello-world.core -- +npm-bundle --reagent 2. Edit core.cljs to add:

[goog.string :as gstring]
to the list of :required libraries, and then change hello-world to:
(defn hello-world []
   [:h1 (:text @app-state)]
   [:h3 (gstring/format "The text reads: %s" (@app-state :text))]])
Building with lein fig:build works fine. Build with lein fig:min and it gives the following at runtime:
TypeError: f.format is not a function. (In 'f.format("The text reads: %s",r)', 'f.format' is undefined)
I’ve tried every :require variation and every combination of js/ or #js, and nothing I’ve come up with has persuaded Closure to leave the name alone. I’m sure I’m missing something really simple and obvious, but I’m damned if I can find it. Any pointers would be very gratefully received!


@paulbutcher I think format is a bit weird in how it's used


That I believe!

dominicm12:12:06 see how it's provide by "goog.string.format"? That means you also have to require goog.string.format. But requiring it mutates goog.string, so you still call goog.string/format. Confusing, right!


OMG. And if I do that (change the :require line to [goog.string.format] and then call goog.string/format it works fine 😳