Fork me on GitHub
#clojurescript
<
2015-08-11
>
lvh00:08:41

What the heck… I’m using cljs-time, and cljs-time.core is nil when I require it. All the other nses are fine

lvh00:08:56

cljs.user=> (require 'cljs-time.core)
nil
cljs.user=> (require 'cljs-time.format)
nil
cljs.user=> (require 'cljs-time.coerce)
nil
cljs.user=> (map some? [cljs-time.core cljs-time.format cljs-time.coerce])
(false true true)

shaunlebron03:08:04

@bensu: honestly, lein’s overhead is something that eludes me

shaunlebron03:08:51

I wonder if there’s really value putting this stuff through lein rather than exposing just the small scripts

shaunlebron03:08:33

and having the build configs in some file clojurescript-builds.edn. reason I opted out of putting them in project.clj was to allow us to read the file without using lein, since it does profile merging and other things

shaunlebron03:08:32

I don’t have a strong opinion, just trying to reconcile david’s aversion to cljsbuild with the current state of the de facto build tools. I just recently realized that mies doesn’t use lein for anything other than managing dependencies and thought that was elegant

ricardo04:08:06

Cool, new #C08LK2DH7 channel. Bit unpopulated now, though.

ricardo04:08:54

According to https://github.com/emezeske/lein-cljsbuild/blob/master/doc/TESTING.md, if :hooks are enabled then lein test should also run the ClojureScript tests. I do have hooks enabled, but when doing lein test I only see it build ClojureScript. I don't get the cljs test reports. Any ideas?

ricardo04:08:03

Configuration is pretty much this: https://github.com/ricardojmendez/tropology/blob/develop/project.clj#L53-L63 (only with :hooks [leiningen.cljsbuild] on the :test profile.

ricardo04:08:08

cljs tests run and report correctly if I just to lein cljsbuild test

bensu08:08:09

@shaunlebron: I agree that there is a lot of overhead to lein. But you said yourself, it manages dependencies for you! That is why the mies scripts still use it. Also it presents an easier to remember interface and entry point into the clojure build world. The point of lein-cljs would be to present an uniform interface to a spoiled user (me simple_smile ) and then get out of the way, while avoiding some repetition. I have +10 cljs projects and I wouldn't like to fill them with the same scripts, and then have to mantain them over time.

bensu08:08:41

@shaunlebron: @bhauman as for a cljs.config.edn, I could see it's value, specially considering boot which doesn't care about project.clj. cljs.config.edn could be a ground zero for any build tools

bensu08:08:02

@bhauman: finally, what you are looking for, docs for custom build pipelines, seems to be more approachable from boot. I don't have much experience but I'll definitely look at it.

martinklepsch08:08:54

@bensu: boot provides an interface similar to the cljs.config.edn: https://github.com/adzerk-oss/boot-cljs/tree/d06714775d49e37d2642a6cda8fd84270a2b1d29#multiple-builds (slightly outdated docs)

bensu08:08:36

there we go, my-build-name.cljs.edn

bensu08:08:49

I need to go and try boot (`tenzing`?), think about it, and then decide if something like lein-cljs is really needed, or the scripts will suffice

martinklepsch08:08:35

lein new tenzing +garden +less +sass +om +reagent — pick one of om/reagent (this is a verbose list of options)

crisptrutski08:08:26

and +test to add doo 😉

val_waeselynck08:08:35

does anyone know how to scrape some HTML from the browser in ClojureScript? I've tried something like (-> (dommy/create-element :html) (dommy/set-html! my-html-string)), but when I cannot seem to query against it - it's as if it was querying my DOM instead of the DOM I just created

martinklepsch09:08:24

@val_waeselynck I’d check if I find something relevant in goog.dom

val_waeselynck09:08:34

@martinklepsch: thanks, will check it out

shaunlebron12:08:39

@bensu: > I have +10 cljs projects and I wouldn't like to fill them with the same scripts, and then have to mantain them over time

shaunlebron12:08:57

I think that point is good

bensu12:08:57

@shaunlebron: "I think that point is good", as opposed to the others simple_smile haha

shaunlebron12:08:36

well, especially

bensu12:08:45

it's the same reason I started a lein plugin for cljs testing. I had runners/phantom-script.js in every project.

shaunlebron12:08:39

lein is of course important for deps. I would rather just use lein deps and be done with it, like npm install

shaunlebron12:08:32

I don’t know, I like the idea of maintaining the scripts more easily through lein though

bensu12:08:00

it doesn't need to be lein. that is why I brought up boot. If what we need is flexibility and composability, boot was designed specifically for that

bensu12:08:41

but I find the /scripts everywhere as a step back (though great to educate on cljs basic)

dnolen12:08:46

@bensu I think this is very much a case of “it just depends"

dnolen12:08:23

I think people should continue to use to Boot & Lein. They are great tools for beginners and experienced users alike. But I would also like to see more dissemination of information on how to use Maven directly and how to script your application with Clojure only.

dnolen12:08:54

there’s a pervasive misinformed notion that Clojure is bad for scripting due to latencies introduced by other tooling.

bensu12:08:54

@dnolen: I agree that it depends. I often have a couple of specialized scripts, specific to the project, and I see their value. I'm just reluctant to have everything be a script, when most of what I do is cljs.watch.api using with no callback fn.

bensu12:08:22

on Maven usage, I have little to none experience to contribute work or opinions on the matter 😞

pandeiro12:08:33

@dnolen: what are the major issues you see (if any) with the current state of cljs tooling, as it applies to creating large frontend apps?

bensu12:08:54

the lein-cljs experiment is: Can we offer the basic cljs api without requiring the user extra work and without getting in the way of the compiler?

dnolen12:08:59

@pandeiro: I really don’t see any huge problems

dnolen12:08:30

but I do think there’s a lack of wide spread understanding on how the tools actually work

pandeiro12:08:10

@bensu: i'm curious what motivated lein-cljs; can you go into more detail?

dnolen12:08:41

the problem w/ that is that perfectly fine projects like cljsbuild languish (due to little contribution to bring it up to parity with the rest of the ecosystem)

pandeiro12:08:23

@dnolen: yes, i am wondering what the state of cljsbuild is; i noticed bhauman has his own cljs compiler for figwheel too... so we have four compiler tool/libs and counting...

bensu12:08:34

@pandeiro: the cljs.api is so good, that I didn't need lots of motivation. if you read the source, you'll know what I mean.

dnolen12:08:58

@pandeiro: “own cljs compiler"

dnolen12:08:18

in nearly every case these tools simply defer to ClojureScript

pandeiro12:08:59

@dnolen: no right, i know... referring to https://github.com/bhauman/clojurescript-build -- it uses that and cljsbuild... now there is lein-cljs, boot-cljs too

pandeiro12:08:24

@bensu: i wonder if the same logic should apply to boot-cljs (ie, simplify and defer more work to cljs.build.api)

bensu12:08:08

@pandeiro working on the compiler has shown me how cljsbuild often got in the way, specially due to bad default opts. At the same time I do want some easy access point to the compiler from the command line. @shaunlebron was talking about how to package these scripts into the figwheel template, or figwheel itself. voila, lein-cljs

dnolen12:08:14

@pandeiro: that’s the idea, tools that don’t should be expected to break

dnolen12:08:25

I’ve been saying that for a year now

juhoteperi12:08:29

@pandeiro: Boot-cljs already uses cljs.build.api and other than small fixes there isn’t much that could be moved to cljs api

dnolen12:08:24

and all these nitpicks aside, to be clear I’m happy with the situation overall simple_smile

dnolen12:08:21

perhaps the only thing I would like to see which I don’t actually need myself at the moment is some CSS / image packing solution.

bensu12:08:21

@dnolen: please be picky. it's the way forward. is there any fundamental reason you don't see something like lein cljs from working?

bensu12:08:56

@dnolen: on the CSS/packing, I see it as something to be handled by ClojureScript on node, taking advantage of npm modules

dnolen12:08:20

@bensu that’s a good point, npm modules are very useful for scripting

bensu12:08:20

(by somebody that knows something on the subject. I don't simple_smile )

dnolen12:08:28

been loving YUIDoc for precisely that

bensu12:08:57

@dnolen: that is where I see a good story for cljs on node or even cljs.js

dnolen12:08:55

@bensu yeah another good point

shaunlebron13:08:37

@bensu: I can see using mies for visibility into the build process, and lein-cljs for convenience

shaunlebron13:08:47

I think it’s somewhat relevant to see how many ways babel can be used: http://babeljs.io/docs/setup/

martinklepsch13:08:31

Are there other Clojure & ClojureScript validation libs that people use? Saw validateur (http://clojurevalidations.info/) and obviously Schema. Herbert which many people seem to like isn’t targeting CLJS.

dnolen14:08:59

@martinklepsch: I’m surprised no one ported herbert yet

martinklepsch14:08:06

@dnolen: well it uses a bunch of libs that are not available in CLJS I believe

martinklepsch14:08:46

@pandeiro: thi-ng/validate looks sweet

val_waeselynck14:08:00

Leiningen noob question here. How can I make an uberwar from the lein-figwheel template? (running lein with-profile uberjar ring uberwar builds without the optimizations)

val_waeselynck14:08:07

Here is my project.clj:

ricardo14:08:44

@martinklepsch: Funny, I was just looking at the http://thi.ng libraries myself.

bhauman14:08:56

@bensu: @shaunlebron @dnolen So here is an idea. lein-cljs could run its tasks directly or with an --generate option generate a script to do the same task. This would give users a great path for taking control of the build process.

orther14:08:26

whoa http://thi.ng is an interesting collection

orther14:08:02

a lot of stuff

pandeiro14:08:20

and all the src is in *.org files simple_smile

val_waeselynck14:08:10

currently the one recommended by Luminus

martinklepsch14:08:40

@pandeiro: somehow validate isn’t written in literate org files

andrea.crotti15:08:29

sorry guys anyone know why I get this

andrea.crotti15:08:30

Uncaught ReferenceError: React is not defined(anonymous function) @ holidaysapp.js:33041

andrea.crotti15:08:46

created a simple app with the fig template

andrea.crotti15:08:09

adding these dependencies

andrea.crotti15:08:09

:dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/core.cache "0.6.4"] [org.clojure/clojurescript "1.7.58"] [om "0.8.0-rc1"] [org.clojure/core.async "0.1.346.0-17112a-alpha"]]

greywolve15:08:16

try replacing [om .. ] with [org.omcljs/om "0.9.0"]

ricardo15:08:34

@andrea.crotti: Is this after doing an uberjar? If so, do you have externs?

andrea.crotti15:08:51

@greywolve: ah ok I tried and it fetched react

andrea.crotti15:08:52

Retrieving org/omcljs/om/0.9.0/om-0.9.0.pom from clojars Retrieving cljsjs/react/0.13.3-0/react-0.13.3-0.pom from clojars Retrieving cljsjs/react/0.13.3-0/react-0.13.3-0.jar from clojars Retrieving org/omcljs/om/0.9.0/om-0.9.0.jar from clojars

andrea.crotti15:08:03

but still see the same issue after a cljsbuild

andrea.crotti15:08:16

do I ever need to restart figwheel maybe?

greywolve15:08:43

which template did you use ? i'll try it out on my side

bhauman15:08:04

@andrea.crotti: can you show us the code in holiday app that is causing this?

andrea.crotti15:08:06

I just did "lein new figwheel"

andrea.crotti15:08:27

I copied from an example @bhauman

andrea.crotti15:08:27

(om/root (fn [data owner] (reify om/IRender (render [_] (dom/h2 nil (:text data))))) app-state {:target (. js/document (getElementById "app"))})

andrea.crotti15:08:35

but don't think that code is the issue

andrea.crotti15:08:51

it's just that it's not compiling the dependencies properly I guess

andrea.crotti15:08:06

wait I also updated clojurescript to the last version which maybe was not a wise idea

bhauman15:08:23

@andrea.crotti: you do need to let things finish compiling.

andrea.crotti15:08:27

mm ok I thought I did running with auto

andrea.crotti15:08:45

ah gosh yes is true

andrea.crotti15:08:52

Successfully compiled "resources/public/js/compiled/holidaysapp.js" in 14.722 second

andrea.crotti15:08:55

I was impatient 😄

andrea.crotti15:08:12

I guess editing makes the compilation restart every time?

greywolve15:08:19

haha, is it working now?

greywolve15:08:38

it should be fast after the initial build

bhauman15:08:39

@andrea.crotti: you are not the only one. lots of folks do this

andrea.crotti15:08:12

I would have never thought it could take so long with an SSD

bhauman15:08:09

@andrea.crotti: you are compiling in :simple or :advanced right?

bhauman15:08:53

@andrea.crotti: you need to use optimizations :none in order to compile quickly

andrea.crotti15:08:51

I didn't touch the settings yet

andrea.crotti15:08:26

if I'm running "lein figwheel" already do I actually need to have "lein cljsbuild auto"?

andrea.crotti15:08:33

probably not, since it seems like it compiles already

bhauman15:08:53

you don't have to run lein cljsbuild auto

bhauman15:08:51

@andrea.crotti: it will save you hours and hours

andrea.crotti15:08:17

yes thanks @bhauman I went through that already many months ago but I forgot about that in the meanwhile of course

bhauman15:08:08

@andrea.crotti: cljsbuild auto defaults to :optimizations :whitespace so thats why the compile times where so long. You have to supply :optimizations :none explicitly when you are using cljsbuild if thats the behavior you want.

lvh16:08:09

I’m seeing super-weird behavior where cljs-time.core is nil under 1.7.28, and #js {} on 1.7.48. All other namespaces work fine. Github issue: https://github.com/andrewmcveigh/cljs-time/issues/41

andrea.crotti16:08:38

so I'm following this tutorial

andrea.crotti16:08:50

and while this works fine

andrea.crotti16:08:36

(om/root (fn [data owner] (reify om/IRender (render [_] (dom/p nil (:text data))))) app-state {:target (. js/document (getElementById "app"))})

andrea.crotti16:08:48

this instead should use a list

andrea.crotti16:08:49

(om/root (fn [data owner] (om/component (apply dom/ul nil (map (fn [text] (dom/li nil text)) (:list data))))) app-state {:target (. js/document (getElementById "app0"))})

andrea.crotti16:08:28

1. defining a component is the same as doing reify om/IRender?

andrea.crotti16:08:44

2. what is supposed to be in the HTML to make that work?

jackjames16:08:04

@andrea.crotti: highly recommend that you go slow, take your time, and read everything. even the docs!: https://github.com/omcljs/om/wiki/Documentation#component

jackjames16:08:40

@andrea.crotti: for 2), what's needed is a dom element with id "app0"

andrea.crotti16:08:43

yeah I have "app" in my example @jackjames so that should still work

andrea.crotti16:08:24

ah cool so om/component is a shortcut

jackjames16:08:18

@andrea.crotti: "app" will work for the first example that you pasted. but def not for the second. for that one, you'll need an element with id "app0"

andrea.crotti16:08:41

@jackjames: yes yes I know this is not the code I'm using

andrea.crotti16:08:58

it's the code from the wiki, mine is

andrea.crotti16:08:59

(om/root (fn [data owner] (om/component (apply dom/ul #js {:className "fruit"} (map (fn [text] (dom/li nil text)) (:fruit data))))) app-state {:target (. js/document (getElementById "app"))})

jackjames16:08:27

@andrea.crotti looks good as long as (:fruit data) evaluates to a seq of strings

jackjames16:08:13

(effectively, anyway)

shaunlebron16:08:14

@bhauman: love the --generate option

andrea.crotti16:08:14

(defonce app-state (atom {:fruit [:banana :strawberry]}))

andrea.crotti16:08:20

ok maybe they should be strings actually

andrea.crotti16:08:25

but should I not get an error?

jackjames16:08:18

@andrea.crotti: you should not get an error. you should get a list of gibberish like: bananabanana111528917921537751054096

andrea.crotti16:08:42

ah finally it works actually

andrea.crotti16:08:52

the new version of clojurescript I think was the issue

lvh16:08:39

Okay, so it looks like the weird bug where cljs-time.core is nil or the empty object is only under figwheel…. https://github.com/andrewmcveigh/cljs-time/issues/41

bhauman17:08:12

@lvh this is only when you require it in the repl right?

lvh17:08:59

@bhauman: No, it also appears to happen when I compile with nrepl. I guess that may be equivalent to requiring in the repl?

bhauman17:08:37

@lvh Ok so nrepl is an added complication.

bhauman17:08:39

This still sounds fishy though

lvh17:08:58

bhauman: I’m guessing the alternative is being required in an ns form?

bhauman17:08:39

For now require it in ns of your project

lvh17:08:52

bhauman: being pulled in through an ns form doesn’t help:

lvh@zygalski ~/P/r/crunch (master) [130]> rlwrap lein figwheel                   10:05:48
Figwheel: Starting server at 
Focusing on build ids: app
Compiling "resources/public/cljs/main.js" from ["src" "test"]...
Successfully compiled "resources/public/cljs/main.js" in 0.69 seconds.
Started Figwheel autobuilder

Launching ClojureScript REPL for build: app
Figwheel Controls:
          (stop-autobuild)                ;; stops Figwheel autobuilder
          (start-autobuild [id ...])      ;; starts autobuilder focused on optional ids
          (switch-to-build id ...)        ;; switches autobuilder to different build
          (reset-autobuild)               ;; stops, cleans, and starts autobuilder
          (reload-config)                 ;; reloads build config and resets autobuild
          (build-once [id ...])           ;; builds source one time
          (clean-builds [id ..])          ;; deletes compiled cljs target files
          (fig-status)                    ;; displays current state of system
          (add-dep [ "0.8.1"]) ;; add a dependency. very experimental
  Switch REPL build focus:
          :cljs/quit                      ;; allows you to switch REPL to another build
    Docs: (doc function-name-here)
    Exit: Control+C or :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when figwheel connects to your application
To quit, type: :cljs/quit
cljs.user=> @#'cljs-time.core
#js {}

lvh17:08:09

That’s without an nREPL client attached, FWIW

bhauman17:08:37

@lvh: well I'm giving it a try.

lvh17:08:48

Thanks; let me know if there’s any way I can help

lvh17:08:04

FWIW, the require libspec in that ns is [cljs-time.core :as tc]. For some reason, nrepl knows how to autocomplete tc/whatever, even though all of the tc/whatevers are nil.

lvh17:08:29

That might be a total red herring though simple_smile

lvh17:08:09

Also:

crunch.ctk> goog.date.DateTime
#js {}
nil

lvh17:08:12

That doesn’t seem right.

bhauman17:08:30

@lvh: so in the console I'm getting errors about DateTime.js not being found etc. So dynamic require of cljs-time doesn't seem to work from figwheel. But ... compiled require does work. If you do (clean-builds) (build-once) and then reload the page everything seems to be working at least in 3308.

lvh17:08:49

Okay, cool, I’ll try that

bhauman17:08:22

@lvh: this has come up before with cljs-time.

bhauman17:08:04

@lvh: haven't taken the "cljs - time" to track it down. ha ha

lvh17:08:02

cljs.user=> (clean-builds)
Focusing on build ids: app
Deleting ClojureScript compilation target files.
nil
cljs.user=> (build-once)
Focusing on build ids: app
Compiling "resources/public/cljs/main.js" from ["src" "test"]...
Successfully compiled "resources/public/cljs/main.js" in 3.988 seconds.
nil
cljs.user=> @#'cljs-time.core
#js {}
;;;;; REFRESHED PAGE HERE
cljs.user=> @#'cljs-time.core
#object[ReferenceError ReferenceError: cljs_time is not defined]
	  (resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:795)
	  (resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:53)
	  (resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:2)
	 figwheel$client$utils$eval_helper (jar:file:/Users/lvh/.m2/repository/figwheel/figwheel/0.3.7/figwheel-0.3.7.jar!/figwheel/client/utils.cljs:47:5)

bhauman17:08:51

Are you seeing errors in the dev console?

bhauman17:08:13

@lvh: alright I'll look at the more recent version of cljs

lvh17:08:32

Interesting, now I am

lvh17:08:35

GET 
 [HTTP/1.1 404 Not Found 1ms]
TypeError: cljs_time.internal is undefined core.js:21:0
GET 
 [HTTP/1.1 404 Not Found 1ms]
TypeError: goog.i18n.DateTimeSymbols is undefined Date.js:808:0
GET 
 [HTTP/1.1 404 Not Found 1ms]
GET 
 [HTTP/1.1 404 Not Found 1ms]
TypeError: goog.date.DateTime.prototype is undefined

lvh17:08:16

│       │       └── goog
│       │           │ …...
│       │           ├── date
│       │           │   ├── date.js
│       │           │   ├── datelike.js
│       │           │   ├── duration.js
│       │           │   └── utcdatetime.js

lvh17:08:19

It’s not wrong, I guess

bhauman17:08:54

if you reload the app you shouldn't get those errors

bhauman17:08:24

and in the dev console cljs_time will exist

bhauman17:08:28

also stop using the var and just use cljs-time.core

bhauman17:08:41

to test existence

lvh17:08:13

bhauman: Reload the app means refresh the browser?

lvh17:08:20

So, I get all of the errors in the browser about stuff being missing, I refresh, and then:

> cljs_time
ReferenceError: cljs_time is not defined

lvh17:08:24

(In the dev console of course)

lvh17:08:36

cljs.user=> cljs-time.core
#object[ReferenceError ReferenceError: cljs_time is not defined]
	  (resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:69)
	  (resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:53)
	  (resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:2)
	 figwheel$client$utils$eval_helper (jar:file:/Users/lvh/.m2/repository/figwheel/figwheel/0.3.7/figwheel-0.3.7.jar!/figwheel/client/utils.cljs:47:5)

lvh17:08:08

I can (require ‘cljs-time.core) but then I get the same errors in the dev console:

GET 
 [HTTP/1.1 404 Not Found 1ms]
TypeError: cljs_time.internal is undefined core.js:21:0
GET 
 [HTTP/1.1 404 Not Found 1ms]
TypeError: goog.i18n.DateTimeSymbols is undefined Date.js:808:0
GET 
 [HTTP/1.1 404 Not Found 1ms]
GET 
 [HTTP/1.1 404 Not Found 0ms]
TypeError: goog.date.DateTime.prototype is undefined

lvh17:08:22

FWIW it seems like the paths are messed up

lvh17:08:39

It’s not supposed to ask for goog/date/DateTime.js; that lives in goog/date/date.js

lvh17:08:03

I don’t know who comes up with that path though; I’m guessing figwheel

bhauman17:08:54

@lvh: yeah that's the problem. But to get things working. Require the clsj-time.core in a file thats required by your app, compile everything, from scratch and load the app. That should work

lvh17:08:54

However, running the tests with doo (so also in a browser but w/o figwheel) seems to work fine

lvh17:08:46

bhauman: When you say required by your app, is having it anywhere in src/ good enough, or is there a specific ns that should require the ns that requires cljs-time

lvh17:08:55

that seems like it is ripe for experimentation

lvh17:08:07

since figwheel does do a lot of fancy dependency graph stuff simple_smile

bhauman17:08:33

@lvh: the only code that is loaded is code that is required in the tree of files from your core app file down

lvh17:08:04

Okay, cool. Should I file this as a figwheel bug somewhere for posterity?

lvh17:08:35

Success!

lvh17:08:45

@bhauman: thanks so much for walking me through the debugging process

bhauman17:08:35

I think this bug has been referenced already.

bhauman17:08:14

@lvh: your welcome simple_smile

lvh17:08:13

I suppose you could argue that maybe it just needs a warning or something, either from figwheel or in the manual. after all I’m abusing figwheel to be my piggieback into a browser environment, and figwheel just wants to compile my app

lvh17:08:25

Obviously “delight users” is a cool feature

lvh17:08:42

I can’t find the relevant issue. Doesn’t seem to be "cljs-time "

chinmay18517:08:08

Hi there! I am a clojure newbie. Learning about JS promises left me wondering.. Would it be possible to implement async and await style syntax using clojure macros?

lvh17:08:42

chinmay185: sure

lvh17:08:49

core.async already does something better

bhauman17:08:13

@lvh: please go ahead an file an issue. The problem isn't cljs-time its a library resolution problem I think. It would be cool if you could verify that this isn't a problem in the regular cljs.repl

chinmay18517:08:15

Ah. Thanks Ivh. I’ll read about core.async.

martinklepsch17:08:57

I wrote a blogpost about parameterizing ClojureScript builds using the tools coming with the Closure compiler: http://www.martinklepsch.org/posts/parameterizing-clojurescript-builds.html — feedback welcome!

pandeiro18:08:57

@martinklepsch: i just skimmed it now; it's interesting but including a sample use case would be nice

bhauman18:08:09

@martinklepsch: great post! super helpful

martinklepsch18:08:24

@pandeiro: there’s the example of customizing an API endpoint at build time

bhauman18:08:29

@martinklepsch: that looks like it belongs in the ClojureScript wiki

pandeiro18:08:58

@martinklepsch: ah ok, i see... yeah I think the background abstract info would be good in the wiki, maybe in the compiler options part

arohner18:08:49

I finally got server-side rendering partially working. I got the basic example working, now I’m slowly introducing CLJS code to find the pieces that break. Is there a nice way to debug nashorn? I can’t seem to get even println debugging working on (.eval nashorn “some code”)

bhauman18:08:02

@arohner: I used node and figwheel to debug server side rendering. Might be a better environment. After that move to nashorn. Most of the bigger problems should be solved.

bhauman18:08:03

or even node without figwheel is probably good

arohner18:08:21

I know nothing about node. Do you still think it’s worth it?

bhauman18:08:53

yep, a way better environment

bhauman18:08:32

@arohner: and server side rendering bugs are numerous and tricky

bhauman18:08:40

@arohner: some things surprisingly work great like dangerouslySetInnerHTML, other things that you would expect to work just don't

pixel19:08:42

@arohner feel free to ama about node, node-repl, node-inspector, nodemon. Note: node-repl command only works with iojs currently. Use nvm to manage node & iojs versions.

pixel19:08:38

Did nodejs at VSCO for a year, been though some fires

wamaral19:08:28

nice commit message

wamaral19:08:32

I think I like this relay thing

bensu19:08:53

@shaunlebron: @bhauman: I see the appeal to the --generate option. I don't know about it but I'll give it some thought.

bhauman19:08:03

@bensu: could be some fun meta programming.

bensu19:08:22

@bhauman: that's right, syntax quotes and file generation. sounds dangerous in all the right ways simple_smile

coyotespike20:08:00

@lvh I had that same problem today. I required cljs-time directly in core.cljs, and that still didn't work. I gave up and copied the files locally. Did you get it working?

lvh20:08:27

@coyotespike: Is core.cljs your main namespace?

lvh20:08:34

@coyotespike: how are you building cljs?

bhauman20:08:24

@bensu: it seems like you should be able to use the run command internally with generated code. not that much different than run-local-project

coyotespike20:08:50

With figwheel, or do you mean my config in project.clj?

lvh20:08:12

coyotespike: If you’re building with figwheel, I guess it’s using cljsbuild, so yes, your cljsbuild config in project.clj

coyotespike20:08:52

source-paths is src/cljs, optimizations are none

bhauman20:08:25

@coyotespike: (clean-builds) (build-once) reload app in browser should work if you are requireing it in core.cljs

coyotespike20:08:58

I did run lein clean

bhauman20:08:33

@coyotespike: the only thing that doesn't work for cljs-time that we found, was requiring dynamically. If you compile it as part of the source and load the app it should work.

bensu20:08:35

@martinklepsch: goog.define comes at the perfect time, I'm going to write some i18n macros next week and that sort of constant replacement is exactly what I need.

coyotespike20:08:01

It works locally, but any clarity on what's happening is always welcome simple_smile

coyotespike20:08:47

@bhauman: thanks, I'll give it another shot

martinklepsch20:08:35

@bensu: happy to hear. I was doing some i18n before and I was wondering if I should make separate builds or include all languages in the build. With only two I went with including all of them but with more this probably becomes less a choice.

orther20:08:45

ahh facebook posted Relay Technical Preview today

bensu20:08:31

@martinklepsch: yes, same question here. so far only supporting english, but in the future we'll need a way to "parameterize cljs builds" to include things like language. if only somebody thought of such things...

bensu20:08:09

haha. when I figure it out, I'll show the build process and the i18n macros

martinklepsch20:08:26

you don’t need macros! 😛

bensu20:08:01

I need them for something else, what if the the string needs to be interpolated? "Hello %s!" then I better leave an anonymous function that takes a name there.

arohner20:08:09

@bhauman: I have my server-side render running in node now, but now I get different errors 😞

arohner20:08:15

React is not defined

kbaribeau21:08:30

is there a blog post / demo / gist out there of what bootstrapped clojurescript looks like?

lvh21:08:44

I’m using [hickory](https://github.com/davidsantiago/hickory) to parse some DOM fragments into Clojure data structures. Is there something like Hickory that starts from the DOM? It seems like Hickory itself uses the DOM in CLJS, so is there a way for me to just give it a DOM element?

lvh21:08:31

I guess as-hiccup takes a parsed doc which is incidentally a dom thing

bhauman21:08:47

@arohner: did you figure it out? Node was a better env right?

arohner21:08:16

@bhauman: not yet. Appears to be something with React detecting whether or not it is a module

arohner21:08:24

node is at least providing stacktraces

bhauman21:08:53

@arohner: are you using the nashorn repl?

arohner21:08:59

*detecting whether or not the env has JS module support, and then defining itself as a repl

arohner21:08:10

as a JS module. gah can’t word today

arohner21:08:38

@bhauman: no, creating nashorn envs programmatically

arohner21:08:45

I did get nashorn print debugging working though

bhauman22:08:33

@arohner: are you requiring cljsjs.react in your ns? and have you seen https://github.com/DomKM/omelette/blob/master/src/omelette/render.clj

bhauman22:08:40

@arohner: looks tough though ...

arohner22:08:51

no, I’m not requiring cljsjs.react. Doesn’t requiring om.core take care of that?

arohner22:08:19

even if I was, that wouldn’t be a node require, right?

bhauman22:08:06

@arohner: it should and you are using something other than :none right. You are going to want a monolith

arohner22:08:33

yeah, using :simple for now

arohner22:08:39

plan on using :advanced once it works

bhauman22:08:06

And React is failing? Strange

arohner22:08:23

yeah, so this is while loading om.dom, on node, I get React.DOM is not defined

arohner22:08:47

react.js starts with: !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);

arohner22:08:56

so it’s clearly trying to detect whether node module support is present

arohner22:08:07

which leads me to believe I need to (node/require “react”) at some point

bhauman22:08:39

try the pattern in the post I just sent.

arohner22:08:06

so in nashorn, I get a lot farther

arohner22:08:26

I can render a simple (om.dom/h1 {} “Hello World”) component

bhauman22:08:35

I haven't had that problem in node at all

arohner22:08:54

but then something in my full app breaks with no stacktrace, so I was trying to use node to get real JS stacktraces

bhauman22:08:49

OK in node I use opt :none and figwheel, so my experience is probably much different

bhauman22:08:10

I thought you were talking about nashorn

bhauman22:08:40

Sorry if that led you down a rabbit hole

arohner22:08:57

no problem. This stuff is so messy I could use all the help simple_smile

dnolen22:08:46

@arohner: you might want to read cljs.repl.nashorn to understand the hacks that are need for React to work if you’re setting up a script context yourself

dnolen22:08:01

random JavaScript libraries sadly make many assumptions Google Closure does not

dnolen22:08:10

about where they are running

dnolen22:08:47

it is typical to check the presence of window, modules, global - all are problematic in in Rhino or Nashorn context

arohner22:08:51

@dnolen: where is that file?

arohner22:08:09

I see clojurescript/src/main/cljs/cljs/repl.cljs

dnolen22:08:19

src/main/clojure/cljs/repl/nashorn.clj

dnolen22:08:32

all Clojure files are under src/main/clojure

arohner22:08:34

now if only I could get a real stacktrace from nashorn...

arohner22:08:58

right now all I get is “eval line 21243"

dnolen22:08:41

@arohner: Nashorn supports .-stack property on Error

dnolen22:08:53

you will need to print that to see the whole trace

dnolen22:08:40

you can also catch the error in your Clojure code and print the trace

dnolen22:08:46

again nashorn.clj shows how

dnolen22:08:58

and you can pass the trace to cljs.stacktrace to map it back to original sources if you build up the source map with cljs.source-map

dnolen22:08:58

it may even be possible to avoid all of these steps by constructing cljs.repl.nashorn/repl-env and using it just for mapping

dnolen22:08:02

but I’ve never tried that