Fork me on GitHub
#shadow-cljs
<
2020-10-05
>
Galagora00:10:49

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/ 😉

devn01:10:35

ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named I keep getting these on shadow-cljs watch

devn01:10:52

it stems from some business in shadow around cljs_hacks

devn01:10:25

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)

devn01:10:35

It doesn’t happen every time.

rberger07:10:16

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?

rberger07:10:33

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

thheller09:10:11

@devn do you maybe use shadow-cljs embedded in some CLJ app in combination with some kind of classloader magic or tools.namespace?

devn19:10:49

I don’t think that’s my situation, but either way, do you have any suggestions for catching what’s actually happening here?

thheller22:10:36

it is extremely unlikely that this is actually a shadow-cljs problem

thheller22:10:42

this is deep inside the clojure core code

thheller22:10:56

so it is much more likely something goin on in your JVM that shouldn't be

thheller22:10:01

how are you running things?

thheller22:10:15

if you are connected over nREPL it might be the nREPL doing stuff

devn23:10:52

@U05224H0W 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]

devn23:10:56

The shadow watch is run with npx — shadowcljs 2.11.4 is specified in the package.json

devn00:10:01

Ugh. I am very embarrassed.

devn00:10:27

I accidentally IBM’s J9 OpenJDK, not the HotSpot version of AdoptOpenJDK

thheller09:10:05

@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])

rberger19:10:24

@U05224H0W 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.

thheller20:10:25

ah if its web components you just do [:sl-button ...] like any other regular dom element

thheller20:10:20

thats why the :refer and stuff may not actually exist because you don't need it if it already self-registers

rberger20:10:03

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 the

thheller20:10:48

that likely means you are including transpiled code from babel

thheller20:10:06

I think a require for regenerator-runtime might be enough

thheller22:10:06

(:require ["regenerator-runtime"]) should do it in case you didn't try .. you said "refer" which would be incorrect

thheller22:10:21

(maybe npm install regenerator-runtime first of course)

thheller22:10:31

but the script tag is fine too I guess

rberger22:10:18

Yep, (:require ["regenerator-runtime"])`` works great. Preferred to <script> tag Thanks again!

thheller09:10:48

but from the package name I gather its about CSS which shadow-cljs does not handle. so it might be webpack only?

victorb09:10:49

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?

localshred14:10:38

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

localshred14:10:09

(where release would be a target in your Makefile to run shadow-cljs release {target} )

victorb16:10:31

Thanks @U5RFD1733, I opted for the inotifywait route as I already had that installed and didn't need to download anything new 🙂

localshred16:10:37

oh for sure, there's a billion watchers out there. yay unix :)

🎉 3
thheller09:10:20

no

🙏 3