This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-08
Channels
- # asami (22)
- # babashka (35)
- # beginners (4)
- # calva (76)
- # cider (7)
- # clj-on-windows (89)
- # clojure (30)
- # clojure-europe (25)
- # clojurescript (10)
- # conjure (46)
- # fulcro (13)
- # gratitude (5)
- # lambdaisland (4)
- # lsp (13)
- # malli (5)
- # membrane (6)
- # nbb (1)
- # off-topic (11)
- # re-frame (2)
- # releases (1)
- # shadow-cljs (45)
- # xtdb (4)
What could I be doing wrong?
(require '[goog.object :as gobj]) => nil
gobj => Use of undeclared Var calva.read-config/gobj
Putting the require in a :require
in the ns
form gives the same result. I can use goog.object this way: (js/goog.object.set o k v)
, but I would prefer to use :require
...Yes, that's how I tried to use it, but got Cannot read properties of undefined (reading 'set')
.
dunno the full context, so can't say much. (:require [goog.object :as gobj])
and (gobj/set x "thing" 1)
definitely works
but goog.object is one of those new goog.module. so there are caveats to using it now. for example in code generated by macros
The longer story is that I wanted to make my own version of cljs.core/clj->js
, so I copied it https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L11031-L11056 and also copied how goog.obj
was required. Then when trying my local version of clj->js
, I got that ^ error.
you can just use unchecked-get
and unchecked-set
from cljs.core
instead. works the same
What I did:
1. Copied clj->js
from core.cljs
and pasted it in my file as my-clj->js
.
2. Copied [goog.object :as gobject]
from the ns
form of core.cljs
and pasted it in my ns
from.
3. Evaluated (my-clj->js {:foo 1})
=> BOOM Cannot read properties of undefined (reading 'set')
.
I like unchecked-set
so I am fine. And I'm not confused any longer. 😃 Even if it would have been better that I had done something weird rather than there being this REPL mystery.
I started using unchecked-set in my own code. no longer worth the trouble with goog.object since the weird goog.module changes
Ah, so you have already figured out what causes it. Nice mini-repro!
(gobj/set #js {} "x" 1)
I get a bit surprised that it evaluates to 1
. Never thought about the return value of these before. I notice that also:
(set! (.-x #js {}) "y") => "y"
using the :as
as a variable only works for npm JS requires, not for CLJS or closure namespaces
Can an error configuring logging cause shadow to not provide a JS runtime. I get
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
no, this is unrelated. usually caused by you having additional logging related dependency on the classpath
(or setting up logging incorrectly in some way). if you start shadow-cljs embedded it'll inherit the JVM logging you configured
about runtime related things see https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting
Don't know if this is Shadow-CLJS's fault, but I'm getting this error when trying to use garden.
app.css> (g/css)
Execution error (ReferenceError) at (<cljs repl>:1).
Can't find variable: garden
:repl/exception!
I'm using deps.edn where I have added garden, and my ns declaration looks like this:
(ns app.css
(:require
[garden.core :as g]
[garden.stylesheet :as gs]
[re-frame.core :as rf]))
I don't get any error when using re-frame, only with garden. Any ideas of what's wrong?not enough context to comment. how did you require things? were there any warnings? errors during load?
I've never used garden, so no clue what it does on load. might be doing something in macros. no clue.
There was one warning:
------ WARNING - :redef --------------------------------------------------------
Resource: <eval>:390:1
abs already refers to: cljs.core/abs being replaced by: garden.color/abs
--------------------------------------------------------------------------------
As for how I required things, I required it with the ns
macro, as I showed.