OK, so FWIW, I put the same minimal reproducible example up https://github.com/galagora/clonode. I couldn't get Figwheel to work either. I guess I'll just have to use something with better Node.js support, https://www.tweag.io/blog/2019-05-09-inline-js/ đ
ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named
I keep getting these on shadow-cljs watch
it stems from some business in shadow around cljs_hacks
ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named
clojure.core/namespace (core.clj:1597)
clojure.core/namespace (core.clj:1597)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:155)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:147)
cljs.analyzer/resolve-existing-var (analyzer.cljc:1276)
cljs.analyzer/resolve-existing-var (analyzer.cljc:1271)
cljs.compiler/fn--9175 (cljs_hacks.cljc:740)
cljs.compiler/fn--9175 (cljs_hacks.cljc:717)
It doesnât happen every time.
so now I have
(defn dev-render-root {:dev/after-load true} []
(shadow/render-root "DcnetApp" (r/as-element [app-root]))
)
itâs called after I update the code, as expected
[Sun Oct 04 2020 19:17:50.501] LOG load JS dcnet_app/screens/home.cljs
[Sun Oct 04 2020 19:17:50.507] LOG load JS dcnet_app/appnav.cljs
[Sun Oct 04 2020 19:17:50.508] LOG call dcnet-app.ios.core/dev-render-root
but the screen doesnât get updated.
anything else I might be missing?I think somethingâs off with the bundler.
I tried two other methods (directly calling .forceUpdate
and updating ratom
within the root component).
It does trigger re-rendering, but still displays old version of the code. Iâll let you know if I figure it out.
Anyone familiar with being able to use https://shoelace.style/getting-started/installation in a shadow-cljs project? I canât seem to just simply require components even though its shipped as an npm package. Do I need to do some webpack thing first? (their installation docs seem to imply that). Or is there some special path I need to use?
I have tried (:require ["@shoelace-style/shoelace" :refer [SlButton]])
and
(:requre ["@shoelace-style/shoelace" :as sl])
and I end up with nil for SlButton
or sl/SlButton
@devn do you maybe use shadow-cljs embedded in some CLJ app in combination with some kind of classloader magic or tools.namespace
?
@rberger read https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages about the default exports. I don't know for this case but it might be (:requre ["@shoelace-style/shoelace" :default SLButton])
but from the package name I gather its about CSS which shadow-cljs does not handle. so it might be webpack only?
Is there any built-in way of combining watch
and release
? Basically just want a way of running release
every time the files change. watch
will call compile
on file change, as I understand it, so if there is a way of getting it to run release
instead?
no
not native to shadow in particular, but if you use watchman-make
you can do anything you want after files are changed e.g. watchman-make -p './src/***/**.cljs' -t release
https://facebook.github.io/watchman/docs/watchman-make.html
(where release
would be a target in your Makefile to run shadow-cljs release {target}
)
Thanks @localshred, I opted for the inotifywait
route as I already had that installed and didn't need to download anything new đ
oh for sure, there's a billion watchers out there. yay unix :)
@thheller I was able to get it to import with:
(:require ["@shoelace-style/shoelace/dist/custom-elements/index.js" :refer [defineCustomElements setAssetPath SlButton]])
It ends up with an html custom element (web component) now I still have to figure out how to access the element after doing:
(.define js/customElements "sl-button" SlButton)
SlButton is defined as a class, but sl-button
is not defined. I probably just need to learn more how web components work with reagent.I donât think thatâs my situation, but either way, do you have any suggestions for catching whatâs actually happening here?
ah if its web components you just do [:sl-button ...]
like any other regular dom element
thats why the :refer
and stuff may not actually exist because you don't need it if it already self-registers
not a clue
Oh, I didnât try with the :
Now that I try that, it
does inject <sl-button>⌠into the DOM now, but Iâm getting a
Uncaught ReferenceError: regeneratorRuntime is not defined
index.js:2654 Uncaught ReferenceError: regeneratorRuntime is not defined
at initializeComponent (index.js:2654)
at _connectedCallback (index.js:2944)
at HTMLElement.connectedCallback (index.js:3049)
at commitPlacement (react-dom.development.js:8835)
at commitAllHostEffects (react-dom.development.js:18656)
at HTMLUnknownElement.callCallback (react-dom.development.js:150)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
at invokeGuardedCallback (react-dom.development.js:257)
at commitRoot (react-dom.development.js:18914)
at eval (react-dom.development.js:20419)
But at least that is something I can track down now hopefully.
Thanks again for your help!
Oh, I didnât try with thethat likely means you are including transpiled code from babel
I think a require for regenerator-runtime
might be enough
Ok. The package has two styles of distriubtions. This custom-elements path that at least let me import: > is a direct build of the custom element that extends `HTMLElement`, without any lazy-loading. The custom elements bundle does not apply polyfills, nor automatically define each custom elements. This may be preferred for projects that will handle bundling, lazy-loading and defining the custom elements themselves. The default path that I couldnt get to import: > The `dist` type is to generate the component(s) as a reusable library that can be self-lazy loading, such as https://www.npmjs.com/package/@ionic/core.
Adding regeneratorRuntime
as a refer item didnât change the behavior
I saw a babel issue that suggested adding
<script src="<https://unpkg.com/regenerator-runtime@0.13.1/runtime.js>"></script>
to the index.html and that did make it work! Will go back and see how to do that thru npm/require.
Yay!
Now to see if this web components actually help life in reagent or notâŚIs there any way to look at a log of what shadow-cljs does?
im completely stumped right now
it is extremely unlikely that this is actually a shadow-cljs problem
this is deep inside the clojure core code
so it is much more likely something goin on in your JVM that shouldn't be
how are you running things?
(:require ["regenerator-runtime"])
should do it in case you didn't try .. you said "refer" which would be incorrect
(maybe npm install regenerator-runtime
first of course)
but the script tag is fine too I guess
if you are connected over nREPL it might be the nREPL doing stuff
Yep, (:require ["regenerator-runtime"])`` works great. Preferred to <script> tag Thanks again!
@thheller itâs not always inside the clojure core code.
I wish I could get a smaller way to reproduce, but:
The project has 3 primary source directories:
âsharedâ (cljc code)
âsrcâ (clojure code)
âui-srcâ (clojurescript code)
There is a project.clj which specifies all 3 of these source paths in its source-paths key. This project.clj requires the latest version of clojurescript.
In addition, there is a package.json and a shadow-cljs.edn. The shadow-cljs.edn has 3 builds in it, all of which are specified with :entries [the.ns]
The shadow watch is run with npx
â shadowcljs 2.11.4 is specified in the package.json