clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2020-10-28T00:00:48.316600Z

hello everyone! does anyone have experience setting up a cljs project with shadow-cljs + sass + bulma? i am a bit lost on how to get bulma to work. i have installed the package and imported in my scss file but am not seeing the classes work in the UI

thheller 2020-10-28T08:49:34.317700Z

you need to run node-sass or so to process the scss file. html can only load the resulting actual css

2020-10-29T04:26:08.371200Z

this is what i ended up doing as well! thanks for the heads up @thheller!

2020-10-28T00:01:40.316700Z

i have this in my <head>

<link href="/css/style.scss" rel="stylesheet">
and this at the top of my scss file (pls disregard the /css folder i know it is incorrect)
@import "./node_modules/bulma/bulma.sass"

seqable 2020-10-28T11:48:54.322700Z

Having major issues with figwheel (I think?). Setup has been acting strangely the entire project but now it's just completely borked. Right now code that runs fine on heroku and certainly compiles with lein cljsbuild once app at first wasn't working properly on my box, after a lein clean won't even run under figwheel citing string.cljs not existing. I'm basically at the point where I need to obsessively restart and run lein clean or even nuke my .m2 every so often. What might be causing something like that?

seqable 2020-10-28T11:49:27.322800Z

It's like it has a mind of its own and will never act consistently.

victorb 2020-10-28T11:55:10.323100Z

Sounds like either something been broken from day 1 or your environment is borked. Try creating a new project from scratch to see if you can reproduce the issue in a smaller scope. If everything is still funky, I'd start looking around in my own OS. If everything works, try adding more stuff from your main project into the new one until it starts breaking

seqable 2020-10-28T11:59:53.323300Z

Yeah evidently. But can't wrap my head around how tho. Redo of m2 did the trick afa compiling (as usual) but just got me back to the earlier point of re-frame subs suddenly not doing my bidding. I've completely cleaned out my profiles.clj so there shouldn't, really couldn't, be anything left hmm.

seqable 2020-10-28T12:02:37.323500Z

I suppose answer is dockerize the fucker and if not properly pin down what exactly changes and where, at least have an easier time getting clean slate. But then slate is supposed to be your deps and your code so, uhh.

victorb 2020-10-28T12:07:01.323700Z

you're having the same issue with multiple projects or just this one?

uosl 2020-10-28T12:10:25.323900Z

Have you tried clearing your browser's cache or opening the webapp in incognito mode? Sometimes the caching messes with me badly.

seqable 2020-10-28T12:11:22.324100Z

yup i'm in incognito. The caching is horrible, agreed. But sadly not my current issue 😕

seqable 2020-10-28T12:57:34.324900Z

seems incognito not enough, went for disabling cache and at least code is current now haha. just not working anyways

kah0ona 2020-10-28T12:59:25.326500Z

Hi folks, It seems for some reason reagent can’t find React anymore, and I get these kind of messages:

