Fork me on GitHub
#clojurescript
<
2017-08-18
>
bhauman00:08:17

but there are a bunch more features like super and static fns etc.

bhauman00:08:56

that could be implemented to make it nice

selfsame00:08:33

lumo -c $(lein classpath) is brilliant

anmonteiro00:08:03

@selfsame there’s also lumo -D group/artifact:version,othergroup/artifact:version

anmonteiro00:08:32

(artifacts must be in your local maven cache (i.e. already downloaded)

josh_horwitz03:08:08

I still can't figure out what Meta is

josh_horwitz03:08:11

or how to use it

flyboarder04:08:42

@josh_horwitz the next release will be much more stable, meta is essentially an sdk for building applications, it operates by generating applications which use its built in framework, it wraps the ui, client and server in a neat package

flyboarder04:08:44

However it doesn't implement any application logic, so a generated project can be directly hacked on

iku00088805:08:13

Has anyone tried using clara-rules in lumo(or self hosted cljs repl)?

amitayh05:08:08

do you know of a wrapper for react for rendering hiccup style dom?

amitayh05:08:06

i’ll check it out, thanks!

cjhowe07:08:12

i've been using this, it works well for me!

richiardiandrea07:08:36

@bhauman @anmonteiro about class... I always assumed reify or proxy would work for that but never really tried..Maybe that is the most idiomatic way?

denisj08:08:25

Apologies if this has been asked before. Given a clojure Spec like the following, is it possible to extract the required keys again ?

(s/def ::composed
   (s/merge ::base (s/keys :req [:key3 :key4 :key5])))

roklenarcic11:08:52

hey guys, if you need to load a configuration json from code base how do you do it? If I make a request, most libs give me async channels, but I'd like to block until config json is loaded.

robert-stuttaford11:08:35

that’s because all network apis in the browser are callback based, @roklenarcic

sundarj11:08:59

@roklenarcic you could do a synchronous XHR

roklenarcic11:08:08

right I know they are callback based, which is why I'm asking how do javascript developers (which I'm not) solve this problem, which is loading up a config json and i18n json at app startup

sundarj11:08:18

everything you can do synchronously you can do asynchronously, no?

roklenarcic11:08:53

it complicates things immensely

sundarj11:08:50

right, but it's still doable

roklenarcic11:08:56

ok, how would I do synchonous XHR

sundarj11:08:37

something like

(let [req (js/XMLHttpRequest.)]
  (.open req "GET" "config.json" false)
  (.send req nil)
  (-.responseText req))

roklenarcic11:08:03

ok I will look into this

andrewboltachev11:08:47

Hello. What library/tool is mostly used for server-side rendering in React+ClojureScript apps?

Roman Liutikov12:08:41

@andrewboltachev take a look at Rum library

gtrak12:08:30

having used om-classic and js react, I think rum is more flexible, but also terser and less annoying to use, no need for manual sablono.

gtrak12:08:24

om's cursors aren't great for everything, rum has cursors and other state strategies but doesn't force you to use them.

andrewboltachev12:08:18

Is it better than Reagent?

andrewboltachev12:08:48

anyways Rum uses macros. I don't like usage of macros LOL 😄

gtrak12:08:31

it needs macros to compile react forms efficiently

andrewboltachev12:08:49

ok. efficience matters, I agree

gtrak12:08:20

I think not being afraid of macros is a good strategy in a lisp 🙂. Rum's pretty small, though. It's sablono + a component wrapper and some helpers for state.

gtrak12:08:22

I haven't used reagent but it seemed too opinionated to me, people seem to like re-frame (built on top) for larger-scale applications.

andrewboltachev12:08:41

yep, I've used re-frame a lot

andrewboltachev12:08:04

what I like in the reagent+re-frame is a tend to make everything declarative

gtrak12:08:11

Yea, if you already know reagent, I'm not sure if learning rum is going to help you do SSR better

gtrak12:08:41

actually this is a nice feature of rum: > Rum server-side rendering does not use React or Sablono, it runs completely in JVM, without involving JavaScript at any stage.

andrewboltachev12:08:17

but there's a bit of interference between classical Hiccup and...

andrewboltachev12:08:39

at least with Hiccup syntax as it's used by Reagent well, probably Rum's markup is very similar to classical Hiccup?..

gtrak12:08:39

yea, I'm not sure how reagent's is implemented, but I think Rum uses sablono for this job

gtrak12:08:42

actually it seems to reimplement it for server-render

roklenarcic12:08:08

I've started using boot-cljs and a boot build, but when I run the task, compiled files don't show anywhere in project tree

