This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-17
Channels
- # announcements (1)
- # babashka (94)
- # beginners (76)
- # calva (24)
- # cider (24)
- # clj-kondo (1)
- # cljs-dev (16)
- # cljsrn (45)
- # clojure (135)
- # clojure-europe (9)
- # clojure-france (5)
- # clojure-germany (2)
- # clojure-italy (12)
- # clojure-losangeles (13)
- # clojure-nl (3)
- # clojure-portugal (54)
- # clojure-uk (20)
- # clojurescript (55)
- # conjure (67)
- # core-async (5)
- # cursive (2)
- # datomic (10)
- # docker (7)
- # duct (22)
- # emacs (16)
- # fulcro (34)
- # graalvm (15)
- # hoplon (1)
- # instaparse (1)
- # jobs-discuss (3)
- # juxt (94)
- # luminus (1)
- # meander (4)
- # off-topic (13)
- # pathom (4)
- # pedestal (1)
- # ring (3)
- # ring-swagger (2)
- # shadow-cljs (61)
- # spacemacs (17)
- # specter (2)
- # sql (23)
- # xtdb (33)
Has anyone here tried building a Firefox extension with the https://github.com/binaryage/chromex library? I know there's quite a bit of overlap when it comes to extensions for both browsers, but what does introduce breaking code is using the Chrome Extension API. All I'm looking to do is build an extension that opens a pop-up window when clicking on the extension's toolbar button and then modifies the web page in the current tab when a button in the pop-up window is clicked. Does something like this use completely different APIs depending on what browser you're in or is it interchangeable between Firefox and Chrome?
Answered it on your reddit post: https://i.reddit.com/r/Clojure/comments/g2us5d/clojurescript_chromex_for_firefox/fnokkc6/.compact
Hello! Does anyone have experience with shadow-cljs and tailwindcss? I am trying to use tailwindcss in a project and I run into problem after problem while trying to make this work!
What do you use to painlessly serve frontend in cljs? I saw that there is a zeit now builder for shadow-cljs: https://github.com/jntn/now-shadow-cljs Are there any other options?
@posobin do you mean in production? I use and contribute to this: https://github.com/piku/piku
@posobin if it’s just a static app* then you don’t even need a now builder just build your app with shadow-cljs then deploy your public directory
your now.json
config can look something like this:
"builds": [
{
"src": "public/**",
"use": "@now/static"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/public/$1"
}
]
What are the good practices these days for maintaining a cljs lib using deps ?
not sure if I'm misunderstanding how the code splitting is supposed to work (I'm using figwheel-main with cljs.loader). Shouldn't the module I'm interested in load later with loader/load
not be parsed and loaded until I call the load
function? It seems that the modules defined are also included in the cljs_base.js
which I thought would just be bare minimum to get the loading to work for other modules
@victorbjelkholm429 I'm assuming you've gone through the tutorial and verified that it works? there's enough users that rely on the code splitting stuff that we generally get bug reports if something regressed - we also have basic tests around it.
@dnolen yeah, I mean it works as in everything functions, it just functioned in a way that was unexpected. Here is one example: https://gist.github.com/victorb/3b0f2d936e7eaa5eecc78a3460c99327
So I expect the "(println "loaded signup")" to not get called until after I call loader/load :signup
but seems it's being called right when either the cljs_base.js file is loaded, or the renderer
module, unsure exactly when. Had to drop working on it to proceed with some other stuff but will look into it all deeper this weekend
@victorbjelkholm429 I wouldn't say that's not working, https://clojurescript.org/guides/code-splitting
@dnolen sorry if I was unclear in my first message, didn't mean to give the impression that nothing is working. It is working, I can see the messages I should see, they are just happening before I call the loader/load :signup
function, which is unexpected (at least that's the expectation from what I had)
I am loading base + the renderer module, but then the signup module is automatically loaded without even calling loader/load
ended up doing everything from scratch and everything is working as expected in my small reproduction example but not when integrated into a bigger application, so seems I'm doing something wrong there. Will dig deeper but probably user-error in the end
let me do a minimal repo repository and it'll be easier to see (even for myself) what's going on
$ clj --main cljs.main --compile hello-world.core --repl
ClojureScript 1.10.520
cljs.user=> (macroexpand '(cond (< n 0) "negative" (> n 0) "positive" :else "zero"))
(if (< n 0) "negative" (clojure.core/cond (> n 0) "positive" :else "zero"))
cljs.user=> (macroexpand '(if (< n 0) "negative" (clojure.core/cond (> n 0) "positive" :else "zero")))
(if (< n 0) "negative" (clojure.core/cond (> n 0) "positive" :else "zero"))
In the REPL I’m not getting what I expected re: macroexpand
I did a vanilla setup per the Quick Start guide to make sure it wasn’t related to something in the more advanced setup of the project I’m working in.
okay, I see the explanation in the second sentence of the doctring, didn’t notice it at first, my bad: > Note neither macroexpand-1 nor macroexpand expand macros in subforms.
> (swap! session assoc :poll (clj->js(:poll (js->clj js/data :keywordize-keys true)))) Is there a better way to rewrite it? Just trying to extract :poll key from a js JSON and assign it to session atom. js/data is like this(generated via json/write-str): <script> var data = {"poll":{"name":"Test Poll"}}; </script>
How to create an element or node with attributes using Google Closure?
Tried gdom/creatElement
, gdom/createDom
, gdom/setProperties
with id
attribute.
But when I try gdom/getElement
or vanilla js getElementById with id, it returns nil.
I looked it up for checking if it's available.
By adding to document you mean using append
or appendChild
?
Thanks.
Hi, my chrome tab crashes running clojurescript code and I have no idea how to debug it. It does crash when running under figwheel-main but not with cljsbuild.
Same thing in firefox.
Anyone know the best way to have a developer flag like
(def dev-environment? true)
in the code?there's a lot of options. if it's truly related to dev/test I'd be tempted to use a dynamic variable like this https://github.com/clojure/clojure/blob/ee3553362de9bc3bfd18d4b0b3381e3483c2a34c/src/clj/clojure/core.clj#L7069
I have a line of code that is needed for dev but will kill performance on prod. So it is basically just for that one line 😛
yeah so I'd probably create an ns called dev and in there (def ^:dynamic *dev-environment?* false)
then when running your program in dev you do (binding [dev/*dev-environment*? true] (main-function))
What about the goog.DEFINE way? Is that basically the same?
In shadow-cljs you can have these :closure-defines things where goog.DEFINE is used.
sounds cljs specific and possibly even coupled to a specific version of google closure. if it were me I'd use the one that works in both clj/cljs and so is pretty much guaranteed to never stop working
You want to use the goog defines in CLJS, because of dead code elimination: https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines
> goog.DEBUG
: The Closure Library uses this for many development features. shadow-cljs
automatically sets this to false
for release
builds.
Ah! That is cool. Thanks for the headsup!
Hello, I cannot make MaterialUI theming working. I use reagent and shadow-cljs with node modules.
["@material-ui/styles" :as muistyles]
(def MuiThemeProvider (adapt-react-class muistyles/ThemeProvider))
["@material-ui/core/colors" :as muicolors]
["@material-ui/core/styles" :as mui-core-styles]
(def createMuiTheme mui-core-styles/createMuiTheme)
(def astroTheme2 #js {:palette {:primary "#00FF00"
:secondary muicolors/green}})
(def astroTheme (createMuiTheme astroTheme2))
and later in app root I put
[MuiThemeProvider {:theme astroTheme}
...
But it does not work. Any ideas?
note that #js
is flat and does not convert nested structures. so the astroTheme2
is a js object with a nested CLJS map that mui won't understand. use clj->js
for nested stuff instead.
Thanks, it works now.
I also needed to add :main into :primary
(def astroTheme2 (clj->js {:palette {:primary {:main "#00FF00"}
:secondary muicolors/green}}))