Fork me on GitHub
#clojurescript
<
2015-09-16
>
pandeiro00:09:39

Does anyone have an example with CLJS + React Native for Android yet?

mfikes01:09:44

@pandeiro: This exists—it appears to directly drive a little React from ClojureScript (no Om or Reagent, etc.). https://github.com/nicholaskariniemi/ReactNativeCljs

pandeiro01:09:36

@mfikes Cheers I'll take a look

jouerose05:09:58

hello all, may i please have your suggestions of methods/frameworks for mobile html5 cross platform development in clojure(script) ? very much appreciated. thank you

jouerose05:09:06

@jaen thank you. heading there to have a look

jaen05:09:59

@jouerorse: the example uses OnsenUI, but there's a lot of mobile HTML frameworks you may want to use in cojunction with Phonegap - Ionic, Sencha Touch, Touchstone, Reapp, material-ui; the last three mentioned are React-based so may be the most interesting to you. There's probably a lot more you can find through Google.

venantius06:09:19

It’s happening.

venantius06:09:29

I find myself unwittingly typing “s” at the end of my .clj file extensions

venantius06:09:44

Soon I will only think about the JavaScript runtime

jouerose12:09:06

anybody made ionic framework and clojurescript work together ?

dnolen12:09:14

@jouerose: I haven’t heard of anything, but might have missed it too

jouerose12:09:18

hi @dnolen , i researched programming languages over the past few months, and clojure(script) looks like a dream language. today i am wondering what are the ways to do cross platform mobile development with it, therefore my question in reality is beyond ionic. if you know anything, thanks for letting me know.

dnolen12:09:57

@jouerose: there’s a good chunk of the ClojureScript community that’s focusing their energies on React as React is immutable friendly

dnolen12:09:04

most JavaScript “frameworks” are not

jouerose12:09:46

@dnolen is there anything for React Native ? would you know whether React (non Native) is an option with clojurescript when targetting mobile ?

dnolen12:09:02

@jouerose: people are already using React Native, and also working actively to enhance it’s usage via ClojureScript

dnolen12:09:25

you can of course approach mobile via more “webby” tech and I know people are doing that too.

jouerose12:09:24

@dnolen thanks. would you any keyword/reference for the mix of clojurescript and react native ? any project or example ?

jouerose12:09:30

would you have*

dnolen12:09:58

@jouerose: there are some things but your patience level is going to have to be very high, literally every aspect of this of kind of development is cutting edge simple_smile

dnolen12:09:25

and you’ll have to have some working knowledge of Clojure, ClojureScript, Objective-C, iOS, React

dnolen12:09:38

a powerful tool, not exactly a great starting point

jouerose12:09:48

@dnolen: i am beginner level in clojure(script) but willing to still have a look at the keywords and references you can drop. if i must wait before using the perfect score, i will take something meanwhile while keeping an eye on the cutting edge

jouerose12:09:15

@dnolen: thank you, is there any other ?

dnolen12:09:51

I’m not aware of anything else or anything easier to get started with. There be dragons.

jouerose12:09:09

@dnolen: regarding natal, i have seen in clojure world that sometimes while version number is low, it can be considered production ready. is Natal one of those software ?

dnolen12:09:48

@jouerose: cutting edge and “production ready” are generally not said in the same breath simple_smile

jouerose12:09:35

@dnolen: thanks for your input

danielcompton14:09:03

This may be attempting rocket surgery on a moving rocket, but is there any way to open a REPL up in the ClojureScript compiler while it’s running from Figwheel?

danielcompton14:09:27

I’m trying to track down a very sporadic bug, and wanting to get more visibility into what’s going on in the compiler

dnolen14:09:00

@danielcompton: the easiest way to do this today is to use Cursive, won’t give you a REPL but that will give you a debugger with in-frame eval which is probably more useful anyhow for this simple_smile

dnolen14:09:14

I do this all the time, def not rocket surgery on a moving rocket

danielcompton14:09:43