roklenarcic12:08:36

it somehow run-development task works, reloading and page works

roklenarcic12:08:47

but build-development doesn't produce any files

roklenarcic12:08:53

at least not in project folders

andrewboltachev12:08:33

@roklenarcic shouldn't it be a single output file when using :optimizations :advanced?

roklenarcic12:08:01

there's no output at all

andrewboltachev12:08:20

how do you know?

andrewboltachev12:08:34

may be it overwrites your other files?

roklenarcic12:08:38

there's no new files in my project tree

andrewboltachev12:08:45

i.e. the old ones

roklenarcic12:08:53

but there are no old js files

roklenarcic13:08:01

it says compiling meds.js

roklenarcic13:08:13

after it finished, there's no such file in project tree

roklenarcic13:08:18

or a similar one

roklenarcic13:08:29

there's no js files whatsoever

andrewboltachev13:08:29

in "project tree" or in a filesystem?

andrewboltachev13:08:49

uhm that's a little funny then

roklenarcic13:08:06

I've read the docs of boot-cljs

roklenarcic13:08:14

and it says I don't have to specify output-dir

juhoteperi13:08:56

@roklenarcic Your Boot tasks don't output any files, you need target task or something similar. Boot doesn't write anything to working directory, unless you tell it to.

roklenarcic13:08:36

really? I copied this from an example of a boot project

roklenarcic13:08:45

not even my invention

andrewboltachev13:08:23

interesting @juhoteperi @roklenarcic so this is probably how so-called "pods" work?

juhoteperi13:08:27

Hmm, yeah, boot-cljs-example is out of date. That would work with boot 2.5 and old boot-cljs, but Boot 2.6 removed the implicit target task.

juhoteperi13:08:17

@andrewboltachev No, not related to pods, those are about isolating dependencies, this is about Boot tmp-dirs and fileset.

roklenarcic13:08:55

so I need to add a target task?

juhoteperi13:08:05

