Fork me on GitHub
#clojurescript
<
2017-03-22
>
mars0i00:03:00

Parens are bad if you format code like Java. Learning to read lisp indentation is what makes the parens comfortable.

rayk04:03:53

Hia, can anyone point me to a good starting point (maybe a recent min lein template) for building nodejs apps with clojurescript.

Jon04:03:46

I guess starting with lumo can be a lot easier...

rayk04:03:45

LUMO as in the REPL..

noisesmith04:03:37

lumo is a self hosting clojurescript

noisesmith04:03:46

you can give it a cljs file, and it runs it in node

rayk04:03:25

Still a bit heavy, my end deployment environment will probably be something like, aws lambda and/or google cloud functions.

Jon04:03:10

Maybe you can try develop code with lumo -c src/ -i src/foo/main.cljs and build file to deploy it.

rayk04:03:39

Just look at it now I will certain try it out.

noisesmith04:03:54

so you want a minified js build targetting node - there's an example of that in the cljs quickstart https://github.com/clojure/clojurescript/wiki/Quick-Start#running-clojurescript-on-nodejs

noisesmith04:03:11

I don't think you need lein at all for this - unless you prefer to manage js with lein over node?

Jon04:03:40

I'm a Boot user. build.boot is neater than project.clj šŸ˜›

rayk04:03:06

was looking at using at using lein-npm for deps... Agree boot rules... maybe time leave lein world... The weight of legacy...

noisesmith04:03:28

for npm deps, why not use npm?

noisesmith04:03:34

all cljs needs is cljs.jar

noisesmith04:03:11

unless someone else's clojure based dep management is significantly better of course, but that seems like it brings in a lot of java stuff you don't need at first glance (I say that as someone who codes in mostly clojure on java)

rayk04:03:26

yep that would work.. just would like to keep tooling down.. npn for node stuff, then lein/boot for clj/cljs stuff... Just was after a unified way.

rayk04:03:46

was actually hoping someone had walk this path before.

noisesmith04:03:49

rayk what I'm saying is cljs.jar is all you need from clj - that's literally end of story

noisesmith04:03:58

you don't need other clojure stuff if you really want to stay minimal

rayk04:03:33

OK get where you are coming from..

noisesmith04:03:34

lein or boot are good if the added bulk adds features you need or avoids problems, of course, but I'm not sure either are really the case here

noisesmith04:03:07

rayk node can manage all the deps you need. java -jar clojurescript.jar build-file.clj will build your js

richiardiandrea04:03:13

With Lumo you'd only need lein or boot for the java classpath resolution, I have been using it in conjunction with inf-clojure successfully for last couple of months now

noisesmith04:03:16

quickstart shows how to do it

noisesmith04:03:53

richiardiandrea but lumo is reportedly too large for their target env

rayk04:03:04

OK @noisesmith will give it a crack this afternoon.

richiardiandrea04:03:24

My task is to write and deploy lambda functions that speak to DynamoDB

richiardiandrea04:03:33

Oh missed that part sorry

noisesmith04:03:56

well, if lumo works on lambda for you, maybe there's more to the story here!

noisesmith04:03:16

richiardiandrea so lumo can generate an individual function you send to lambda, is that how it works?

Jon04:03:33

also compiling ClojureScript files with lumo, if the bugs in Lumo in 1.2 is fixed...

richiardiandrea04:03:03

I am not compiling with Lumo at the moment yes

noisesmith04:03:37

to me it still seems like clojurescript.jar and java are the easier building method - though lumo is great for dev time

rayk04:03:11

@richiardiandrea what are you using to compile to js, produce and manage and package.json etc.

richiardiandrea04:03:42

I am using boot-cljs...Probably in order to be minimal the build.cljs approach is best

richiardiandrea04:03:03

For deps I am shelling out to yarn

noisesmith04:03:33

see, if boot isn't needed for your program's deps, I still don't get why you'd use boot and not clojurescript.jar directly?

rayk04:03:55

imho boot/lein is certainly help with the incident stuff. Running test/spec, alternative builds etc. That is about it. Really workflow support that is about it.

noisesmith04:03:01

alternative builds are literally just different hash-maps in a clj file with clojurescript.jar - I honestly don't know the testing story though

noisesmith04:03:15

but whatever works, of course

Jon04:03:10

lumo can run tests too thanks to mike. Not sure about spec though.

rayk04:03:25

thanks @noisesmith I will that the guide for a spin using the jar.

noisesmith04:03:31