Uncaught TypeError: $reagent$impl$component$$.$node$module$react$ is undefined
With figwheel locally it works, also the compiled minified bundle (with :psuedo-names true) shows that React / ReactDOM are in there. Any pointers in how to debug this? I’ve tried many things, can’t for the life of me figure out why it happens. No webpack or any form of bundling, and some other projects with similar deps I run run just fine. My build config:
:cljsbuild
  {:builds {:uberjar {:source-paths ["src/cljs" "src/cljc"]
                      :compiler     {:main            aviationglass.core
                                     :optimizations   :advanced
                                     :asset-path      "/js/compiled/out"
                                     :output-dir      "resources/public/js/compiled"
                                     :source-map      "resources/public/js/compiled/main.js.map"
                                     :output-to       "resources/public/js/compiled/app-min.js"
                                     :pseudo-names    true
                                     :pretty-print    true
                                     :source-map-path "/assets/js/compiled"
                                     :externs         ["resources/public/js/uppy.extern.js"]
                               
                                     :infer-externs   true
                                     :install-deps    true
                                     :closure-defines {goog.DEBUG false}

kah0ona 2020-10-28T12:59:57.327Z

Reagent 1.0.0-alpha2, and clojurescript 1.10.597 and also tried the latest

kah0ona 2020-10-28T13:00:53.328Z

In the app-min.js there’s React in there, in the browser console React.version shows 16.13.0

kah0ona 2020-10-28T13:01:59.328800Z

tried different :optimizations as well, and this projects ‘used to work’ with older reagent version, but i have another similar projet with 1.0.0-alpha2 that runs just fine

kah0ona 2020-10-28T13:02:03.329Z

any pointers? 🙂

2020-10-28T13:10:51.329600Z

anyone knows how to make github actions (node) with cljs?

victorb 2020-10-28T13:14:05.329700Z

here is one such example: https://github.com/mvc-works/lilac/pull/8/files

victorb 2020-10-28T13:14:43.329900Z

but, I'd probably go for something like babashka if you're just doing smaller scripts. Way faster startup

dnolen 2020-10-28T15:04:09.330800Z

@kah0ona the error makes it seem like React is coming from node_modules

dnolen 2020-10-28T15:04:53.331200Z

so need more details on how you are supplying React to the build

kah0ona 2020-10-28T15:33:00.333800Z

Thanks for your response, already shedding some light. I was going trying the :target :bundle route, but that yielded some other problems, so was going to go back. But now it’s just vanilla clojurescript from a leiningen project with lein-cljsbuild with above parameters. There is a node_modules directory, but afaik all explicit mentions of it are removed. Can I tell if/how the cljs compiler is looking in the node_modules dir when compiling? Could it be through transative dependencies?

seqable 2020-10-28T15:35:54.333900Z

yup turns out suspicions correct, something about figwheel... with cljsbuild straight and a bunch of fiddling I finally managed to get what what's supposed to work working and what isn't, not. Hurray! Probably time to look towards moving away from sidecar since it's not seeing updates.

kah0ona 2020-10-28T15:39:47.334300Z

(defproject aviationglass "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [org.clojure/core.async "0.4.490"]
                 [org.clojure/clojurescript "1.10.597"]
                 [re-dnd "0.1.19"]
                 [re-val  "0.1.3"]
                 [sweet-crud "0.1.2"]
                 [reagent "1.0.0-alpha2"]
                 [reagent-utils "0.3.1"] ; cookie/session mgmt
                 [re-datagrid "0.1.10"]
                 [cljs-ajax "0.8.0"] ;
                 [re-frame "1.1.1"] ;client-side reagent framework
                 [re-frame-utils "0.1.0"]
                 [clj-commons/secretary "1.2.4"] ;client-side routing
                 [compojure "1.6.1"]
                 [metosin/compojure-api "2.0.0-alpha20"] 
                 [ring "1.7.1"] ;ring + midddleware
                 [ring/ring-defaults "0.3.2" ]
                 [ring/ring-json "0.4.0"]
                 [http-kit "2.3.0"] ; high performance HTTP server
                 [day8.re-frame/http-fx "0.1.6"]
                 [day8.re-frame/async-flow-fx "0.0.11"]
... snip ...            

kah0ona 2020-10-28T15:41:21.335100Z

Or does the cljs compiler nowadays just ‘notice’ an node_modules directory and do something with it implicitely?

dnolen 2020-10-28T15:55:44.335300Z

yes it looks there

dnolen 2020-10-28T15:56:04.335900Z

I believe reagent now does not depend on the CLJSJS one?

dnolen 2020-10-28T15:56:19.336200Z

so it it will try to get it from node_modules

kah0ona 2020-10-28T15:56:37.337Z

because it is the 1.0.0-alpha, and that has changed? :thinking_face:

dnolen 2020-10-28T15:56:44.337300Z

I don't know

kah0ona 2020-10-28T15:56:51.337600Z

ah ok

dnolen 2020-10-28T15:57:20.338300Z

this should be documented in Reagent itself

dnolen 2020-10-28T15:58:14.339500Z

if the CLJSJS one exports react as a namespace

kah0ona 2020-10-28T15:58:16.339700Z

but how come the React is in the final artefact? Maybe reagent requires it differently now because it somehow thinks it should be in node_modules?

kah0ona 2020-10-28T15:58:26.340Z

ah yeah

dnolen 2020-10-28T15:58:42.340400Z

then you should be able to explicitly refer to the CLJSJS dep in your list of deps

dnolen 2020-10-28T15:58:51.340800Z

and carry on like before

👍 1
kah0ona 2020-10-28T15:59:02.341300Z

aah yeah so i just got it working by simply removing node_modules dir…..

kah0ona 2020-10-28T15:59:13.341600Z

and then recompile

kah0ona 2020-10-28T15:59:25.342100Z

at least I think that’s why it works now… ok will investigate more

kah0ona 2020-10-28T15:59:32.342600Z

will get to the bottom of this, thanks for your help 🙂

dnolen 2020-10-28T15:59:48.343Z

right switching back and forth between bundle and the old way will likely create a confusing state

kah0ona 2020-10-28T15:59:50.343100Z

gotcha

kah0ona 2020-10-28T16:00:03.343500Z

yeah ok

dnolen 2020-10-28T16:00:29.344200Z

:npm-deps false

dnolen 2020-10-28T16:00:42.344700Z

should also work, it will force ignoring of node_modules

kah0ona 2020-10-28T16:01:04.344900Z

is it true by default?

kah0ona 2020-10-28T16:01:20.345500Z

ok but this all will pan out, thanks a whole bunch for your time sir!

dnolen 2020-10-28T16:01:25.345600Z

pretty sure it isn't

dnolen 2020-10-28T16:01:31.346Z

in general the old way is not desirable

kah0ona 2020-10-28T16:01:31.346100Z

k

dnolen 2020-10-28T16:01:48.346600Z

:bundle is superior in my opinion for typical things

kah0ona 2020-10-28T16:02:01.347100Z

the issue, btw, i head with :bundle is, it seemed to hang with :advanced

dnolen 2020-10-28T16:02:01.347200Z

since you don't have to go hunting for deps

dnolen 2020-10-28T16:02:07.347500Z

externs inferences work etc.

kah0ona 2020-10-28T16:02:09.347700Z

had*

kah0ona 2020-10-28T16:02:15.347900Z

yeah i loved that approach tbh

dnolen 2020-10-28T16:02:50.349Z

would have to dig into your :advanced problem

kah0ona 2020-10-28T16:02:52.349200Z

i backtraced to this state because of somehow a hanging build (and a nearing deadline making me do things the old way) But that’s a story for another day; at least i can show my customer something now 🙂

dnolen 2020-10-28T16:02:57.349300Z

never seen that

kah0ona 2020-10-28T16:03:25.350100Z

either it hangs or it would take so very long that i didn’t wait that out

dnolen 2020-10-28T16:03:44.350700Z

sure, it could be a variety of things

dnolen 2020-10-28T16:03:46.351Z

JVM settings etc.

kah0ona 2020-10-28T16:03:52.351200Z

but yeah , there wasn’t any output

kah0ona 2020-10-28T16:03:58.351500Z

it just said: compiling clojurescript…

kah0ona 2020-10-28T16:04:02.351700Z

and then blank

kah0ona 2020-10-28T16:04:08.351900Z

for like, long, way longer than before

kah0ona 2020-10-28T16:04:12.352100Z

so most of time i killed it

kah0ona 2020-10-28T16:04:18.352600Z

all of time* after a few minutes

dnolen 2020-10-28T16:04:20.352800Z

sure

dnolen 2020-10-28T16:04:31.353400Z

but like I said - can't help w/o more info, I've never seen it

dnolen 2020-10-28T16:04:43.354Z

we're using :bundle and :advanced and lots of deps

kah0ona 2020-10-28T16:05:09.354700Z

sure, not asking you to either 😉 you’ve already been of enough help for today, will try that again later! 🙂

kah0ona 2020-10-28T16:05:18.354900Z

ah ok good to know

2020-10-28T16:13:29.356100Z

hi all, is there an idiomatic cljs way of handling long-press events instead of translating the js equivalent please ? (cljs noob here)

dnolen 2020-10-28T16:15:32.356700Z

like only fire the event if the press last longer than some time T?

2020-10-28T16:15:47.356900Z

yep something like that

dnolen 2020-10-28T16:16:36.357800Z

would be pretty easy with core.async - but you need to read up on it

2020-10-28T16:18:04.359600Z

I have played a little bit with it already but can you elaborate on the idea ?

dnolen 2020-10-28T16:18:15.360300Z

alts + timeout

👍 1
🙏 1
2020-10-28T16:18:22.360500Z

oohhhh okay

2020-10-28T16:19:53.362300Z

thanks a lot @dnolen I will check that out

dnolen 2020-10-28T16:20:26.362800Z

(let [long-press-chan (timeout 1000) [c _] (alts! [long-press-chan mouse-release-chan])] ...)

👍 1
💯 1
dnolen 2020-10-28T16:20:49.363300Z

something like that, you can check whether c is a long-press or a mouse-release and then do whatever

dnolen 2020-10-28T16:20:59.363600Z

that's just my first idea, probably other code-golfy ways

2020-10-28T16:21:14.364100Z

thanks a lot ... I will take it from there

dnolen 2020-10-28T16:24:23.364600Z

@kaffein alt! is probably cleaner for something this simple

👍 1
🙏 1
dnolen 2020-10-28T16:24:29.364900Z

since it has the shape of cond

dnolen 2020-10-28T16:24:56.365200Z

(alt! long-press ... release ...)

2020-10-28T16:34:07.365900Z

oh okay thanks for the tip

2020-10-28T18:09:12.366400Z

https://github.com/actions/javascript-action => something like this

2020-10-28T18:09:26.366700Z

but yeah, I know about babashka 😃

2020-10-28T20:32:52.367600Z

Has anyone any experience of this course ? https://www.learnreframe.com/#course ?

2020-10-28T20:33:06.368Z

It's pretty expensive, worth it?

Nathan 2020-10-28T21:13:09.368100Z

I'm almost finishing it. It's a good course. Gives a good overview of reframe, but it's a more hands-on in my opinion which is good depending on your purpose. It helped me a lot as I didn't have any experience with Reframe before. If you really want to understand the different parts of reframe I can recommend https://purelyfunctional.tv/courses/understanding-re-frame/