Fork me on GitHub
#clojurescript
<
2015-09-10
>
potetm00:09:54

Awesome. Thanks @maria and @nullptr!

mfikes02:09:13

@potetm: Yeah, if you need something now, Zachary Kim's Vee is interesting. But React Native Android is RSN http://www.reactnativeandroid.com which leads to the all-important (= view (f data))

juliobarros05:09:32

Anybody playing with using CLJS to build an Apple TV app?

wqhhust05:09:42

cljs-ajax is async aljs-http + core.async is also async. So should I use cljs-ajax or aljs-http + core.async

borkdude07:09:42

@wqhhust: if you want to avoid callback hell, go for cljs-http

jaen07:09:46

@dnolen @maria: continuing with trying to get modular React libraries run as-is where I left off yesterday I've came across two more problems: 1) absolute requires don't seem to work. That is even if I have React in foreign libs and another foreign lib does require('react'); I get an error like this

ERROR: JSC_ES6_MODULE_LOAD_ERROR. Failed to load module "react" at node_modules/react-motion/lib/Spring.js line 5 : 13
that indicates the library can't find react even though it's specified in foreign-libs. When using relative require (that is require('./react');) everything works, provided react sits next to that file of course. Here's some sample code to demonstrate the problem - https://github.com/jaen/require-paths (there's branch broken when for non-working code and working for working code). Of course if the goal is using the libraries as-is then we need to finda a better solution than manually changing all absolute requires to relative ones and possibly shuffling the files around (and you would either have to force each programmer to do this by hand on each lib update or keep the libs in source control), 2) I've also noticed that output for foreign libs is flat - that is all foreign libs seems to be dumped to the root output folder. This seems problematic, since having a library with just an index.js file is a pattern that seem to recur in node packages (in sgrove's sample it's 5 libs that do that) and that will result in libs clobbering each other. I imagine this could be solved by letting the user specify the output name/folder of the foreign lib. I can provide a repo with reproduction for that later if needed (figured it's better to deal with the former issue first). Of course I don't know what the best solution for those issues would be, so I'm leaving this here for discussion.

jrychter10:09:51

So I wanted to generate some CSV data in ClojureScript and present it to the user as a downloadable file. Turns out the only reliable way to do this is: generate data — ship to the server — have the server expose it at a temporary URL — return the URL — redirect the browser to the URL. I feel like I'm reinventing FTP.

jrychter10:09:56

@crisptrutski: I want all browsers to reliably download the file, not display it in a browser window, which often happens for CSV data.

jrychter10:09:33

@crisptrutski: No Flash, I'm trying to look forward. I also looked at FileSaver.js, but it requires additional shims for IE, and even then the W3C deprecated the File Writer API http://www.w3.org/TR/file-writer-api/

crisptrutski10:09:14

disappointing, yeah i see that download attribute below 50% support in browsers still 😞

jrychter10:09:42

From what I found, there is simply no good way to present a download from JavaScript. The "bounce through the server" solution works very well, but it really is FTP reinvented, from the early, non-PASV days (with a command channel and a separate data channel).

jrychter10:09:07

It's also a good example of how seemingly simple tasks ("let the user download tables as CSV") can explode into complex solutions.

crisptrutski10:09:00

it is truly ridiculous

crisptrutski10:09:34

imagine faking your ftp service at least with service worker if that lands first 😛

dnolen11:09:31

@jrychter: I would probably just go with a Flash solution if reach was the primary concern.

dnolen11:09:19

@jaen yeah the whole thing needs more consideration. Probably part of the issue is overloading :foreign-libs when we should be focusing on :libs. The whole point of module conversion is to allow these JS libs to be part of the build.

dnolen11:09:18

yeah upstream :libs is supported in deps.cljs ...

jaen12:09:59

@dnolen: the exact distinction being? If I understand docs correctly :foreign-libs seem to deal in single files (possibly non-Closure compatible) that are used as-is, while :libs can take both single files and library roots (provided they are Closure libs) that are then processed with GClosure like the rest of the codebase, or is this understanding wrong? I'm just trying to understand how using :libs instead of :foreign-libs will help - will that for example mean I would specify something like, say, :libs [{:root "some/library" :module-type :commonjs :language-in :ecmascript6}] and all requires will resolve properly, modules get translated to Closure modules and they take part in the build? Or is that a misreading of what you mean?

