This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-20
Channels
- # announcements (33)
- # aws (1)
- # babashka (8)
- # beginners (100)
- # calva (59)
- # clara (4)
- # clj-kondo (33)
- # cljdoc (9)
- # cljs-dev (30)
- # cljsrn (1)
- # clojure (24)
- # clojure-australia (1)
- # clojure-boston (1)
- # clojure-dev (4)
- # clojure-europe (14)
- # clojure-france (5)
- # clojure-italy (7)
- # clojure-nl (1)
- # clojure-uk (36)
- # clojurescript (13)
- # clojureverse-ops (6)
- # conjure (2)
- # cursive (2)
- # datahike (11)
- # datalevin (1)
- # datomic (106)
- # graphql (3)
- # helix (10)
- # holy-lambda (24)
- # kaocha (2)
- # lambdaisland (3)
- # lsp (199)
- # malli (35)
- # off-topic (16)
- # pathom (7)
- # polylith (38)
- # portal (16)
- # quil (2)
- # re-frame (18)
- # reagent (57)
- # shadow-cljs (11)
- # testing (3)
- # xtdb (9)
Can you or someone else make some prose as to what changed and why users should change something? I feel like Iām missing some details. E.g. what does becoming a module mean. I checked the JIRA issue but it has no description.
the closure library has different types of source formats. the old legacy goog.provide/goog.require system which CLJS uses where everything lives in the same shared global scope
then the newer goog.module
which is more like ESM or commonjs. meaning those files need to be rewritten before they can be loaded in the runtime (eg. browser)
there is a legacy goog.module
variant that still exported the global name so it just worked with the "old" style
but newer goog.module
no longer export that global name and need to be accessed in a different way, which creates this new problem
the closure library has started moving more and more stuff to goog.module
and recently also some without the legacy "bridge"
technically goog.object
is one of those legacy modules, so it would work with the old style but David wants to rip the band-aid off faster. not sure I agree with that but it likely needs to happen at some point so best to get it over with quickly š
@thheller So this is like ES modules where each CLJS namespace has to have its own reference to the imported module, rather than a global one? Are CLJS namespaces compiled as goog modules as well?
Or it is sufficient for one CLJS namespace to require goog.object
to make it available to all (which you should not do, but technically I mean)
So I have this code in clj-kondo:
(when cljs?
;; see
(one-of ns* ["js" "goog" "cljs.core"
"Math" "String" "goog.object" "goog.string"
"goog.array"])))
I will remove goog.object
, goog.string
and goog.array
from this. From then on, not requiring these modules will result in "Unresolved namespace: ... Are you missing a require?".Perhaps this should also then be updated in CLJS? https://github.com/clojure/clojurescript/blob/514274cab1d1798a1754758502e6fee2ab32103a/src/main/clojure/cljs/analyzer.cljc#L744
OK, committed this: https://github.com/clj-kondo/clj-kondo/commit/67b9d106bd4344f32e4de30c4beba56ebbcea30f Can do new release when new CLJS is about to be released.
@borkdude yes, somewhat like ES modules where each ns has a local reference. CLJS is not gonna use goog.module
. any namespace should always require everything it uses, no exceptions and regardless of CLJS or JS. definitely good to remove those special cases you had there
@borkdude in general for Closure namespaces yes - but I didn't want to spend a ton of time on a more less transitional thing
it's only a problem w/ Google Closure Library because they just change stuff whenever they feel like it
I never had a special case around goog.Integer
in clj-kondo and nobody has complained about this. When I search for goog.Integer
on http://grep.app I found 0 references