I do my clojurescript testing with cljs.test, I don't use any plugins for it, but my project uses leiningen because that's the sanest way to manage my monstrosity of a java dependency tree. But I fantasize about not needing the heavy tooling.

richiardiandrea04:03:14

It is true that you could get rid of boot (or use boot with-cp only for the classpath). Agree with the above ^

richiardiandrea04:03:47

There are two interesting projects in this area, one is calvin the other cljs-boot

richiardiandrea04:03:59

I have been trying to push for a port of the task DSL or similar šŸ˜€ I would love to have a way to compose tasks and fileset on node.js at this point

richiardiandrea04:03:27

Haven't had the time to hack it myself though

thosmos05:03:06

I just upgraded a project from 1.7.228 to 1.9.495 and now source-map links in the chrome console are stacking two levels of :asset-path like: /admin/adm.out/admin/adm.out/admin/core.cljs where /admin/adm.out is the asset path. Is this a known issue?

Jon06:03:36

boot-cljs ?

john0506:03:37

hello everyone, what will be the best to get started Clojurescript ?

Jon06:03:21

what do you want to do with ClojureScript then?

john0506:03:13

I want learn mobile application development with ClojureScript + React Native

Jon06:03:11

maybe #re-natal ?

Jon06:03:23

I'm not with cljs on React Native... not familiar

john0506:03:24

Going to use re-natal instead of Boot React Native

john0506:03:23

re-natal is building tool to create mobile application with react native or it is ?

john0506:03:32

Can you please explain to me ?

Jon06:03:13

I didn't even try it

Jon06:03:00

since you mentioned Boot React Native, do you already learn ClojureScript? I thought you were asking about how to start picking up cljs..

john0507:03:31

I want move mobile application development to clojurescript using react native.

john0507:03:50

I am just googling to get started

Jon07:03:48

so you currently using JavaScript and React Native?

john0507:03:43

I am totally new to React Native. I come native development background. I am android developer

Jon07:03:26

Java O_O

Jon07:03:48

I'm from JavaScript side and learning cljs can be started with build small web apps, like todolist or something.

Jon07:03:59

I mean in browsers.

Jon07:03:28

For React Native maybe you can also trying playing with browsers first, I guess.

Jon07:03:43

...in browsers.

john0507:03:49

is it mandatory to learn react native ?

Jon07:03:17

not quite understand you question, I think it maybe help, because in React Native, the ClojureScript part and the React part is nearly the same with that in browsers.

Jon07:03:45

while the environments and lower level APIs can be much different

Jon07:03:45

If you haven't learning ClojureScript yet, I would suggest starting from Web pages with Reagent or Om, then React Native.

Jon07:03:04

šŸ™‚

curlyfry12:03:38

@john05 I think #cljsrn is the best place to ask if you want to know more about clojurescript in react native

sivakumargsk14:03:27

Problem with parse function in cljs-time, this works fine with simple format in cljs-time issue https://github.com/andrewmcveigh/cljs-time/issues/64

