Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

I have a mobile app that works fine when using clojurescript version 1.10.879.
As soon as I upgrade to 1.10.891 or 1.10.893 I start getting the following errors and my app stops working

TypeError: undefined is not an object (evaluating 'some-ns.goog$module$goog$object.get')

3 Answers

+2 votes
by

You should add an explicit (:require [goog.object]) in your namespace declarations. If you're using libraries where you cannot change this yourself, use global-goog-object&array.

See documentation:
https://clojurescript.org/news/news#_google_closure_library_goog_module_global_access

by
Noted, will add the require wherever possible.
+1 vote
by

The update did not break goog.object, it only broke "global" access to it. This means that any namespace using goog.object/get directly without a proper (:require [goog.object :as ...]) in its ns form will now break. You can no longer rely on goog namespaces being globally available. Technically this was never valid but could sort of be relied on since cljs.core requires goog.object and such ensured that it is always loaded.

So to fix this properly all you need is to add a goog.object require.

However there is a more subtle issue that is related to macros. Some libraries may have macros that emit forms directly accessing goog.object/get or so. This will now also break even if the namespace using that macro is doing everything properly. This is happening because the namespace using the macro likely doesn't have a goog.object require of its own (and shouldn't need to have it).

Unfortunately due to that changes the macros need to be rewritten to either use their own helper functions which then can use goog.object properly or switching to using unchecked-get and unchecked-set which are basically equivalent to goog.object/get and goo.object/set.

As per the announcement a compiler option was added to make the transition a little more smooth.

So if the problem is in your own code you just need to add the ns require. If its in a library it needs to be fixed there. Or you may use the compiler option :global-goog-object&array until it is fixed.

0 votes
by

It seems this was addressed in CLJS-3330. The fix introduced the compiler option global-goog-object&array:

Defaults to false. If true load goog.object and goog.array as global namespaces rather than as goog.module namespaces.

by
Thanks for that it's all good now.
...