Fork me on GitHub
#clojurescript
<
2016-02-23
>
futuro01:02:14

When you're building full-stack apps, do you distribute the front-end with a CDN, and if so, do you develop the front and back-end's in the same repo, or separate them?

richiardiandrea01:02:23

@futuro about #2 in my experience it is better to have separate project, and usually yes the frontend content in in a sort of CDN but to make it super fast there are modules, server-side rendering, very nice tricks 😉

futuro01:02:19

@richiardiandrea: Cool, thanks for the tip simple_smile

richiardiandrea01:02:39

@futuro: NP! in a project I had both together and ended up with all sorts of dependencies problems, than switched to boot and thanks to its pods the pain healed a bit 😄

futuro01:02:37

huh, interesting.

futuro01:02:15

It seemed like there could be benefits to having both in one project; one less directory to move around in, similar project.clj; but I wasn't entirely sure

futuro01:02:27

I suppose the only way to know is to try them both out 😛

richiardiandrea01:02:16

Agree, but it's always good to ask so that you have an idea simple_smile For example in boot I had a lot of fun dispatching on a multimethod, calling for instance boot -e flavor=backend build --type prod or analogous for frontend. Leiningen gives you less flexibility but more of a declarative approach. But it can get big: https://github.com/Lambda-X/replumb/blob/master/project.clj

sveri09:02:57

Hm, not long ago I read about a cljs librarie for games, a wrapper around a js library. But I cannot recall its name. Any ideas?

sveri10:02:13

@msuess: ah, that was what I was looking for, thanks

limist13:02:43

Noob debugging advice please: if i'm seeing an error in the compiled and deployed cljs, that's totally absent from local version, how should I got about debugging it? Error message from the compiled version is, "Uncaught Error: Vector's key for assoc must be a number."

dnolen13:02:51

@limist: this sounds like a runtime bug not present in your local setup

dnolen13:02:10

somewhere you are trying to assoc a vector with a key which is not a number

aleph13:02:46

cool stuff, thanks @mlatu !

limist13:02:00

@dnolen Yes thanks, is there a way to get more info from the compiled version when one cannot reproduce it locally?

dnolen14:02:24

@limist: you can build source maps and make those only visible to yourself a la http://blog.getsentry.com/2015/10/29/debuggable-javascript-with-source-maps.html

sveri14:02:22

I am trying out devcards and as soon as I add this expression: [devcards.core :refer-macros [defcard]]or this (:require-macros [devcards.core :refer [defcard]]) section I get this error: Uncaught TypeError: Cannot read property 'render' of undefinedin my browser console. Any ideas what is going on here?

darwin14:02:28

some code is trying to access render property on a javascript object which happens to be null/undefined, for example this code would do that (.-render (call-function-returning-nil))

darwin14:02:36

a pro-tip: cljs-devtools with :sanity-hints enabled could help you locate exact source code location when that happened: https://github.com/binaryage/cljs-devtools#an-example-of-a-sanity-hint

sveri14:02:37

@darwin: Thanks for the suggestions. Still, there must be something missing in my project or I have some misconfigured dependencies.

darwin14:02:14

try to ask in #C09GR9UJC

sveri14:02:46

ah, we also have a channel for that, good idea

limist16:02:47

@dnolen: Thanks for the link!

pandeiro18:02:01

is there a semantic difference between (:require-macros [foo.bar :refer [baz]]) and (:require [foo.bar :refer-macros [baz]]) for a dep with a foo/bar.clj and foo/bar.cljs ?

pandeiro18:02:49

seems to me like the latter (`:require`) form should always be preferred as safer, but I'd never hit a problem with this til now

dnolen18:02:41

@pandeiro: the second case is sugar

dnolen18:02:52

the first case is the primitive

pandeiro18:02:56

@dnolen Wouldn't the latter also :require the foo/bar.cljs namespace, while the former wouldn't, necessarily? or am I misunderstanding?

dnolen18:02:36

@pandeiro: sorry I was talking specifically about :refer-macros in :require

dnolen18:02:02

not :require in general, I assumed you were not asking about that

pandeiro18:02:17

ah yeah I meant the cumulative effect of both expressions

dnolen18:02:30

:refer-macros will implicitly require the macro namespace

dnolen18:02:47

it must really

dnolen18:02:03

requiring is about loading, the :refer stuff is all syntactical convenience nothing more

dnolen18:02:32

@pandeiro: but I don’t really understand at all what you’re trying to actually ask

dnolen18:02:45

since no real problem has been posed

pandeiro19:02:52

@dnolen: Case in point (easier), re-frame uses a pattern where it loads a macro from reagent.ratom; However if the reagent.ratom CLJS namespace is not also required, that will spit out undeclared var warnings

pandeiro19:02:27

It doesn't show up most times, b/c in most namespaces, re-frame or reagent are also being required, bringing in the reagent.ratom transitively

pandeiro19:02:55

But if they are not there, the CLJS namespace of the same name only gets loaded using the second syntax I showed, not the first

dnolen19:02:03

@pandeiro: all of that is to be expected

pandeiro19:02:10

And until today I hadn't realized that subtle distinction

dnolen19:02:12

loading macros without requiring runtime stuff isn’t going to work

pandeiro19:02:15

Sure, makes sense

mfikes20:02:01

@pandeiro: FWIW, if you do (doc ns), an example showing exactly how the :refer-macros inline macro specification desugars appears at the bottom. If you are ever really curious, you can invoke the (undocumented internal) desugar function yourself. Here is it being done with Planck:

cljs.user=> (require 'cljs.analyzer)
nil
cljs.user=> (cljs.analyzer/desugar-ns-specs {:require '[woz.core :as woz :refer [woz-fn] :refer-macros [app jx]]})
((:require (woz.core :as woz :refer [woz-fn])) (:require-macros (woz.core :as woz :refer [app jx])))

pandeiro20:02:09

Interesting, thanks @mfikes

mfikes21:02:05

Captured the above in a gist in case anyone is interested in it: https://gist.github.com/mfikes/faea7393d04b92a43388

mfikes21:02:21

Wow… so bootstrapped ClojureScript’s known bug count went to zero today.

mfikes21:02:03

I think David started on it a little before mid-2015, and truth be told, most of the bugs were addressed fairly quickly. But it took a while to squash the long tail of tiny known bugs.

dnolen21:02:55

exciting stuff

gabe22:02:40

anyone know why reduce isn’t implemented for cljs.core/PersistentHashMap?

gabe22:02:55

I know I can use reduce-kv

gabe22:02:39

it’s inconsistent w/ Clojure

dnolen22:02:03

@gabe: an artifact of history, it could directly implement but it doesn’t need to due to seq-reduce

dnolen22:02:12

a patch that copies the Clojure implementation is welcome

gabe22:02:22

ok. thx!