cljs.user=> (require '[cljs-time.format :as fmt])
nil
cljs.user=> (def yyyy-MM-dd (fmt/formatter "yyyy-MM-dd"))
#'cljs.user/yyyy-MM-dd
cljs.user=> (fmt/parse yyyy-MM-dd "2013-04-01")
#object[Object 20130401T000000]
But for this format "dd-MMM-yyyy kk:mm aa" I got an error.
cljs.user=> (def my-formatter (fmt/formatter "dd-MMM-yyyy kk:mm aa"))
#'cljs.user/my-formatter
cljs.user=> (fmt/parse my-formatter "05-Dec-1992 12:00 PM")
#error {:message "The parser could not match the input string.", :data {:type :parser-no-match}}
new (jar:file:/home/sivakumar/.m2/repository/org/clojure/clojurescript/1.9.494/clojurescript-1.9.494.jar!/cljs/core.cljs:34703:10)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (jar:file:/home/sivakumar/.m2/repository/org/clojure/clojurescript/1.9.494/clojurescript-1.9.494.jar!/cljs/core.cljs:34779:9)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2 (jar:file:/home/sivakumar/.m2/repository/org/clojure/clojurescript/1.9.494/clojurescript-1.9.494.jar!/cljs/core.cljs:10244:17)
cljs.core/ex-info (jar:file:/home/sivakumar/.m2/repository/org/clojure/clojurescript/1.9.494/clojurescript-1.9.494.jar!/cljs/core.cljs:10237:34)
cljs-time.format/parse* (jar:file:/home/sivakumar/.m2/repository/com/andrewmcveigh/cljs-time/0.4.0/cljs-time-0.4.0.jar!/cljs_time/format.cljs:421:11)
Function.cljs_time.format.parse.cljs$core$IFn$_invoke$arity$2 (jar:file:/home/sivakumar/.m2/repository/com/andrewmcveigh/cljs-time/0.4.0/cljs-time-0.4.0.jar!/cljs_time/format.cljs:428:7)
cljs_time$format$parse (jar:file:/home/sivakumar/.m2/repository/com/andrewmcveigh/cljs-time/0.4.0/cljs-time-0.4.0.jar!/cljs_time/format.cljs:424:1)

Janet A. Carr14:03:34

Can someone tell me about a work around for the with-redefs and cljs.test async bug? other than the patch listed here http://dev.clojure.org/jira/browse/CLJS-884

dnolen14:03:11

@janetacarr the problem is not specific to with-redefs, bindings canā€™t persist across async calls

dnolen14:03:07

you can probably make it work with cljs.test fixtures

Janet A. Carr14:03:38

I tried both a synchronous fixture and async fixture. It didn't seem to work šŸ˜ž Does that mean that with-redefs doesn't function like the with-redefs clojure documentation?

dnolen14:03:28

@janetacarr with-redefs wonā€™t work with go macros, you donā€™t know which threads will handle the body of the go block

dnolen14:03:34

and bindings are thread-local

dnolen14:03:43

so the same problem exists in Clojure too

dnolen14:03:13

but rewinding, your problem should be solveable, but not with with-redefs

dnolen14:03:30

first you need to enforce serial test execution by using cljs.test/async

dnolen14:03:48

no other test can run until a async test finishes

Janet A. Carr14:03:57

so the answer is yes, "These temporary changes will be visible in all threads."(https://clojuredocs.org/clojure.core/with-redefs) <- is not true.

tbaldridge14:03:07

and it's not really a bug, it's mostly a misunderstanding of what with-redefs does: http://blog.cognitect.com/blog/2016/9/15/works-on-my-machine-understanding-var-bindings-and-roots

Janet A. Carr14:03:19

I am using the async macro

dnolen14:03:46

so if you want to scope some redefs to that test just do it with a per test fixure

dnolen14:03:56

donā€™t try to do it with with-redefs

Janet A. Carr14:03:46

@dnolen would I do that with binding

dnolen14:03:35

no you just need to write your own thing here - itā€™s probably less scary then it sounds

Janet A. Carr14:03:47

that's a little vague.

dnolen14:03:49

itā€™s a bit easier if you donā€™t care about running tests advanced compilation

dnolen14:03:00

@janetacarr yes Iā€™m going to explain

Janet A. Carr14:03:49

Really what's happening is I'm trying to redefs a fn that makes http requests asynchronously.

dnolen14:03:44

(deftest foo (async (let [old http-fn] (set! http-fn new-fn) ā€¦ (set! http-fn old) (done))))

dnolen14:03:52

so just do it explicitly instead of trying to use with-redefs (which canā€™t handle async code in itā€™s body)

dnolen14:03:55

if this is super repetitive and needed for many tests then thatā€™s why I suggested trying to do this in fixture

dnolen14:03:03

set the fns you want before, and restore after

dnolen14:03:26

so set! yourself, and skip with-redefs and bindings

Janet A. Carr14:03:04

sure, but I thought set! only works on mutable things like vars, refs, java fields, and agents

dnolen14:03:56

yes but if http-fn is a fn from some ns then itā€™s basically a var in this case

Janet A. Carr14:03:11

I'll give that a shot then. thanks.

dnolen14:03:30

ClojureScript is a bit more lax here because no threading - and itā€™s doesnā€™t have real vars

dnolen14:03:50

youā€™re definitely in a spot where the differences between Clojure/ClojureScript are subtle and not really resolveable in a generic way

tbaldridge14:03:31

Although we should mention that with-redefs is painful in both CLJS and CLJ, it can sometimes be cleaner to refactor the tests so that redefing vars isn't needed. For example you can test that you're constructing the correct http request given certain inputs.

Janet A. Carr14:03:24

I guess I should have been more specific, I'm writing unit tests for functions that call a form to make the http request

dnolen14:03:43

right, you want to intercept those calls

shdzzl15:03:12

Is there a codepen or jsfiddle for clojurescript?

shdzzl15:03:46

Thanks. Is that the only one that you know of?

vikeri15:03:20

Is there a list of ES6 features not yet supported by the Closure compiler? I tried importing a library with :foreign-libs and :es6 but it threw some errors, among them were:

ERROR: JSC_CANNOT_CONVERT_YET. ES6 transpilation of 'Wildcard export' is not yet implemented.

mikepjb17:03:02

Does anyone have experience with mocking in clojurescript tests? Trying to add a testsuite, I want to redefine js/document to be a noop as we are running tests using nashorn and it isnā€™t callable there

mikepjb17:03:35

some quick googling and trying to use with-redefs like so havenā€™t worked:

(deftest incoming-location
  (testing "what this method is actually doing"
    (with-redefs [js/document "nada"]
      (= (core/incoming-location [{:Location
                                   {:Scope "some-scope"}}
                                  {:Location
                                   {:Scope "another-scope"}}]) "result!"))))

martinklepsch17:03:20

@mikepjb with-redefs is intended for vars which js/document isnā€™t. Interestingly with-redefs uses set! which I was going to suggest to try so not sure how that would play out

mikepjb17:03:19

something like (set! (.-document js) ā€œnadaā€)?

mikepjb17:03:45

I am not familiar with set! but will have a play around, thanks!

robert-stuttaford18:03:10

@dnolen @anmonteiro now that the closurelib async bug is fixed, is there any timeline for updating cljs to use the new build? weā€™re itching to use the new tree-shaking for external libs, but weā€™re using core.async šŸ™‚

dnolen18:03:37

@robert-stuttaford did Closure cut a release though?

anmonteiro18:03:45

@robert-stuttaford weā€™ll update Closure when the March release is out

robert-stuttaford18:03:54

iā€™m checking that now

anmonteiro18:03:56

shouldnā€™t be too far off

robert-stuttaford18:03:09

ohh i see thereā€™s a big lag between fixes and releases, ok, my bad

robert-stuttaford18:03:14

thank you šŸ˜Š

anmonteiro18:03:18

they do a monthly release

anmonteiro18:03:30

last 2 were Jan 24, Feb 18

robert-stuttaford18:03:47

so a week out at most, rad

anmonteiro18:03:18

@robert-stuttaford note that while itā€™s a cool feature, itā€™s also in alpha, so expect some packages to not be supported at first

anmonteiro18:03:42

even in the Closure side of things, we keep finding stuff that breaks sometimes

robert-stuttaford18:03:50

totally get that. we use rum on top of react, so iā€™m anticipating some gains from the react constellation

anmonteiro18:03:21

plus some more that havenā€™t been tracked down, but weā€™ve been following in #cljs-dev

robert-stuttaford18:03:53

great. iā€™m pretty sure our use is quite vanilla, but iā€™d be happy to file bugs if we find them

anmonteiro18:03:58

right, starting slowly with React may be a good start

anmonteiro18:03:17

but note that Rum will probably need to be updated for that use case too

anmonteiro18:03:42

i.e. if it calls js/React, needs to update to consume React from NPM etc

robert-stuttaford18:03:15

itā€™s using cljsjs.react right now, but i do see js/React.PropTypes.string in the source

robert-stuttaford18:03:15

once cljs support with async is in, iā€™ll chat with Nikita about it

anmonteiro18:03:16

itā€™s what Iā€™m saying

anmonteiro18:03:30

if itā€™s using cljsjs/react, itā€™s using js/React

robert-stuttaford18:03:57

we use rum/react on mobile, so weā€™ve a good reason to see this working

anmonteiro18:03:15

Iā€™m excited to see people using it

robert-stuttaford18:03:50

itā€™s hella cool. all on the back of Mariaā€™s work right?

anmonteiro18:03:27

started with that, yes

anmonteiro18:03:42

@juhoteperi improved on it a lot too

tech_hutch19:03:32

I'm trying to use core.async, and the compiler is throwing an error: No such namespace: clojure.core.async

tech_hutch19:03:41

In my namespace declaration, I'm requiring [clojure.core.async :as async]. Am I requiring it wrong?

jr19:03:24

cljs.core.async

tech_hutch19:03:28

(I also tried using cljs.core.async instead, but that threw the same error.)

tech_hutch19:03:44

@jr Caused by: clojure.lang.ExceptionInfo: No such namespace: cljs.core.async, could not locate cljs/core/async.cljs, cljs/core/async.cljc, or Closure namespace "cljs.core.async"

jr19:03:31

and you have the core.async dependency listed in your project?

tech_hutch19:03:01

No. Is it not in cljs.jar?

jr19:03:07

it is not part of core

tech_hutch19:03:43

I need to set up my project as well. I don't have a dependency file at all yet.

tech_hutch19:03:56

That would be with Lein, right?

jr19:03:01

yeah. There are other build tools available but lein works well enough