dnolen12:09:17

I would read this first and give feedback on this 😉

jaen12:09:30

Ok, thanks, looking at this now

grav12:09:02

@dnolen: The author of Cursive mentioned that you may have gotten the js debugger of the commercial version of IDEA to work with ClojureScript. Is that true? Sounds awesome simple_smile

dnolen12:09:25

@grav it's a little hacky but works thanks to source maps. The Node.js REPL supports :debug-port option. I haven't bothered with investigating browser integration since the browser already works pretty well.

grav12:09:05

@dnolen: cool! any plans on writing a guide?

cfleming12:09:31

@grav: That should really be my job, but I’m pretty busy right now

cfleming12:09:43

I’ll see if I can get to it this week

grav12:09:39

@cfleming: cool. I’ve tried setting it up by making sense of the Jetbrains' help pages in this regard, but they point to IDEA’s own source map generation, which doesn’t make sense

martinklepsch12:09:39

@dnolen: in the node shim path.resolve(".”) is used but this is set to where node was executed and not the path of the current file. Wouldn’t __dirname be more appropriate here?

dnolen12:09:06

@martinklepsch: more importantly what problem are you trying to solve.

jaen12:09:37

@dnolen: read the wiki page, sounds like a good plan (incidentally it seems I almost hit the right proposed syntax for :libs in the comment right above yours, funny). The :libs part especially mirrors how I expect this to work - say I have package.json with npm dependencies and then some Clojure code in boot that enumerates that and puts appropriate module roots in :libs and then Clojurescript takes it from there. One thing I noticed playing with sgrove's ReactMotion sample though that might be worth taking into consideration, is that some libs do have their own node_module directories (as in they have a separate set of dependencies from the rest of libs, presumably to avoid conflicts). With :libs as described in proposal I don't see any way to reflect that. Or do you think that's not an issue?

dnolen12:09:43

@jaen making NPM work is a non-goal

dnolen12:09:09

there’s really very little pressure to use ClojureScript + Node.js for server side stuff

dnolen12:09:22

and NPM doesn’t really work for browser stuff, and our stuff does

dnolen13:09:11

so the end result would be to make it easy to package up any old random Node.js thing into a JAR and deploy that.

dnolen13:09:42

but really the most popular libs - jQuery, Underscore, lo-dash … no one’s going to bother with these.

dnolen13:09:53

and anything that really targets client is generally self sufficient (few deps)

martinklepsch13:09:39

@dnolen: when you invoke the shim from the commandline it fails loading any module unless you are in the directory the shim is in.

martinklepsch13:09:31

@dnolen: can easily be solved by :asset-path but I’m just wondering if that’s intended

dnolen13:09:09

@martinklepsch: ok, I haven’t really put much thought into it since I don’t really use Node.js for anything other than library dev myself. Issue/patch welcome that clearly states the use case and a reasonable amount of testing that verifies it won’t break anything people are currently doing.

jaen13:09:00

@dnolen: I'm not saying it is a goal for Clojurescript compiler to handle NPM directly, but a lot of frontend Javascript uses NPM to distribute their packages. And I'm just wondering how a hypothetical tool (external to Clojurescript compiler) could tell the Clojurescript compiler that this lib a here expects foo to resolve to a/foo, while this lib b there expects foo to resolve to b/foo without having to modify any source code. Though I agree a case

martinklepsch13:09:03

@dnolen: not sure if patch without any breakage will be possible. I assume people have workarounds in place that expect current behaviour.

jaen13:09:40

*cases where this might be needed will probably be far and between, so this might as well be ignored until someone complains with an example.

jaen13:09:42

I guess.

dnolen13:09:12

@jaen anything NPM related simply cannot work without more compiler support which we’re not going to bother with.

martinklepsch13:09:13

@jaen: I hear boot-npm 😛

dnolen13:09:27

NPM allows loading 50 versions of the same dep

dnolen13:09:38

Google Closure uses a global namespace

dnolen13:09:42

these are incompatible.

jaen13:09:49

Ok, that makes sense

jaen13:09:42

@martinklepsch: right now I'm not thinking much further than "I want to get MaterialUI to work as-is", but if some useful code results from that, then why not

jaen13:09:55

@dnolen: so basically if something like that ever comes up in practice one would be doomed to fork the lib and maintain it for compatibility with Clojurescript compiler, right? Not that I'm complaining (since that hopefully sounds like once in a blue moon occurence), just wanted to clarify.

martinklepsch13:09:10

Isn’t there some material ui thing in cljsjs?

dnolen13:09:28

@jaen no, the whole point of including all this compilation machinery is to not have to fork the lib

jaen13:09:49

@martinklepsch: this one is specifically React components, those two libs in cljsjs are not as far as I can tell.

martinklepsch13:09:11

That could very well be the case.

dnolen13:09:13

the story is exactly the same as bower, shrinkwrap the thing with a script simple_smile

dnolen13:09:28

@jaen this is really about taking the cljsjs thing to the next logical step. Except you can dump needing to write externs and the thing is susceptible to all of Closure optimization, code splitting etc.

mfikes13:09:09

To be honest, I really only want support for one foreign lib: React.

jaen13:09:58

@dnolen: yeah, I was just wondering that if Clojurescript can't scope dependencies like NPM does (and there's no plans to do so) it might result in breakages for certain NPM packages that are sensitive to their dependencies being some exact version (hence having to fork them to somehow deal with that in their source). That said I think I'm somewhat convinced now that this can be addressed only if it ever comes up in practice (I tend to overengineer and this totally sounds like a case of this) and the proposal sounds good as-is.

