Fork me on GitHub
Mr. Savy00:10:53

I downloaded the fulcro template to play around with, but I'm getting an net::ERR_CONNECTION_REFUSED whenever I start the server. Has anyone encountered this error before with shadow-cljs? I ask here because the terminal spat out an error that pointed to some shadow-cljs code.

Mr. Savy00:10:15

The namespace is shadow.cljs.devtools.client.websocket line 12. Still looking into it though. It seems like anything could cause this which is worrisome.

Mr. Savy00:10:30

looking at some of the issues in the github, something with websocket I guess.

Mr. Savy04:10:12

redownloading the template caused it to go away. I have no idea why.


Is there any way I can inline the compiled output into the HTML file? Something like HtmlWebpackInlineSourcePlugin but for shadow-cljs


another question, is there a target for generalized JS environment? The context I'm trying to run in is not a browser environment (no access to browser APIs) nor nodejs (so can't use dirname and other nodejs specific things). The environment is a sandboxed browser environment with ES6, with removed browser APIs


more questions, slightly related. There is bunch of extra (undocumented) targets in, can I use them from the shadow-cljs npm module somehow? I'm not able to figure out how...


@victorbjelkholm429 there is nothing to do the inline the output into html. you could just to it in an extra step after compilation thought. need more information before I can comment on the target thing. Maybe :target :esm does what you need in release mode or any of the node stuff. just don't expect watch or compile to work. release output might work.


Interesting, I'll take a look at the :esm target, thanks! For now, watch/compile for that is not super important, can work around that for now.


for the record, here is where I'm trying to get it to run: Basically has two different contexts. One "UI" that has access to all the browser APIs but cannot load JS sources via script tags, everything has to be inlined. The other one "code" (basically background) that has no access to browser APIs but custom ones like the figma one. Currently I got the UI one working fine by having shadow-cljs output a npm-module that I'm including in a "vanilla JS" file, then webpack packs it + index.html into a single file with the JS embedded. Having harder time getting the "code" context to work, as output from shadow-cljs (cljs-compiler maybe?) is either assuming it's in a browser OR nodejs context while in "code" context, neither global, process nor window is available


:target :browser may work too, but again just in release


in compile or watch it will definitely try to access all of those


Hm, I'll give release a try, didn't try it before with the :browser target. Thanks for the guidance!


Managed to get it to work by using a combination of compile for the "Figma UI target" and release for the "Figma background target", and using the :browser target for both. Thanks for the help!


the :ui-dev build you do not need


or I guess the :ui build is old since its still :npm-module?


@U05224H0W I do 🙂 I have two different environments, one where I simulate the Figma environment in the browser


has to be a npm module as after shadow-cljs I pass it to webpack to inline UI into the index.html (needed for Figma...)


it's a bit tricky and messy, but it works at least. Basically I shim the APIs that Figma provide in the plugin context, if FIGMA is false. So I can develop most of it in browser, and then only test integration in figma itself


well there could be a :target :figma-plugin or so that takes care of some of the messiness


but I don't have time to look into that currently


@U05224H0W don't worry about it, thanks for the guiding so far. I think it's a pretty small intersection of people who write clojure and writes Figma plugins 😄 I might open source the wrapper I'm using, to help others, and if that sees any interest, I could think about contributing a :figma-plugin target


Is there a way to make React Native hot reload feature work? Somehow Metro bundler reloads the whole bundle after recompilation


disable it completely and let shadow-cljs handle the reload


@U05224H0W thanks for the pointer! It works much better (the currently active screen doesn’t refresh though)


you must set up the re-rendering properly


so if nothing refreshes you likely have done something that breaks that or not done it at all


got it, thank you!


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.


check the "things to avoid" and "hooking up react"


I think I finally made it work, thanks a lot for your help!


otherwise no clue


Hi. I have a CommonJS module in src/add.js (`module.exports = add`) and this CLJS code in src/habit/core.cljs:

(ns habit.core
  (:require [moment]
            ["/add" :as add]

(println (add 1 2))
(defn main []
  (println "hi"))
With this shadow-cljs.edn:


  {:target :node-script
   :main habit.core/main
   :output-to "out/core.js"
I then run sc cljs-repl m and node out/core.js which outputs "3" and "hi". However, in the repl, I get this error when trying to access add : #object[ReferenceError ReferenceError: module$add is not defined] . I can access moment fine. What am I doing wrong?


Should I try an earlier one?


no. just ruling out that you are on old versions 😛


might just be a bug in the node-repl. don't really know. not something alot of people do