Fork me on GitHub
#clojurescript
<
2017-01-10
>
alex-glv05:01:34

Can anyone suggest why I can’t target :nodejs when building cljsjs.react dependant app? I get

Error: Cannot find module ‘react’` 
thrown from react.inc.js, even though I don’t use any optimizations? Something to do with require paths, but can’t make it look in the directory where compiled files are (out)

alex-glv07:01:11

MODULE 33851: load “/Users/a/Sites/boards-io/target/test/test.js" for module "."
MODULE 33851: Module._load REQUEST react parent: .
MODULE 33851: looking for "react" in [”/Users/a/Sites/boards-io/target/test/node_modules”,"/Users/a/Sites/boards-io/target/node_modules","/Users/a/Sites/boards-io/
node_modules”,”/Users/a/Sites/node_modules","/Users/a/node_modules","/Users/node_modules","/usr/lib/node_modules","/usr/lib/node_modules","./","/Users/a/Sites/boar
ds-io/target/test/out/”,”/Users/a/.node_modules”,"/Users/a/.node_libraries","/Users/a/.nvm/versions/node/v6.3.1/lib/node"]
module.js:442
    throw err;
    ^

Error: Cannot find module 'react'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at COMPILED (/Users/a/Sites/boards-io/target/test/test.js:41:87)
    at Object.<anonymous> (/Users/a/Sites/boards-io/target/test/test.js:41:310)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)

gfredericks12:01:52

what is the easiest way to start a cljs repl in node from leiningen, with or without a project

dnolen13:01:03

@gfredericks how do you specify ClojureScript dep w/o a project?

dnolen13:01:23

@gfredericks re: cljs.test - some things were done simply to work around the fact that hardly anything can be done at runtime and must be done at macro time.

dnolen13:01:10

@alex-glv need more information, what did you write that triggers that Node.js require?

leov13:01:35

hello everyone

leov13:01:14

new to clojurescript/react SPA development - can you plz point me to complete routing example, preferrably bidi or silk?

leov13:01:54

I see how to match a route, but I don't see library helpers to hook up into browser navigation during page load

robert-stuttaford13:01:40

you could replace the secretary/dispatch! with a bidi/match-route or whatever

robert-stuttaford13:01:24

it’s a very tiny bit of code, thanks to google closure

leov13:01:40

well, in that example, how does it know which exact page/url it landed on?

leov13:01:27

during initial page load

robert-stuttaford13:01:38

in your root component’s did-mount, you’d call whatever processes your route with your routing with js/window.location. there must be a full example somewhere in the clojureverse

leov13:01:29

am I correct that all routing libraries do these things: 1. hook into history API 2. parse current window location and call a callback 3. have a sugar function that navigates you to different location and calls a callback

leov13:01:43

thnx googling

leov14:01:23

ok got it. thanks

claudiu14:01:21

Trying to pick a library for react in clojurescript. So far rum seems like the nicest because it has server side rendering in clojure. Can't really seem to figure out why reagent does not have this or why rum is rarely mentioned in talks/articles (almost all are about reagent & om).

dnolen14:01:14

@claudiu simple - Reagent & Om are the oldest by far

ejelome14:01:56

what does static html generator even mean?

gfredericks14:01:16

@dnolen the magical tool I had in mind would pick a cljs version for me. I just wanted to get a cljs repl fast to try something out. I ended up doing "lein new reagent" and "lein figwheel" because I knew that would work, but it was four steps instead of one

dnolen14:01:27

@gfredericks not aware of anything

ejelome14:01:35

maybe boot instead of lein?

claudiu14:01:16

@dnolen What react wrapper would you recommend for a clojurescript (the project needs to have server side rendering in clojure) ?

dnolen14:01:29

@claudiu I have no recommendation

dnolen14:01:41

use whichever one looks most appealing to you

dnolen14:01:20

Reagent & Om have the most users & documentation. Rum is newer but it has a community and may have the features you want

claudiu14:01:35

Yes, still a bit new. to clojure So far the most appealing would be reagent + re-frame but they don't seem to offer clojure rendering.

claudiu14:01:33

Seems to be down to rum or om.next. A bit confused with om & om.next when googling for resources. Is om.next stable enough now ?

dnolen14:01:38

@claudiu there’s a #reagent channel, maybe ask there first about server side rendering

dnolen14:01:44

maybe there’s some third party solution to that problem

rauh14:01:01

How do I force a file to be recompiled when annotating it with ^:figwheel-always, I need macroexpansion to happen anew. I'm fine with a hack

claudiu14:01:37

@dnolen thank you 🙂

robert-stuttaford14:01:41

fwiw, @claudiu, rum is very simple to get started with, and it stays quite simple even as codebases grow. here’s a pretty concise example using rum and datascript: https://github.com/robert-stuttaford/stuttaford.me/blob/master/src/stuttaford/client/components/codex.cljs — you can see it in action here http://www.stuttaford.me/codex

robert-stuttaford14:01:58

(full disclosure: i work with the person who made rum)

claudiu14:01:42

@robert-stuttaford thank you will look into it 🙂

dnolen14:01:13

@claudiu people use om.next in production, and it’s pretty stable. that said I would say it’s one of the more challenging bindings to adopt because it has opinions about server/client relationship

dnolen14:01:52

so if you’re just getting started with ClojureScript expect some significant rampup time

dnolen14:01:50

my recommendation would be to start with something less sophisticated, om.next isn’t going anywhere if you decide you like it at some future time

ejelome14:01:20

@robert-stuttaford interesting! I always wondered where does datascript fit into the ecosystem, is it the sql to talk to clojure (server)?

schmee15:01:28

ejelome datascript is an in-memory DB, with a datalog query language

schmee15:01:45

it’s commonly used to store app state for cljs apps

schmee15:01:09

it is integrated with reagent for instance: https://github.com/mpdairy/posh

ejelome15:01:50

^ awesome share

ejelome15:01:36

... I have too many questions in mind XD

ejelome15:01:48

@schmee if it's not too much can I extend my question about datascript because I'm confused how it fits with data persistence, because I keep on seeing people using both datascript and a database e.g. rethinkdb, are these for optimization purposes or the latter is a necessity?

schmee15:01:08

out of the box Datascript is not involved in persistence whatsoever, it is in-memory only

schmee15:01:03

but I suppose it is possible to extend to that is more of a “cache” for a Rethink-backend, so that the Datascript db mirrors the Rethink one and vice versa

schmee15:01:19

but these thing are all separate from Datascript itself

schmee15:01:47

just think of it as a hash map with a query language 🙂

ejelome15:01:15

ahhh, so that's it, it's a temp storage

schmee15:01:57

yeah, it’s a alternative to “giant hash map in an atom” for app state

ejelome15:01:03

thanks @schmee, that clear things up 😄

exit216:01:41

hi all, I’m trying to figure out the cljs equivlent for $(window).unload(cb), I’ve tried (.unload (jquery “window”) and a few other variations but can’t seem to get it right

darwin16:01:48

what about (-> (js/$ window) (.unload cb))?

exit216:01:14

TypeError: $(...).unload is not a function

exit216:01:25

maybe jquery isn’t loaded in my repl 🙂

darwin16:01:40

ah. maybe (-> (js/$ js/window) (.unload cb))?

exit216:01:19

hmm same error

exit216:01:22

jquery is available too

exit216:01:28

(js/$)
jQuery.fn.init {}

darwin16:01:37

what do you get when (js* "$(window).unload(cb)”)?

exit216:01:31

same, weird..

exit216:01:33

TypeError: $(...).unload is not a function

darwin16:01:47

so there is no unload method on wrapped jquery window object

exit216:01:55

ya it seems

darwin16:01:46

the method has been removed in jQuery 3.0: https://api.jquery.com/unload/

exit217:01:24

I wonder if they want you to just use .on(‘unload’)

darwin17:01:49

probably, but I don’t have time to study it now 🙂

exit217:01:16

thanks for your help @darwin

exit217:01:07

this doesn’t throw an error (-> (js/$ window) (.on "unload" (fn [e] (js/console.log e))))

scaturr18:01:09

Forgive me if this has been asked a bunch 😞, but google turns up little: What is the best way to deploy a library to clojars that supports both node and the browser? In my case, my library would support HTMLCanvasElement for the drawing in the browser, and node-canvas when being used from node. https://github.com/Automattic/node-canvas

scaturr18:01:29

Any way to make it transparent to the user? Do I need to use *target* perhaps?

selfsame18:01:11

@scaturr yeah probably (def *canvas* (try (nodejs/require "canvas") (catch :default e (make-html-canvas)))) or something

scaturr18:01:09

cool. thanks!

rocaboca21:01:38

How can i use https://github.com/apollostack/graphql-tag or something similar to parse a graphql query in cljs?

alex-glv22:01:35

@dnolen: I created the issue in cljsjs/packages as I am not sure what's causing it. https://github.com/cljsjs/packages/issues/923 it has minimum reproduction repo.

anmonteiro22:01:15

@alex-glv I haven't been following your issue but I don't see you ever requiring cljsjs.react in that repo

anmonteiro22:01:31

ReactDOM needs React and you're never including it

alex-glv22:01:00

@anmonteiro https://github.com/cljsjs/packages/issues/923 I’ve clarified the issue that requiring react doesn’t make a difference. With that reasoning, wouldn’t requiring react.dom resolve react as a dependency anyway? The same way when I require om.dom it requires react.dom which requires react? If I understand your point correctly.

anmonteiro22:01:30

@alex-glv right then I've had your issue and solved it by npm install react

anmonteiro22:01:54

I'm not sure this is a problem with ClojureScript or CLJSJS packaging, but instead with the way React packages are put together

alex-glv22:01:19

I though I pushed it, but here it is https://github.com/alex-glv/nodejs-cljs/blob/master/src/nodejs-cljs/core.cljs . Installing react from npm seems to fix it. Huh.

sandbags23:01:05

@pupeno ping. I just updated to the latest version of free-form and it no longer seems to be dispatching my update event, no errors in the console, not sure where to look. any advice?

sandbags23:01:01

@pupeno my error, i copied the updated markup from the new examples too literally and, accidentally, replaced a free-form.re-frame/form call with a free-form.core/form call

sandbags23:01:27

@pupeno free-form is very useful, grateful to you for releasing it