jaen13:09:59

Anyway, if there's anything else to be done wrt module enhancements I can try to help insofar my wits and time permits.

jrychter13:09:34

@dnolen: the download solution I implemented (bouncing from the server) works without flash and works well, so I'm happy with it for now. I just feel it is unnecessarily complex.

dnolen13:09:05

@jaen right but those issues are ones that anyone trying to use NPM for client side development will encounter. Again this is precisely the reason Bower happened. And why Browserify and other things have to use some de-duping which can’t eliminate these issues.

dnolen13:09:56

short answer, ClojureScript will never directly address the complexities introduced by NPM style package management.

dnolen13:09:27

leveraging the proposed solutions in some 3rd party thing is of course possible (though not recommended simple_smile

jaen13:09:19

Honestly I didn't do any complex frontend development before Clojurscript and React (just some usual Rails jQuery wrangling) so I wasn't aware of those issues and how that factors in.

dnolen13:09:38

@jaen ha, Browserify doesn’t dedupe - this is the NPM horrowshow https://github.com/substack/node-browserify/issues/692

dnolen13:09:54

@jaen we’re not going to go there

ragge13:09:22

@dnolen: Hi! What's the preferred way of "porting" clojure issues that also affect clojurescript? I've fixed a destructuring bug (http://dev.clojure.org/jira/browse/CLJ-1778) that I believe also applies to cljs. Report in jira and attach new patch?

dnolen13:09:23

@ragge, you can do that but for stuff like this we generally wait until it’s been vetted and applied to Clojure.

dnolen13:09:34

feel free to open a ticket and attach a patch and link to the Clojure issue.

jaen13:09:25

@dnolen: ok, that does sound crazy indeed.

darwin15:09:45

just wondering if there is a better way to coerce value into boolean, I don’t want to call 2 functions to do this: https://gist.github.com/darwin/5f7e0a5e8e5c1353c8cd

dnolen15:09:28

(boolean 0) ; => true etc.

darwin15:09:01

@dnolen: thanks, I will look for usages in cljs.core

darwin15:09:51

but it basically does the same thing, calls nil?, I guess I will leave it as is, ^boolean type-hint should inline it in advanced build I believe

dnolen15:09:54

@darwin I would not waste time worrying about 2 trivial fn calls. nil? not both inline

sgrove16:09:44

@dnolen @jaen: For consuming libraries that aren’t in e.g. cljsjs, I’m thinking about a preprocess step that takes a :libs-like declaration, and matches each :provides to a dir/file, and then generates a top-level js file with just those requires/exports that webpack can process into a single browser-loadable file, and then that file is all that the closure compiler ever sees

sgrove16:09:33

But that sounds almost identical to @maria’s work, so I’m probably just lost. Bleh.

dnolen16:09:48

@sgrove: we’re not going to bother with anything like that

sgrove16:09:51

Also, it’s basically rebuilding e.g. gulp/grunt (I think, not sure what those are)

dnolen16:09:03

the link I posted above covers what I’m interested in

sgrove16:09:05

@dnolen: Not saying you/cljs, it’d be a library I would build

dnolen16:09:59

@sgrove: I also don’t know why you would want to use what you’re proposing, might as well just use JS if you want huge blobs of unoptimizable stuff.

sgrove16:09:44

@dnolen: That’s pretty bombastic. ReactMotion is a awesome library that fits in really well with functional nature of cljs, and I really don’t want to rewrite that library. I just want to consume it, and I’m looking for ways to do so that won’t hopelessly hobble my productivity or the deliverability of my apps

sgrove16:09:13

Anyway, I appreciate the work that’s happening, I’ll keep trying to figure out a way to make it work a bit more seamlessly.

dnolen16:09:18

@sgrove: there’s nothing bombastic about what I said simple_smile

dnolen16:09:32

you can either work on the problem, or wait patiently simple_smile

rauh16:09:53

@sgrove: Also remember that HTTP-2.0 is on the horizon. You don't want to merge libraries together anymore. Many JS files are just fine to load in modern browsers.

sgrove16:09:58

I’m ok with either of those, not really with “might as well use js” 😛

dnolen16:09:59

@rauh HTTP-2.0 is just a lot of talk and bad benchmarks at this point

dnolen16:09:30

pretty much everything I’m hearing from the Google folks is that it doesn’t buy you anything in actuality and may even be detrimental.

rauh16:09:01

Interesting, I guess I'll be more skeptical then.

dnolen16:09:49

@rauh people are only pointing at the upside, better for initial load.

dnolen16:09:21

but we’re talking about a distributed system, and after the first load, the server isn’t going to know what’s in the browser cache.

dnolen16:09:29

and all the server push is just burning cycles at that point

dnolen16:09:14

and once you realize that, Google Closure trying to just make the smallest thing possible still sounds like a rock-solid fast strategy

nullptr16:09:31

sgrove: you can consume a library without including it in the closure compilation pass -- most of the time that's the right thing for JS libs, as they're not designed for adv compilation -- most CLJSJS stuff works this way

jaen16:09:53

@sgrove: that's one way to do it I suppose, but that would mean all Maria's work would have been for naught if we would just work around it. I'd wait to see if what @dnolen proposes is enough for most NPM-distributed libraries (and barring scoped dependencies it looks like it just might) and then decide what to do next. In the mean time you can follow what this library does I suppose - https://github.com/taylorSando/om-material-ui/tree/master/build-mui

nullptr16:09:58

you can certainly use something like webpack externally to translate it to directly browser consumable stuff, the std foreign-libs / CLJSJS plumbing will handle the concat

nullptr16:09:20

the asterisk there is you need externs, but such is the cost of advanced compilation!

dnolen16:09:31

@nullptr: I would not put too much weight into “not designed for advanced compilation"

dnolen16:09:51

hilariously ES6 and React-like perf sensitive libraries are becoming Closure compatible out of necessity

nullptr16:09:07

the more the merrier

rauh16:09:36

@dnolen: I didn't necessarily mean server-push, but mostly the multiplexing which makes downloading multiple JS files just as fast as one big JS file

rauh16:09:45

(in theory)

dnolen16:09:21

@rauh yeah sorry, right. But my point stands client requests one thing, server believes it know what deps client needs (but it doesn’t)

dnolen16:09:24

it may turn out to be a win eventually, but I’ll remain skeptical until a very big company working at scale says it delivers anything of value.

teslanick16:09:12

YUI3 tried to do a smart server-side loader (you ask for a module and it provides it and any dependency modules you didn't already have) and it ended up being very difficult to manage and they eventually deprecated it.

rauh16:09:02

@dnolen: Full disclosure: I haven't really tried (and measured) HTTP-2.0. I only re-stated this presentation: http://bit.ly/http2-opt (slide 29)

dnolen16:09:38

that’s just a lot of talk show me lots of benchmarks instead simple_smile

rauh16:09:45

Agreed with that simple_smile

dnolen16:09:12

@jaen @sgrove I actually now think that the hack-y React @providesModule directive might turn out to work in our favor in this regard. In order to avoid the deduping issue they have their own packaging tool. But this means their model is actually inline with ours.

sgrove16:09:27

@dnolen: Exactly, yes

jaen16:09:24

@dnolen: but that only helps us with React itself (and whomever decides to use that), right? Other libraries might not use that (for eg. libraries I or sgrove tried to integrate don't). But if they are there they do seem helpful, that's for sure.

dnolen16:09:54

@jaen this is true but once you venture out of React-land and other critical UI bits, JS libraries become less interesting to adopt - Closure has a crazy amount of stuff.

dnolen16:09:21

a lot of the JS integration stuff isn’t about being able to use anything, but filling in gaps not filled by the standard lib or Closure

sgrove16:09:55

Sounds correct, yeah

jaen16:09:47

Well, that's true that if you are doing React you suddenly have a lot less of need for things like tooltip or select libs or whatnot. But both ReactMotion and MaterialUI are React-land and don't have those annotations, so it's not universal.

dnolen16:09:45

right, but ReactMotion has no deps (beyond React)

dnolen16:09:47

MaterialUI is more annoying because of react-draggable

dnolen16:09:26

but not much more so

dnolen16:09:33

object-assign and classnames are the only deps

dnolen16:09:30

but my suspicion is that stuff that needs to run on the client will naturally avoid things with deep deps for reasons I talked about earlier

dnolen16:09:39

happy to hear about cases people discover where this is not the case

jaen16:09:10

Yeah, the dependencies remark makes sense, if it's really as problematic as you say it is (and that issue you linked certainly shows it can be).

jaen16:09:54

So I imagine if Clojurescript will be able to handle ReactMotion and MaterialUI it will be able to handle most useful libraries

jaen16:09:29

And if there's something that won't work, then potential fixes can be evaluated if that happens, I suppose

dnolen16:09:27

fwiw both Ember.js and React.js have had to deal with this problem - so we are not alone in working around it simple_smile

dnolen16:09:08

yet another reason to move more quickly on this stuff

sgrove17:09:26

Trying to debug an issue that only happens under advanced compilation, so pseudo-names are fantastic, just surprised by the compilation time (although I think I remember some ml thread saying I should expect longer compile times for it)

dnolen18:09:44

@sgrove: no idea, make sure you are giving the JVM adequate memory settings, something between 1g-2g

sgrove18:09:01

Good point, will make that explicit

maria23:09:00

@dnolen @jaen I am probably a bit late to the party, but here are my thoughts on the wiki entry to enhanced module support. I like the idea of supporting library specs in :libs for converting JavaScript modules, since it highlights that those JavaScript moudules can be used in the same way as Google Closure modules after conversion. This would probably mean that we wouldn't support the :module-type option in :foreign-libs? But I think we would still need to support the :preprocess option in :foreign-libs since users might want to use this functionality separately without module conversion.

maria23:09:38

And :path in the :libs spec should probably either point to a single file or a directory?

dnolen23:09:37

@maria yes I agree that :module-type + :foreign-lib doesn’t make that much sense in the context of the ideas expressed in the wiki entry. Agree with :preprocess.

dnolen23:09:10

and yes to :path pointing to a single file or directory, not sure what that key should actually be called, open to ideas.

dnolen23:09:41

@maria and no, not late to the party - won’t start working on anything or greenlighting anything without your feedback simple_smile

bhauman23:09:11

You all are going to make Clojurescript the best platform to work on JavaScript.

nullptr23:09:25

it's probably already the best platform for working with closure and react, we've already won!

bhauman23:09:00

I'm already doing effortless live js coding. Now with module preprocessing I will probably be able to code arbitrary js modules live as well. and with externs generation ... I'll get all the GCComplier goodness as well.

bhauman23:09:41

Jeez, I'm going to have to give a live coding talk at a JS conference soon ...

nullptr23:09:14

i'm demoing figwheel to a couple hundred JS folks in a couple hours...

nullptr23:09:23

i'll let you know how it goes :)

bhauman23:09:18

just don't throw an error in the REPL, seems to be a nasty stacktrace bug.

al3x23:09:24

@bhauman: I saw a couple people bringing up issues with Figwheel and auto-reloading in the latest releases. I’m seeing a version of that, where Figwheel is pushing JS files with an incorrect path. Known issue?

al3x23:09:39

Oops, sorry, that was for @bhauman

nullptr23:09:42

don't worry, like all good demos -- happy path only

bhauman23:09:56

@al3x: yeah we're used to that

nullptr23:09:01

al3x: i had an issue like that, try (clean-builds) from figwheel

bhauman23:09:37

@al3x: yeah you have to do a thorough cleaning when switching figwheel versions

al3x23:09:17

okay, I’ve cleaned the heck out of my project, but the paths that Figwheel is pushing are still wonky.

al3x23:09:24

Ex: ("../imageatlas/pages/home.js" "../imageatlas/components/page.js" "../imageatlas/core.js”)

al3x23:09:39

Those relative paths go to nothing

bhauman23:09:48

You need to re load your browser as well

al3x23:09:45

Seeing the same issue across browsers, in fresh tabs, etc.

al3x23:09:59

Is there some way to control how those paths are generated?

bhauman23:09:20

@alex are you using weasel?

al3x23:09:41

project config is as per the latest docs

maria23:09:39

@dnolen :path sounds good to me, it works for both, file or directory simple_smile One thing we need to keep in mind is that the Google Closure compiler can only handle requires that use a relative or absolute path when converting modules. That’s why jaen got the error mentioned above where the Google Closure compiler couldn’t locate react. And we always need to pass all the required files as source files to the Google Closure compiler when converting a module.

bhauman23:09:58

@al3x: I really think something fishy is going on here. perhaps caching.

bhauman23:09:32

@al3x: you are getting 404s right?

dnolen23:09:31

@maria right the relative or absolute path is an interesting problem - that’s not how Node.js require actually works for installed modules.

al3x23:09:06

@bhauman: no, actually i’m getting totally blank responses

dnolen23:09:20

passing all the inputs doesn’t seem like too hard a problem, @juhoteperi’s recent ticket to calculate all deps seems like it would do the trick

dnolen23:09:28

or at least related to solving that problem

bhauman23:09:56

@al3x: so you have your own server that is serving your compiled javascript assets?

Josh23:09:20

Hi #C03S1L9DN, I'm new to clj(s) and I'd like to try building an app on top of Parse. I found my way to cljsjs and noticed the Parse JS SDK wasn't packaged, so just submitted [my first PR](https://github.com/cljsjs/packages/pull/221). Following [these docs](https://github.com/cljsjs/packages/wiki/Creating-Packages), boot package build-jar seems to have worked, but now I'm not sure how to test it locally. I have a (boot2-based) Hoplon6 app I'd like to include it in but not sure how. Anyone have a minute to pair with me?

bhauman23:09:34

@al3x: and that server isn't respecting the relative paths

bhauman23:09:12

@al3x: this is a problem you will have with any Google Closure project.

al3x23:09:38

weird. it just cropped up with the latest figwheel version. i’ve been working with the same setup for weeks.

al3x23:09:48

it’s just an http-kit server

bhauman23:09:56

@al3x: I'm deferring to goog.require and following it's conventions. But you know I can/should probably fix the relative path before the request.

bhauman23:09:10

Not that hard to do,

bhauman23:09:20

@al3x: things work a lot better now but yeah I'm deferring more to google closure to handle this stuff

al3x23:09:18

huh. so now I’m seeing actual responses, and the page bodies include the expected generated JS. the page just isn’t reflecting the changes visually.