@roklenarcic Yes, (target :dir #{"target"}) should do it. After cljs task, before serve.

roklenarcic13:08:49

the funny thing is that the run-development task works, it compiles/reloads/serves the page

roklenarcic13:08:13

so it's pulling files from some temp dir somewhere

juhoteperi13:08:29

Yes, serve can serve the files from classpath (which includes the Boot temp-dirs with output role)

juhoteperi13:08:50

And cljs task automatically adds the files to the fileset with output role

deas13:08:07

Is there a "mostly safe" way to replace a transitive cljsjs dependency with node modules? Say I want to use devcards in an application which uses react from node modules. Looks like global exports might help here.

andrewboltachev13:08:58

Hi @deas I've experience connecting React from node_modules

dnolen13:08:32

@deas that’s one of the big ideas behind global exports - but artifacts have to transition to that first before end users have an easy migration path

selfsame13:08:01

interesting difference with cljs and clj: (list? (cons '+ (list 1 2)))

deas13:08:37

@dnolen I was wondering whether it should be possible to say swap out cljsjs.react in your project with a node module based version - with devcards or other libs being unaware of that.

dnolen13:08:05

@selfsame yeah that’s an old discrepancy from ~5 years ago - I suppose we could change that, but maybe not worth it

dnolen13:08:23

@deas yes that’s what global exports is for

dnolen13:08:33

but cljsjs.react has to change first

selfsame13:08:31

yeah imagine it would break a lot of stuff if it was changed

deas13:08:43

@dnolen cljsjs.react has to change because there is no way to override deps.cljs from the jar?

dnolen13:08:48

actually I suspect it’s a pretty rare predicate since it captures so little

dnolen13:08:25

@deas it has to change so that your code doesn’t when you switch artifacts

dnolen13:08:40

if you don’t use global exports than you’re referring to global names

dnolen13:08:48

which is incompatible with requires from node_modules

lxsameer15:08:39

hey folks, what do you use for managing your static files ?

dnolen15:08:54

standard thing is to put them on a CDN

juhoteperi15:08:40

I usually just put the files under prefix in uberjar and serve using Ring, ensuring they have proper cache headers, and add cache busting query string to script/link urls. Works fine for smaller apps (like intranet apps or such).

lxsameer15:08:42

I was looking for some assets pipeline to take case of the path and other stuff like appending the checksum to the name etc

juhoteperi16:08:38

@deas @dnolen Looks like updating devcards to use global-exports and support node_modules requires at the same time updating sablono, om and rum, and I fear all these updates will be breaking, reagent is currently only lib with support for this

juhoteperi16:08:37

And all these libs will require Cljs 1.9.854 after the update

dnolen16:08:01

@juhoteperi I don’t see how it will be breaking

dnolen16:08:11

global exports doesn’t prevent global access

juhoteperi16:08:07

But using global access prevents using node modules

dnolen16:08:16

and prior version of ClojureScript will ignore it

dnolen16:08:27

there’s nothing breaking here though

dnolen16:08:34

if you haven’t fixed it you can’t use node modules

dnolen16:08:39

that’s new stuff

dnolen16:08:59

anybody that switches to global exports is just providing a forward path

dnolen16:08:11

nobody staying with old stuff is going to change

juhoteperi16:08:23

Hm, not sure I understand, perhaps there is difference what I refer to with breaking?

juhoteperi16:08:44

New foreign libs using global-exports work with old ClojureScript, yes

juhoteperi16:08:13

But libraries (Reagent, Om etc.) which start using (:require [react :as react]) to support both node modules and global-exports will require new ClojureScript

dnolen16:08:26

yes but you don’t need to change all libs

dnolen16:08:35

just the one you care about

juhoteperi16:08:00

Devcards depends on sablono, sablono depends on om/rum/reagent (for tests, I think)

dnolen16:08:06

oh if you want to use node_modules

dnolen16:08:20

yes then everything in your dep graph needs to be updated

dnolen16:08:41

right that’s to be expected, it’s going to take a while for sure

dnolen16:08:53

there’s a bunch of stuff still be sorted with node_modules anyhow still

p4ulcristian17:08:04

Hello, I want to ask how can I put dashes in hiccup attributes? [:div {:uk-icon "icon"}] is <div ukIcon = "icon"> because of the camelcase 😕

rgdelato17:08:01

I'm pretty sure this has been asked before, I think the solution last time was to use data attributes ala {:data-uk-icon "icon"}

p4ulcristian17:08:55

I am very thankful for this information, you saved my project. Can I ask from where do you know this, so I don't have to ask any more trivial questions?

rgdelato17:08:33

I haven't used UIKit, I honestly only know this because someone else asked it before

dnolen18:08:55

@juhoteperi had an idea about your point - we could actually use global exports in an interesting way

dnolen18:08:05

moving this to #cljs-dev

cap10morgan18:08:38

I am wayyyyyy out of my element here (w/r/t the JS ecosystem stuff), but I just pulled in a react component lib (react-calendar-heatmap) using npm-deps in cljs 1.9.908 and found that I needed to use it via (.-default CalendarHeatmap) instead of just CalendarHeatmap. This seems to have something to do with one of the many JS module export approaches? Did I / they do something wrong here or is this just one of the rough edges of the new npm-deps support?

dnolen18:08:35

@anmonteiro ^ I can’t remember, is this expected?

anmonteiro18:08:33

@cap10morgan I don’t really understand what you’re saying. can you post a snippet of your importing + usage of that module?

anmonteiro18:08:58

you totally need to use .-default

dnolen18:08:59

this is a case of export default Foo;

anmonteiro18:08:38

@cap10morgan but you can use CalendarHeatmap/default

anmonteiro18:08:59

no need for interop there if you’re consuming a node module

cap10morgan18:08:37

hmm, CalendarHeatmap/default didn't work

cap10morgan18:08:16

my require line is (:require ["react-calendar-heatmap" :refer [CalendarHeatmap]])

dnolen18:08:26

that won’t work

dnolen18:08:39

(:require ["react-calendar-heatmap" :as CalendarHeatmap)

cap10morgan18:08:50

which was my attempt at translating this JS: import CalendarHeatmap from 'react-calendar-heatmap';

cap10morgan18:08:53

OK, will try that

anmonteiro18:08:26

no need for string too

Garrett Hopper18:08:32

Any dirac devtools users around here? I can't seem to get it working. The dirac window will open, but it doesn't have any files in the sources and no output in the console.

cap10morgan18:08:04

@anmonteiro without the string it tries to goog.require react_calendar_heatmap and fails (underscores vs. hyphens)

Garrett Hopper18:08:19

Console output. (Of Chrome Devtools in the Dirac Devtools window): http://sprunge.us/PBdN

anmonteiro18:08:27

@cap10morgan I don’t believe you

anmonteiro18:08:56

if that’s happening it’s because the module wasn’t correctly processed

dnolen18:08:23

@cap10morgan it should work, you should only need strings if it’s not a valid symbol - if you can find a case that doesn’t work it’s a bug

cap10morgan18:08:43

OK, I'll dig further and report an issue if necessary

darwin18:08:58

@ghopper are you running it with recent Chrome Canary?

anmonteiro18:08:03

@cap10morgan as I said above, happy to look at a snippet of your importing + usage of that module

anmonteiro18:08:11

would probably clear out any confusion

anmonteiro18:08:14

and save you some time

cap10morgan18:08:24

@anmonteiro cool, thanks. I'll get that up and linked here shortly.

dnolen18:08:25

@cap10morgan the goog.require is not going to be for a munged thing like that - Google Closure generates a name

Garrett Hopper18:08:31

I'm running with the latest chromium beta version. I couldn't build the dev. (Version 59.0.3071.86 (Developer Build) (64-bit))

anmonteiro18:08:34

@cap10morgan you may also wanna use :language-out :es5

anmonteiro18:08:41

or default will be munged to default$

Garrett Hopper18:08:49

@darwin Where do you see what version is required specifically?

Garrett Hopper18:08:07

That makes sense. I'll work on getting a more recent dev version.

darwin18:08:41

@ghopper each release has links to likely working chromium builds: https://github.com/binaryage/dirac/releases/tag/v1.2.15

darwin18:08:06

but generally current Chrome Canary should work

cap10morgan18:08:41

@anmonteiro https://github.com/democracyworks/elections-viz/blob/master/src/cljs/elections_viz/calendar_heatmap.cljs <- the non-working example w/ a symbol in the require vector. that along with the cljsbuild settings in project.clj should be all of it (and the main-panel component is referenced from the views ns).

cap10morgan18:08:38

oh, nevermind, it's not the symbol vs. string in the require (as you said). I'll push up my working example here. would love to know where I'm being non-idiomatic w/ it, though.

cap10morgan18:08:19

that's pushed

anmonteiro18:08:22

@cap10morgan I got it compiling locally

anmonteiro18:08:35

I think you won’t be able to use this from node_modules for now

anmonteiro18:08:12

I think Closure doesn’t understand the UMD pattern that the module exports

cap10morgan18:08:19

@anmonteiro I see. So is my working example an accident?

anmonteiro18:08:57

@cap10morgan wait, your example is working?

cap10morgan18:08:08

my most recent push, yes

anmonteiro18:08:12

it’s probably an artifact of having a global React 😛

anmonteiro18:08:26

if you were also consuming react from node_modules it woudn’t work

Garrett Hopper18:08:58

@darwin Alright, I got a newer version. Any idea about these?

Internal Dirac Error TypeError: target.pageAgent(...).setAdBlockingEnabled is not a function
Internal Dirac Error TypeError: Cannot read property '_createLiveLocation' of undefined
Internal Dirac Error TypeError: Cannot read property '_createLiveLocation' of undefined
Internal Dirac Error TypeError: Cannot read property 'element' of undefined
Internal Dirac Error TypeError: Cannot read property 'element' of undefined
Internal Dirac Error TypeError: Cannot read property 'element' of undefined
Internal Dirac Error TypeError: Cannot read property 'element' of undefined

cap10morgan18:08:01

OK, yeah, I added that b/c I was getting an error about it not finding react

darwin18:08:16

@ghopper let’s move to #dirac

anmonteiro18:08:26

so perhaps worth making a note that the code may break if / when you move to consuming react from node_modules

cap10morgan18:08:23

@anmonteiro is there a less brittle way to consume this library for now?

anmonteiro18:08:49

use the bundle as a foreign library

anmonteiro18:08:21

i.e.copy node_modules/react-heatmap/build/index.js to a place in your repo

anmonteiro18:08:52

and add [{:file "path/to/react-heatmap/build/index.js" :provides ["heatmap"]}] to your foreign-libs in compiler opts

anmonteiro18:08:05

@cap10morgan you can also add :global-exports '{whateverGlobalTheLibProvides react-heatmap} to the foreign lib entry

anmonteiro18:08:15

and keep your nice, idiomatic require

symfrog22:08:05

@anmonteiro I am trying out the fix to https://dev.clojure.org/jira/browse/CLJS-2326 , using master I get the error No input matching "bootstrap" when attempting to (require [bootstrap]). I still get the same Assert failed: cljs.analyzer/foreign-dep? expected symbol got ... when trying other paths. Were you able to require bootstrap with that fix on your side?

anmonteiro22:08:48

we do have tests for that though, and they’re passing…

anmonteiro22:08:36

I’m happy to look at a minimal failing case but I would check that you’ve cleaned your build first and are actually running ClojureScript master

symfrog22:08:13

@anmonteiro ok, thanks, will continue to look for a possible issue on my side