I’ve got Cursive running, but I’m guessing I need to start with a debug config?

dnolen14:09:53

yep that’s all you need to do

dnolen14:09:10

search for files will show sources in jars

danielcompton14:09:19

Took a few days for this bug to show up again, so I don’t really want to kill the REPL 😞

dnolen14:09:46

you can set breakpoints in any ClojureScript compiler source file.

danielcompton14:09:47

Can I do this from figwheel, or do I need to launch the compiler directly?

dnolen14:09:25

you can attach to any JVM process, easier if Cursive launches it

danielcompton15:09:08

Got the debugger attached with breakpoints in ClojureScript, off to bed now!

danielcompton15:09:17

Thanks @dnolen, I appreciate the help

dnolen15:09:09

@danielcompton: np the more people know how to do this the better simple_smile

dnolen16:09:59

looks like somebody may have already written all the integration bits we would need, open question as to how reusable it is or simple to integrate

dnolen18:09:42

@shofetim: because http/get doesn’t throw

dnolen18:09:04

it probably just returns a channel

jaen18:09:26

@dnolen: interesting. Though if I understand that correctly it's React-specific, so it does not solve the general module problem, just eases integration with React in an already browserify-processed form.

dnolen18:09:42

@jaen yeah sorry wasn’t talking about the module issues, just using this for JSX processing instead

dnolen18:09:57

of babel / old jsx transform

dnolen18:09:24

@jaen ah darn ok I didn’t look too closely!

mfikes19:09:14

There's now 3 or 4 people messing with JavaScriptCore / React / Android. Wow!

Pablo Fernandez19:09:42

Is cljs.nodejs suppose to come with ClojureScript? I can’t locate it.

Pablo Fernandez19:09:18

Oh, nevermind… for some reason my non-nodejs build is picking up a directory I’m not specifying, which contains nodejs code.

lvh19:09:53

@mfikes: Nice! Does React Native on Android also run on JSC?

Pablo Fernandez20:09:55

Any ideas why I’m getting this error: lojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate cljs/nodejs__init.class or cljs/nodejs.clj on classpath., compiling:(projectx/node.clj:1:1)

dnolen20:09:48

@pupeno: you probably created a .clj file when you meant to create a .cljs one

Pablo Fernandez20:09:16

And now this: SEVERE: cljs.nodejs:1: ERROR - namespace "cljs.nodejs" cannot be provided twice

Pablo Fernandez20:09:20

I’m feeling stupid today.

dnolen20:09:33

the errors tell you what’s wrong

dnolen20:09:50

the previous error message was exactly right, this is almost always the case

dnolen20:09:58

loading .clj file that doesn’t exist

dnolen20:09:18

this one isn’t any different, cljs.nodejs is getting provided twice somehow

Pablo Fernandez20:09:48

Yes, I get that bit, but I can’t identify why?

dnolen20:09:07

start thinking through the obvious ways this could happen

dnolen20:09:24

are you using output directories as input directories to the compiler?

Pablo Fernandez20:09:03

No, I’m not doing that.

dnolen20:09:08

do you have your own ns called cljs.nodejs, stuff like that

dnolen20:09:19

whenever you think “No, I’m not doing that"

dnolen20:09:22

you should be thinking

dnolen20:09:29

but “I might be doing something like it though"

dnolen20:09:01

the bug doesn’t lie

dnolen20:09:10

somehow you are giving Closure the file twice

dnolen20:09:06

one helpful thing would be to turn on :verbose true and do a clean build

dnolen20:09:23

this will show you everything the compiler looks at and outputs

dnolen20:09:29

then do a second build etc.

Pablo Fernandez20:09:47

mhh… would src/cljs also include ser/cljs-node in cljsbuild?

Pablo Fernandez20:09:26

No, that’s not it 😕

dnolen20:09:34

@pupeno turn on :verbose true

dnolen20:09:43

search for the compilation of that file

Pablo Fernandez20:09:48

