This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-27
Channels
- # aws-lambda (3)
- # beginners (3)
- # boot (327)
- # capetown (2)
- # cider (156)
- # cljs-dev (368)
- # cljsjs (13)
- # cljsrn (53)
- # clojure (403)
- # clojure-czech (5)
- # clojure-dev (4)
- # clojure-greece (2)
- # clojure-russia (72)
- # clojure-spec (12)
- # clojure-uk (129)
- # clojurescript (156)
- # core-async (1)
- # cursive (33)
- # datomic (35)
- # emacs (10)
- # events (1)
- # hoplon (4)
- # jobs-discuss (3)
- # klipse (1)
- # lein-figwheel (14)
- # leiningen (5)
- # luminus (5)
- # off-topic (15)
- # om (69)
- # om-next (2)
- # onyx (2)
- # parinfer (15)
- # perun (12)
- # re-frame (30)
- # reagent (7)
- # ring-swagger (8)
- # spacemacs (10)
- # specter (6)
- # untangled (69)
- # yada (13)
I got this to compile https://github.com/swannodette/es6-demo/blob/closure-master/src/libs/NodeStuff.js
oh wow...
React too?
but this confirms my suspicion that trying to integrate with CommonJS NPM modules is kind of dead end
however there’s still some value for people who want to use NPM as their distribution mechanism
hrm or maybe not … I don’t know yet - there maybe something about how we evaluate goog.require
under Node.js that is wrong.
tested latest master (367e2f) against a 20K line reagent/re-frame app and all works fine slightly_smiling_face Noticed initial build time on 80->114s) and rebuilding on changes increased avg 10 seconds (~20->30s). @dnolen:simple
optimisations increased avg 34 seconds (
@superstructor I don’t know about :simple
since that’s Closure time
should I try optimisations :none
and time it again ?
@dnolen time reported by :compiler-stats true
and I think the final “elapsed time” is part of our boot-clj tasks; e.g.
Compiling ClojureScript...
• js/app.js
WARNING: :preloads should only be specified with :none optimizations
Compile sources, elapsed time: 545.27221 msecs
Compile sources, elapsed time: 153.117463 msecs
Optimizing with Google Closure Compiler, elapsed time: 11372.209861 msecs
Optimizing 490 sources, elapsed time: 28017.807772 msecs
Writing target dir(s)...
Elapsed time: 30.921 sec
@superstructor like I said anything in Google Closure time is not something we can do too much about
it’s also nearly impossible to swap out Google Closure since they make breaking changes and we are often pinned to a particular one since we integrate so tightly
@superstructor I’d be more interested in :none
time
@dnolen ok thanks I’ll do some tests on :none
time and see if there is a substantial difference between versions.
A scary commit 🙂 https://github.com/clojure/clojurescript/commit/59a7f265fac02c931cc3d5615727da861db62e3b
@dnolen so on :none
the compile sources phase actually appears to be slightly faster (if anything) going from 293 -> master. Just the Google Closure optimisation phase on :simple
and above that appears to have slowed down, so I understand thats not in scope of CLJS. Thanks :thumbsup:
@superstructor glad to hear it
but externs are definitely going to be an issue - but funny cljsjs kind of solves that problem
advanced compiling ClojureScript from node_modules, including a good chunk of cljs core via the usage of a persistent vector and the println stuff - 66K gzipped
curious why you had to remove cljs.nodejs/process
and cljs.nodejs/require
that may be a breaking change for people on Node
@anmonteiro yes it will be a breaking change
when we globally require we need to disable goofy JS detection of the Node environment
oh right. I know what you're talking about
I do the same in Lumo
@dnolen btw, I just discovered why Lumo isn't building. Got one more patch before tomorrow's release. Attaching it now
I don’t want to break what people are doing with Node.js too much, so people need to try it
but so far I’m thinking that being able to consume Node.js deps without losing your mind is a huge win
A TL;DR view of CLJS-1909 is that is strangely reaches into macro-land, and then accidentally back out into runtime.
@dnolen right. fortunately these breaking changes are fairly easy to spot
Right. As @mfikes said it's an edge case that only occurs in self-host
which is why it was hard to figure out
this is a game changer. I'm really excited to try it out
hopefully I'll have some time over the weekend
between this & externs inference our integration story improved by at least an order of magnitude
yes, you've been hard at work
@dnolen btw, I think this patch still makes sense: http://dev.clojure.org/jira/browse/CLJS-1822
but I wouldn't recommend putting it in this release. Probably need to try it out again and report back
Funny because at our Vancouver meetup today we where using nodejs/require
a lot: https://github.com/paullucas/lumo-misc/blob/master/http.cljs
I guess it won't be possible anymore
the use case in question is consuming e.g. React
@richiardiandrea that thing was annoying anyway
they have a dev bundle which doesn't strip away some checks when compiling with :advanced
You know, actually yes 👍
@richiardiandrea I’d like the Node.js integration to be a lot simpler
if we’re going to break a few minor things, it’s a good time to consider how to make it better
At work we are going to probably write a big chunk of code using cljs on Node.js, so I am very excited about this, thanks
Oh okay, will test that, got it
We are about to, and actually estimating if it is a good choice, but because we are targeting AWS lamdba it is kind of the only choice if you want to keep using Clojure
So I have to say that these new patches are actually solidifying my proposal (which I am kind of pushing) and could not come in a better moment 😀
Will do
@richiardiandrea could you run Lumo scripts on AWS for example?
I'm not suggesting you do, just asking because I'm unfamiliar with it and don't know if you can run third party binaries
@anmonteiro on an EC2 instance yes, the code above was a little exercise during the meetup
On lamdba you run js
I meant AWS Lambda
I know you can run on EC2, sorry
I went to double check but no: > AWS Lambda supports code written in Node.js (JavaScript), Python, Java (Java 8 compatible), and C# (using the .NET Core runtime). Your code can include existing libraries, even native ones. Please read our documentation on using Node.js, Python, Java, and C#.
👍 thanks
http://dev.clojure.org/jira/browse/CLJS-1911 is worth looking at closely before release
So cool to read up on all the progress done here. Looking forward to the day where we can say CLJS React apps are smaller than JS React apps hehe
Wondering how hard it would be to run yarn
inside nashorn...
@anmonteiro: AWS Lambda calls to one of python, js, java, but there's nothing stopping you from shelling out to Lumo
You can provide a zip file of code/whatever when you deploy a lambda, so you would just bundle Lumo, assuming it has a static binary (or you compile it on an AMI that looks like the lambda environment).
Things won't be quite as tightly integrated, we're calling python3 from python2 and it works ok. Obviously you pay for the overhead of calling out, and also you don't get to keep lumo running in between requests.
But could be handy for some quick scripts
@martinklepsch technically they already are 🙂 based on my test yesterday React+ReactDOMServer is about 8K smaller by going through Google Closure
@anmonteiro yes I was are of require issue but I didn’t have a good answer for that - that patch looks fine to me
@martinklepsch stuff like Yarn unlikely to work because they haven’t thought about the “bootstrap” problem
Ah I see. Somehow thought Nashorn would be exactly that, but it’s “just" JS
There seem to be some other things out there though… http://dynjs.org/ & http://nodyn.io/
@martinklepsch I looked at that before and I suspect it’s not good compared to Nashorn (wrt. to quality completeness of JS runtime)
might be, either way, probably not “the pragmatic approach” just to get rid of the node dependency for development
I agree worth looking at, but my experience with non-spec compliant JS runtimes has been pretty bad
@dnolen: awesome. We can also just bind require
to global.require
outside the function, but in Mikes's patch it is right next to the problem so might be easier to reason about why it's needed
@anmonteiro I already did that on master
Ah right. On phone, sorry. Yes it's fine lile that, just saw it
@dnolen: consider also applying CLJS-1910 to get the bootstrap tests running again
@anmonteiro shouldn’t that work? with require
fix?
It uses cljs.nodejs/require
which you commented out
Not sure if the fix is to bring those back or to apply mikes's patch
going to work on an “advanced" part of the JavaScript modules http://clojurescript.org guide that shows how to consume node_module
Cool. I'll give it a spin in about an hour
hopefully it inspires people to think how make it easier - I don’t think it will be very hard
I’m deprecating the ClojureScript wiki, please direct all edits to the ClojureScript site, thanks https://github.com/clojure/clojurescript-site
@dnolen https://github.com/clojure/clojurescript/blob/7d856d7f04dde5e450462cbf24866011803f47a6/src/main/clojure/cljs/closure.clj#L1921
bug there: remove opts
, it's already threaded through
one other thing. one recent patch added timing info for every file that's compiled
in my computer it shows that compiling cljs.core$macros
takes about 27 secs
is this to be expected?
it's by far where the compiler is wasting the greatest amount of time
apart from that, Lumo works great with latest master
builds successfully, every test passes, etc.
@anmonteiro I would expect that file to take some time
27 seconds on a fairly good computer. takes about 40 on my 2.5-year old mac
that would make sense
@dnolen that would also explain the thing I showed you at EuroClojure
exactly
let's open a ticket so we don't forget
on it
for every numerology fan out there
lol you guys are funny 🙂
I will need to update replumb now with all these changes 😄
tested a "standard" boot project against master and no problems so far
(also used master for this project btw, no issues, but also very small project)
@martinklepsch it seems moderately useful though it should probably have a lot of caveats
got some regressions in my tests, git bisect identified this commit: https://github.com/clojure/clojurescript/commit/101d7d9e03e90518e6769781dd33fbe6387d2d44 it is probably my fault, FYI, investigating it now
found the issue in my code (wasn't obvious): https://github.com/binaryage/cljs-devtools/commit/3267356be0d2d5d4084191f104cb80c239d2f6b6
I think it will be worth noting in release notes that sequable?
changed and people might want to review its usage
also DCE stopped working in in my cljs-devtools tests -> going for another bisect hunt
according to git bisect this commit prevents DCE in cljs-devtools: https://github.com/clojure/clojurescript/commit/0560106fe8576fd7029d86e61be09cd1f246bfe0
this is the test project which gets compiled:
https://github.com/binaryage/cljs-devtools/tree/master/test/src/dead-code/devtools
this is the compiler config:
https://github.com/binaryage/cljs-devtools/blob/master/project.clj#L73-L82
this is lein task to run it lein test-dead-code
:
https://github.com/binaryage/cljs-devtools/blob/master/project.clj#L107-L109
I’m not inferring externs there, it is really strange, don’t understand that commit (yet), just reporting what I’m seeing 🙂
so far, I was able to narrow it to this line: https://github.com/clojure/clojurescript/commit/0560106fe8576fd7029d86e61be09cd1f246bfe0#diff-97c50fd669986fb95db3957c1bab83baR769 added some debug printing, it definitely affects my existing code which has no externs inferring printing !!! sym -> pre, outputs stuff like this: https://gist.github.com/darwin/4832baf286287d94c32a32443fa8b60f
I could try to print generated source before it gets passed to closure compiler and maybe compare it to old version if that would be helpful
well, DCE worked in 1.9.293, I upgraded to master, it broke, the test project it dead simple, I don’t see obvious error on my side
this is not super important, some people rely on cljs-devtools to be elided by DCE in advanced builds, this will stop working for them
I personally don’t include clsj-devtools in advanced builds (via a separate cljsbuild profile configuration)
at this point I don’t understand compiler internals enough to really answer it, sorry 🙂
@dnolen just saw you doing some work with processes. I think you forgot about clojure.java.shell/sh
which does what you are implementing basically
@thheller yeah I’m just not familiar with that ns, and it’s not really important now, I have something working
@darwin I just tried the trivial console.log
hello world smoke test - DCE seems OK here
dnolen: ok, I also tested cljs-oops which has multiple projects testing DCE and all worked, but none of them is testing a code which should get elided by :closure-defines
via false goog.DEBUG, which is probably the case which stopped working
look here, that’s my test project: https://github.com/binaryage/cljs-devtools/tree/master/test/src/dead-code/devtools
ah, mean this one: https://github.com/binaryage/cljs-devtools/blob/master/test/src/dead-code/devtools/dead_code/core.cljs
goog.reflect
has some interesting things in it: https://github.com/google/closure-library/blob/master/closure/goog/reflect/reflect.js
(aget obj (goog.reflect/objectProperty "string_prop_name" obj))
allows prop-munging of property names, but can still access by string
goog.reflect/cache
lets you use an object as a side-effect-free cache without preventing DCE
btw. this mandatory ^boolean
thing reminds me this ticket, which fixes it (and hopefully more):
http://dev.clojure.org/jira/browse/CLJS-1615
ok, that’s a fair point, let’s hope for closure compiler to get smarter about our truth_
function
tested on a project, compiles fine with advanced optimizations output bundle got larger for ~0.5KB, changed from 797460 bytes to 797965 bytes
I’m also getting compiler warnings Use of undeclared Var private.project/js
which is really just this calls (js/Date.)
. There 7 calls, but I’m getting only 3 warnings, don’t know if it’s helpful
nevermind, it’s gone
@dnolen I know it is marked experimental but I'm really skeptical about the whole node_modules stuff. There are a bunch of sort of non-official things in the js build world that this completely ignores.
so basically your only goal is to let people call into babel or others via js-transforms?
dealing with the wider JS ecosystem is not purely a technological one with a simple answer
the changes to ClojureScript are just about letting others do that work with less friction
if somebody gets inspired by this stuff and does something 10X better - we accomplished our goals
yes that is great but you also still have people using
or whatever that ns is called
@dnolen hah, looks like the ClojureScript release missed this by a couple days: https://github.com/google/closure-compiler/pull/2130#issuecomment-275801425
> This has been submitted internally & will appear in github on our daily export.
@anmonteiro yep I’ve been following that one very cloesly
@anmonteiro but no idea when that will get into a release
hopefully will be in the February release
@thheller far as I can tell the most successful things in technology are pretty darn dusty
@anmonteiro fingers crossed, soon as that’s in we can fix the ugly ES6 example
I think it optimal case Closure should be able to optimize JS modules as well or better as Webpack
https://clojurescript.org/guides/javascript-modules has some invalid code
@juhoteperi it’s already better
Closure can already remove code where if
condition is always false, etc, so it should be probably possible to define process.ENV
as constant or something
@juhoteperi yes, in fact you could probably hack it with goog.define
in CLJS
@juhoteperi I don’t know if you saw earlier but you were right about the package.json
stuff
One thing that I hit when trying this a month or two ago, was that Closure "scoped" modules by path, packages under node_modules
could only require each other and not packages from foobar/node_modules