Codox seems to be barfing on the :default
in :require
that shadow-cljs enables. Does anyone know a way to tell codox to allow it? The error is:
Caused by: clojure.lang.ExceptionInfo: Only :as, :refer and :rename options supported in :require / :require-macros; offending spec: ["react-bootstrap-table2-editor" :default cellEditFactory] at line 1 file:/Users/rberger/omnyway/neo/lib/re-view/src/review/table.cljs {:file #object[java.net.URL 0x1835b24b "file:/Users/rberger/omnyway/neo/lib/re-view/src/review/table.cljs"], :line 1, :column 1, :tag :cljs/analysis-error}
Or is my only painful alternative is to replace the very nice :default
with :as and an alias?@rberger you can use the new official alternative ["react-bootstrap-table2-editor$default" :as cellEditFactory]
, see https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces
If I use the new official alternative, do I use the alias in the code just like it was the previous :default
? I.e (cellEditFactory (clj->js {:mode "click"}))
(without the /default
)
yes, thats what the $default
does
FWIW don't do this (cellEditFactory (clj->js {:mode "click"}))
. for really simple JS objects like that just use #js
eg. (cellEditFactory #js {:mode "click"})
I'm getting bunch of infer-warnings on shadow-cljs with Reagent (the project itself, not when using as library). Seems to be related to deftype
and extending a protocol without any methods. Though IAtom doesn't cause these problems, any ideas?
(defprotocol IReactiveAtom)
(deftype IRatom [bar]
IAtom
IReactiveAtom
)
------ WARNING #1 - :infer-warning ---------------------------------------------
File: /home/juho/tmp/your-project/src/your_project/core.cljs:30:1
--------------------------------------------------------------------------------
27 |
28 | (defprotocol IReactiveAtom)
29 |
30 | (deftype Ratom [bar]
-------^------------------------------------------------------------------------
Cannot infer target type in expression (. (. IRatom -prototype) -your-project$core$IReactiveAtom$)
--------------------------------------------------------------------------------
31 | IAtom
32 | IReactiveAtom
33 | )
34 |
--------------------------------------------------------------------------------
most likely a problem in CLJS directly? or does it not happen there?
would help if you try with cljs.main
and (set! *warn-on-infer* true)
No, but I guess I need to check if I'm running warn-on-infer there.
if that doesn't warn I can fix it. if not its happening somewhere in the CLJS parts of inference
Strange, I get different warnings with cljs.main:
Compiling /home/juho/Source/reagent/src/reagent/ratom.cljs to target/bundle-adv/resources/public/js/out/reagent/ratom.js
WARNING: Cannot infer target type in expression (. c push derefed) at line 76 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. G__6105 push p2__6103#) at line 98 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. G__6105 push p3__6104#) at line 98 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. v -destroy) at line 328 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. a push f) at line 495 /home/juho/Source/reagent/src/reagent/ratom.cljs
And shadow-cljs:
------ WARNING #1 - :infer-warning ---------------------------------------------
File: /home/juho/Source/reagent/src/reagent/ratom.cljs:129:1
--------------------------------------------------------------------------------
126 |
127 | (defprotocol IReactiveAtom)
128 |
129 | (deftype RAtom [^:mutable state meta validator ^:mutable watches]
-------^------------------------------------------------------------------------
Cannot infer target type in expression (. (. RAtom -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
130 | ; IAtom
131 | IReactiveAtom
132 |
133 | IEquiv
--------------------------------------------------------------------------------
------ WARNING #2 - :infer-warning ---------------------------------------------
File: /home/juho/Source/reagent/src/reagent/ratom.cljs:208:1
--------------------------------------------------------------------------------
205 | (set! (.-reaction obj) r))
206 | v))))
207 |
208 | (deftype Track [f args ^:mutable reaction]
-------^------------------------------------------------------------------------
Cannot infer target type in expression (. (. Track -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
209 | IReactiveAtom
210 |
211 | IDeref
212 | (-deref [this]
--------------------------------------------------------------------------------
------ WARNING #3 - :infer-warning ---------------------------------------------
File: /home/juho/Source/reagent/src/reagent/ratom.cljs:250:1
--------------------------------------------------------------------------------
247 |
248 | ;;; cursor
249 |
250 | (deftype RCursor [ratom path ^:mutable reaction
-------^------------------------------------------------------------------------
Cannot infer target type in expression (. (. RCursor -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
251 | ^:mutable state ^:mutable watches]
252 | IAtom
253 | IReactiveAtom
254 |
--------------------------------------------------------------------------------
------ WARNING #4 - :infer-warning ---------------------------------------------
File: /home/juho/Source/reagent/src/reagent/ratom.cljs:358:1
--------------------------------------------------------------------------------
355 | ;; - state
356 | ;; - watches
357 | ;; - watching
358 | (deftype Reaction [f ^:mutable state ^:mutable ^boolean dirty? ^boolean nocache?
-------^------------------------------------------------------------------------
Cannot infer target type in expression (. (. Reaction -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
359 | ^:mutable watching ^:mutable watches ^:mutable auto-run
360 | ^:mutable caught]
361 | IAtom
362 | IReactiveAtom
--------------------------------------------------------------------------------
that is odd. thx for testing, I'll look into it
Minimal project https://github.com/Deraen/shadow-cljs-infern-warning, npm run release
shows the warning, build.sh
doesn't
fixed in https://github.com/thheller/shadow-cljs/commit/721f71dce7ca55bf9b3c5d80b38709e68270ef4a, released in 2.14.5
hello, i’ve a quick question. I’m trying to create a devcards macro that basically just wraps components with my react lib’s theme provider, and realized it presents a bit of a catch 22 as i need the symbol for the react component in the actual clj implementation. i know the general approach is to make sure you use fully qualified symbols (clojure.core/xxx). But since the ["mylib" :default/refer …]
syntax is cljs/shadow specific, just wondering what (if any) equivalent there is.
create a helper function that does what you need. (defn foo-helper [a b] (that-npm-alias/do-stuff a b))
. maybe even helps reducing the amount of code the macro generates.
you can also use cljs.analyzer/resolve-var
to get the actual alias if helper function is not an option
a helper on the clj side? I tried something like that w/o creating the macro, for something like (defcard xxx (wrap-theme comp))
but I think the arg capture confuses things.
ah
ok, yeah will give resolve-var a try
helper on the cljs side
yeah, that’s what I did. no joy 😉
what did you try? should be straightforward macro-wise? even just a function?
for the helper i tried a couple things someting like:
(defn theme
[x]
[:> ThemeProvider
x])
as well as another variant that returned an fnbut i hadn’t gotten far on the macro, as I realized i wasn’t sure how to fully qualify ThemeProvider
(:name (cljs.analyzer/resolve-var &env the-sym))
firing up my repl now 🙂
but that doesn't look like it should be a macro
(remember that you can't write macros in a CLJS repl)
yeah i didn’t think so, but for whatever reason it doesn’t seem to work. will try checking the macro expansion
ah yeah i know, just meant to start playing with the analyzer
Hi,
I keep getting shadow-cljs - Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running
message when trying from Emacs cider-jackin-cljs
What option do I miss?
My .dir-locals.el
looks like
((nil . ((cider-preferred-build-tool . shadow-cljs)
(cider-default-cljs-repl . shadow)
(cider-shadow-default-options . "app")
(cider-shadow-watched-builds . ("app")))))
I am trying out the example project here https://github.com/shadow-cljs/quickstart-browser
either you are loading the wrong javascript (often happens when people rename :modules
or change :output-dir
)
or you might have 2 instances of shadow-cljs running competing with each other and conflicting
Thanks let me check
note that jack-in from emacs starts a new fresh instance, so if you have shadow-cljs watch
already running separately that would be your conflict
I am sure I don’t have anything running as I list all of my open program and then kill off all node process just to make sure and I am still getting the error.
And I kill off my Emacs instance as well just to be on the clean state for testing.
I am trying the npx shadow-cljs watch app
then cider-connect
options to confirm
shadow-cljs is a java process. so killing the node process may not end up killing the java process
I managed to fix it by reload the page. And the things seems to be connect properly now. Thanks again for your help.