Yes, I’m watching it run right now.

dnolen20:09:01

check your output dir make sure node.js isn’t in there twice.

dnolen20:09:31

cljs/nodejs.js rather

Pablo Fernandez20:09:05

wow, compiling each of my targets individually work, but all together fails.

dnolen20:09:16

@pupeno: are you sharing output dirs?

dnolen20:09:44

also resources probably should NOT be on your classpath for compilation unless you want very confusing bugs

Pablo Fernandez20:09:17

yup, I am sharing output dirs… but that doesn’t make sense anyway.

dnolen20:09:27

it does make sense

dnolen20:09:49

compiling to the same output dirs is a surefire way to create problems if you’re not careful

Pablo Fernandez20:09:30

No, I mean, for my project, these two outputs shouldn’t be in the same directory, it makes sense to separate them.

Pablo Fernandez20:09:54

I still seem to get the same error… let me try to reproduce it cleanly.

bensu20:09:22

hi @pupeno do you have a folder named esources?

bensu20:09:58

also, can you post your project.clj?

Pablo Fernandez20:09:29

I do have a resources

Pablo Fernandez20:09:22

After properly cleaning the project, it seems to be working.

Pablo Fernandez21:09:30

ok… the error happens when I’m recompiling and I didn’t clean it first. :S

dnolen21:09:09

@pupeno: right I mentioned that above

dnolen21:09:21

it just sounds like you have resources on the classpath when you are compiling

dnolen21:09:26

and I also said not to do that simple_smile

Pablo Fernandez21:09:28

@dnolen: I didn’t do that explicitly and the nodejs code now outputs outside resources… it outputs to target… which is probably bad too 😕

dnolen21:09:02

right you are confused about what I’m saying

dnolen21:09:10

it’s fine to output to resources

dnolen21:09:25

but DO NOT put resources on the classpath when compiling

dnolen21:09:42

if you do this then the compiler will look there for ClojureScript and JavaScript files

dnolen21:09:14

this is how you are getting duplicates

dnolen21:09:19

and this is why the second build fails

Pablo Fernandez21:09:36

Yes, I understood that, but I don’t see how resources can end up in the classpath.

dnolen21:09:46

because lein probably does that for you.

Pablo Fernandez21:09:14

oh! so, the default lein behaviour is bad?

dnolen21:09:30

it makes sense for web servers

dnolen21:09:36

it doesn’t make sense for the build

bostonaholic21:09:40

lein gets that behavior (probably) from maven, which does the same

Pablo Fernandez21:09:01

How do I undo it then?

dnolen21:09:18

just specify explicit :resources-path

dnolen21:09:32

might be :resource-path I don’t remember

bostonaholic21:09:10

:resource-paths close @dnolen 😜

Pablo Fernandez21:09:44

but is it valid inside cljsbuild? and what does it normally contain so that I remove resources and leave the rest?

bostonaholic21:09:37

I believe it is :resource-paths ["resources"] by default

bostonaholic21:09:53

but you can always read the source to find out for yourself

Pablo Fernandez21:09:42

bostonaholic: that would require having different profiles for clojure and clojurescript, so instead of dev, now I would need to have dev-clj and dev-cljs.

Pablo Fernandez21:09:57

Anyway, having :resource-paths [] didn’t fix the problem.

dnolen21:09:52

@pupeno: I’m very skeptical about that claim. Paste what you tried. And no :resource-paths doesn’t go in :cljsbuild it’s a Lein thing.

dnolen21:09:19

@pupeno: I doubt supplying an empty :resource-paths will work, you need to supply something

dnolen21:09:20

but the important thing is this ...

dnolen21:09:40

resources/cljs/nodejs.js will match a namespace cljs.nodejs

dnolen21:09:07

so you can make resources work correctly if you actually adopt a traditional setup

dnolen21:09:28

where you set :output-dir to resources/public/js

dnolen21:09:38

then you can leave resources alone

dnolen21:09:00

because cljs.nodejs can no longer be matched to anything on the resources classpath

val_waeselynck21:09:16

Feedback appreciated simple_smile

Pablo Fernandez21:09:40

dnolen: my output dir is resources/public/js for one of my builds, target/js for the other (following your recommendation of not having them in the same directory). There’s no resources/cljs directory.

dnolen21:09:10

@pupeno: right so then target/js is also your problem (which I alluded to early)

Pablo Fernandez21:09:57

I set it to something different before and I think it was still happening, let me check.

dnolen21:09:36

you can keep checking. But the principle is this - if the ClojureScript compiler sees a namespace called cljs.nodejs it will attempt to find on the classpath in a non-deterministic way

dnolen21:09:03

every possible combination of some/classpath/cljs/nodejs.(js|cljs)

dnolen21:09:50

so the only way to avoid this is to make sure your classpath is clean for your builds

dnolen21:09:07

that is cljs.nodejs should only resolve to what’s in the ClojureScript JAR nothing else

Pablo Fernandez21:09:47

dnolen: I understand that, but I don’t see why a secondary cljs.nodejs is appearing.

Pablo Fernandez21:09:57

I set the output directory to foo2

Pablo Fernandez21:09:01

and it’s still happening.

dnolen21:09:08

@pupeno if you understand what I said, then it should be obvious how a second one can appear

dnolen21:09:26

if you don’t understand how it can appear twice, then you did not understand what I said above

Pablo Fernandez21:09:36

Ok, then I didn’t understand it.

Pablo Fernandez21:09:13

Clearly it’s picking up an extra file: https://gist.github.com/pupeno/70eff5d4629f79874233#file-when-it-doesn-t-work-L8 when it fails (13 sources instead of 12).

dnolen21:09:13

1) clean build

dnolen21:09:16

2) compile

dnolen21:09:39

3) cljs/nodejs.clj gets compiled to “something/on/your/classpath/cljs/nodejs.js"

dnolen21:09:43

4) rebuild

dnolen21:09:09

5) you now have two matching namespaces on your classpath

Pablo Fernandez21:09:11

Yes, but I don’t understand why 3 is happening.

dnolen21:09:49

3) is happening because something is setting :nodejs target or explicitly requiring that ns

Pablo Fernandez21:09:44

dnolen: yes, I am setting :nodejs because I want to run my app in :nodejs and I’m requiring cljs.nodejs so that I can call (cljs.nodejs/enable-util-print!)

dnolen21:09:55

@pupeno then you have all the information you need

dnolen21:09:05

I explained exactly how you ended up where you ended up

dnolen21:09:30

the solution is tweak your classpath so the same resource can’t be resolved twice when you compile

Pablo Fernandez21:09:22

How do I remove foo2//server-side/cljs/ from the classpath then?

Pablo Fernandez21:09:00

(and why is cljsbuild putting node.js there when it breaks things?)

Pablo Fernandez21:09:16

And why isn’t foo2//server-side/cljs/core.js a problem but foo2//server-side/cljs/nodejs.js is? or is nodejs.js just failing first?

dnolen21:09:25

@pupeno: now you’re getting to part where I don’t have any answers

dnolen21:09:30

your project.clj is pretty complicated

dnolen22:09:04

if I were you I would whittle this down to a minimal case to determine if it’s a bug in cljsbuild or something we’ve missed

Pablo Fernandez22:09:16

Ok, it wasn’t that obvious and simple after all.

Pablo Fernandez22:09:04

I’ll try to make a minimum case, although this is already quite a minimum case from what I’m trying to do.

dnolen22:09:32

@pupeno the issue is the same one I said it was like an hour ago simple_smile

Pablo Fernandez22:09:31

Yes, there are two nodejs.js, that’s simple, it’s in the error message, but why they are or how to avoid it is not simple. All cljs gets compiled to js files there, so it doesn’t feel like it’s wrong.

dnolen22:09:04

it’s completely simple

dnolen22:09:18

but your tooling decisions are polluting the classpath and you’re OK with this.

dnolen22:09:43

lein classpath read the output, see which ones are going to intersect

Pablo Fernandez22:09:48

What decision is polluting the classpath?

dnolen22:09:06

Lein and cljsbuild “easy” decisions

Pablo Fernandez22:09:35

what do you mean?

dnolen22:09:10

I don’t use any of these tools because I want to know that the classpath isn’t going to include some random stuff for whatever operation I intend to do

Pablo Fernandez22:09:51

Using lein and cljsbuild is my mistake?

dnolen22:09:25

@pupeno: no, but you should understand the opaqueness of what’s going to be on the classpath is a direct result of what you decided to use

dnolen22:09:46

so if you want to use these things you will have to sort out how they work wrt. the classpath

Pablo Fernandez22:09:23

https://gist.github.com/pupeno/70eff5d4629f79874233 there’s the classpath, it doesn’t include foo2//server-side/cljs/nodejs.js

Pablo Fernandez22:09:27

So that’s not the problem.

dnolen22:09:45

I never said that was the problem

dnolen22:09:02

just that cljs/nodejs.js is in the build twice

Pablo Fernandez22:09:33

I don’t see how that CLASSPATH would include cljs/nodejs.js twice.

dnolen22:09:07

have you tried to do recursive directory search to see how many times cljs/nodejs.js occurs in your project?

Pablo Fernandez22:09:45

$ find . -name nodejs.js ./foo2/server-side/cljs/nodejs.js ./foo2/server-side/goog/bootstrap/nodejs.js

dnolen22:09:41

@pupeno: huh and that isn’t on your :dev profile classpath?

dnolen22:09:44

@pupeno: don’t you need to run a different command to compute the classpath for a profile?

dnolen22:09:50

lein classpath isn’t enough I don’t think

Pablo Fernandez22:09:06

I thought the :dev profile was the default.

dnolen22:09:22

I don’t know, I don’t use lein so you’ll have to tell me simple_smile

dnolen22:09:23

ok yeah :dev is in the :default composite

Pablo Fernandez22:09:11

If nodejs.js is a problem there, then core.js should be a problem here ./resources/public/js/app/cljs/core.js and the app should fail with the same error.

dnolen22:09:40

@pupeno: I would examine the final output file, I should have suggested that earlier

dnolen22:09:57

look for goog.provide(“cljs.nodejs”)

Pablo Fernandez22:09:22

$ grep -R "goog.provide('cljs.nodejs')" target/ target//js/server-side/cljs/nodejs.js:goog.provide('cljs.nodejs'); target//js/server-side/D2E353E.js:goog.provide('cljs.nodejs');

Pablo Fernandez22:09:52

WTF is D2E353E.js?

dnolen22:09:50

right so this right back to the problem of sharing output directories and putting them on the classpath

dnolen22:09:02

I’m assuming target/js/server is on the classpath

dnolen22:09:56

sorry I mean, it’s on the classpath or ClojureScript sources path

dnolen22:09:03

one or the other

Pablo Fernandez22:09:10

It’s not in either of them.

dnolen22:09:33

the ClojureScript doesn’t randomly include things

dnolen22:09:37

everything must be explicitly specified

Pablo Fernandez22:09:42

:source-paths ["src/cljs" "src/cljc" "src/node"]

dnolen22:09:53

@pupeno no I know I’ve seen your file

dnolen22:09:02

I’m just saying that whatever you specified doesn’t matter

Pablo Fernandez22:09:13

I’m not saying it does, but I’m not explicitly doing that.

dnolen22:09:25

somehow target/js/server-side is part of your build or your classpath

dnolen22:09:59

anyways the randomly named file is just a thing we generate under :none

dnolen22:09:40

so yeah I have no ideas about that directory is getting considered in your build

dnolen22:09:12

@pupeno what happens if you remove the :scope “provided” bit from your ClojureScript dep?

Pablo Fernandez22:09:39

I don’t have :scope “provided"

dnolen22:09:13

but I just tried that here

dnolen22:09:16

doesn’t seem to matter

Pablo Fernandez22:09:19

Ah, that provided, nevermind, let me try.

dnolen22:09:00

@pupeno: what I’m confused by is why target exists?

dnolen22:09:11

it’s not a part of your project.clj

Pablo Fernandez22:09:14

If I stop requiring it, the problem stops, but then I can’t call enable-util-print!

dnolen22:09:23

if it isn’t why don’t you delete it

Pablo Fernandez22:09:42

dnolen: foo2 was my renamed target to try to avoid collisions.

dnolen22:09:00

target how is that part of the prefix of the output dir?

Pablo Fernandez22:09:34

let me update things so everything is consistent.

Pablo Fernandez22:09:26

target/js is specified as the output dir in project.clj

dnolen22:09:49

@pupeno: why doesn’t :app build specify :output-dir?

dnolen22:09:56

@pupeno: one second ...

dnolen22:09:55

@pupeno: OK I spelunked a bit with Om which uses Lein

dnolen22:09:06

I used lein-cljsbuild 1.0.6 same as you

dnolen22:09:24

the random files are only generated under :none

dnolen22:09:33

never under :simple

dnolen22:09:54

in your case it appears that when you run all builds somehow the :none compilation artifacts end up in :simple output-dir

dnolen22:09:01

that’s about as far as I’m willing to dig into this, gotta switch gears - this appears to me at the moment that this is firmly in cljsbuild territory

dnolen22:09:11

@pupeno and you’re right about your project.clj, it looks fine and doesn’t appear to have any of the issues I mentioned, it’s just that almost every user that reported that bug has always had classpath issues

dnolen22:09:37

I suspect that this may be one of those cases people always get tripped up on and just learn to clean and never report the cause 😞

dnolen22:09:40

@pupeno: also tried running lein cljsbuild once with two build specs

dnolen22:09:57

I still don’t see the wrong files in the wrong place. So maybe this is a profile merging thing? dunno

jaen22:09:10

Huh, interesting how finicky building cljs with lein can be

Pablo Fernandez22:09:44

I switched from :simple to :advance optimizations and now it’s finding even more sources to mess up together (still the same error though).

dnolen22:09:17

@pupeno: remove all the profile stuff and try that

dnolen22:09:53

@pupeno: also would look at using a more recent version of cljsbuild

Pablo Fernandez22:09:17

lein ancient claims I’m having the latest one.

dnolen22:09:50

your project.clj says 1.0.6

dnolen22:09:52

github says 1.1.0

Pablo Fernandez23:09:02

upgrading, same, disabling profiles, same 😞

Pablo Fernandez23:09:22

Removing :target :node or removing :require [cljs.node] fixes it.

dnolen23:09:07

I wonder if it’s because output-dir has target as parent

Pablo Fernandez23:09:57

I tried setting it to foo2 and the behaviour was identical. Before it was set to resources (when the problem started).

dnolen23:09:23

yeah I can’t repro here

dnolen23:09:28

out of ideas

dnolen23:09:49

well other than slowly whittling down the project

dnolen23:09:01

(and ruling out weirder stuff like global lein profiles)

danielcompton23:09:51

@dnolen: ruling out ~/.lein/profiles.clj is usually one of the first steps I take

Pablo Fernandez23:09:49

@danielcompton: I deleted it, no effect.

Pablo Fernandez23:09:54

Oh, nodejs works with :optimizations :none? I thought it required at least simple. Anyway, it works with :optimizations :none, so the problem is with optimizations.

Pablo Fernandez23:09:59

Anyway, thank you everybody and specially @dnolen for the help, I’m off to sleep.

dnolen23:09:39

@pupeno yeah Node.js has worked with :none for a while now

dnolen23:09:04

@pupeno: let me know if you get to the bottom of it, would like to know!