This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-27
Channels
- # bangalore-clj (1)
- # beginners (11)
- # boot (23)
- # business (2)
- # cider (43)
- # cljs-dev (65)
- # cljsjs (17)
- # cljsrn (4)
- # clojure (144)
- # clojure-austin (4)
- # clojure-berlin (3)
- # clojure-finland (4)
- # clojure-nl (2)
- # clojure-russia (13)
- # clojure-spec (73)
- # clojure-uk (42)
- # clojured (2)
- # clojurescript (166)
- # core-matrix (4)
- # cursive (24)
- # datomic (39)
- # dirac (8)
- # hoplon (97)
- # jobs (2)
- # jobs-rus (11)
- # juxt (16)
- # lein-figwheel (8)
- # leiningen (1)
- # luminus (5)
- # lumo (46)
- # off-topic (1)
- # om (39)
- # onyx (43)
- # overtone (1)
- # pedestal (3)
- # perun (6)
- # play-clj (3)
- # protorepl (14)
- # re-frame (21)
- # reagent (25)
- # remote-jobs (1)
- # ring (1)
- # robots (4)
- # rum (13)
- # specter (5)
- # untangled (72)
- # yada (62)
I’m trying to import a node ES6 module, and it doesn’t know what to do with the spread operator: …
Is there anyway to add a preset to the Closure Compiler to let it know what to do with it?
@mruzekw how are you trying to import a node ES6 module?
can you show me your foreign lib entry for that module?
:foreign-libs [{:file "node_modules/react-scroll-horizontal/src/react-scroll-horizontal.js"
:provides ["com.mruzek.hz-scroll"]
:module-type :es6}]}
@mruzekw did you add :language-in :es6
to your compiler options?
ClojureScript compiler options
did that fix the issue?
I’m getting:
ERROR: JSC_PARSE_ERROR. Parse error. '}' expected at node_modules/react-scroll-horizontal/src/react-scroll-horizontal.js line 96 : 6
Looks like “Babel Transforms” is what I’m looking for https://clojurescript.org/guides/javascript-modules
I don't know if ES6's specification includes the rest operator
in any case the transform should help you
Now I’m getting missing module errors:
ERROR: JSC_COMMONJS_MODULE_LOAD_ERROR. Failed to load module "react" at react-scroll-horizontal.js line 5 : 21
ERROR: JSC_COMMONJS_MODULE_LOAD_ERROR. Failed to load module "react-dom" at react-scroll-horizontal.js line 5 : 39
ERROR: JSC_COMMONJS_MODULE_LOAD_ERROR. Failed to load module "react-motion" at react-scroll-horizontal.js line 5 : 61
@mruzekw if you're consuming node modules you should be aware you're trying out pre-alpha features and expect to figure things out on your own
your could probably use cljs.build.api/node-inputs
to calculate the dependencies for your module
see the very end of https://clojurescript.org/guides/javascript-modules
are there any om <-> webgl bindings available? I'm aware of gamma and http://thi.ng, but they both seem to be pure cljs
Does anyone have any experience creating commonjs libraries with clojurescript?
I'm attempting to use clojurescript on AWS lambda
and I'm not sure how to get an exports.handler
into the top level of the build
@anthony.naddeo I’ve had success using https://github.com/nervous-systems/cljs-lambda in the past
on a different note. calvin-cljs got an update to support the lumo.build.api https://github.com/eginez/calvin
@stbgz Thanks! looking into that now
Is there a simple om-next example where as I move mouse cursor around, the x/y coordinates are updated?
@qqq there is: https://github.com/omcljs/om/blob/master/src/devcards/om/devcards/bugs.cljs#L71-L113
@anmonteiro : this is precisely what I needed; thanks!
show-stopper cljs advanced compilation bug with core.async http://dev.clojure.org/jira/browse/CLJS-1954, due to async
being a new reserved word
When something works perfectly fine in :optimizations :none, but gives an error of "cannot read property 'j; of undefined" under :optimiozations :advanced .... how do I debug this?
@anmonteiro fwiw, can no longer reproduce the closure naming issue. Think it was somehow related to npm link. Will sort it out in case it hits me again.
@qqq :pseudo-names true + :pretty-print true gives you :advanced without the senseless names, so that you can read it
@robert-stuttaford : I'm sorry how do debug with this, is it: 1) in :compiler-options : 1a) remove :optimizations :advanced 1b) add :pseudo-names true // add :pretty-print true 2) rerun program 3) then, when error pops up, I somehow map pseudo-names back to real clojure names? The part that confuses me is as follows: if the names are accurate, I should ahve no problem since :optimizations :none works if the names are not accurate, how do I guess the original names?
@qqq, you should keep :optimizations :advanced
Clean up generated js and compile.
okay, this makes sense, so it does all the optimiozations; but instead of minifying everything down to 1-letter var names, it gives me pseudo names that should be reversible
"There are only two hard things in Computer Science: cache invalidation and naming things.” -- Phil Karlton
Every problem in CS can be solved wiht an extra layer of indirection; except the proble of having too many layers of indirection.
@darwin "There are only two hard things in Computer Science: cache invalidation, naming things and off by one errors.” -- Anonymous
it doesn't change the situation that before i started working with clojurescript, i have not head these cache errors for years
not saying it was easy, just that it was abstracted away and the problem did not arise unless you specifically tried to deal with it
definitely didn't arise in situations like using a development environment where all caching should be always turned off (unless you want to work on a cache or with a cache, but again, those are specific scenarios, not everyday situations)
@ashnur the caching we are talking about here is exactly what you want turned ON during development
what's generally the size of a large clojurescript app with advanced compilation and gzipped that people have seen?
if just has become one of those "did you try turning it off and on again?" type things where restarting usually resolves the thing
@risto I worked on a app that had 30MB of JS files, gzip+advanced compilation = 400KB
(JS files = output of CLJS compiler)
not really, it all worked really well
turning on simple optimizations helped performance a lot, as well as advanced compilation (although perhaps less of a improvement moving from simple->advanced).
I would recommend doing all benchmarking and performance testing with optimizations turned on. It sounds like a 'duh' suggestion, but those compilation modes improved performance of some of our functions by 10x.
@risto I'm working on app that has 5Mb of js files, but passes to be 450k advanced+gzip or 320k advanced + brotli 😉
because it can be hard to keep access consistent across a big codebase. Sometimes you may need aget, but sometimes not
@niwinz I'm wondering what made your compression level much less than @tbaldridge (400KB/30MB vs 450KB/5MB)
@risto it's dead code removal
Maybe I have less dependencies and I'm using bigger portion of code of that dependencies. The dead code removal on the end depends on each codebase..
the Closure compiler removes code that's included in your project but never actually called. My project had a fair amount of cruft
@thheller are you saying that hmr is impossible to solve on the level as incremental compilers (like browserify for example, where i think there is hmr, but i never tried, it was enough that the bundle was finished in miliseconds)
afaik no incremental compiler in javascript has these kinds of "cache issues" that i am also experiencing (exclusively with clojurescript)
hello. How to check if goog.DEBUG
is set as early as possible? I want to have some bindings in index.html
. Or how to compile index.html without debugging code?
ah no not what I'm talking about. The caching I'm talking about is the analyzer cache. The analyzer keeps all information about your CLJS code, ie. which namespaces exists, which functions and so on.
this is required for compilation, so if that somehow gets out of sync you are compiling against stale data
this is why it comes up often. whether or not caching was actually the problem is unclear
1. you were one of those who said this is so common, you are guessing just to be sure 2. i always run lein clean && lein figwheel but that doesn't really help much 3. running lein is very slow. i must say that the develoepr enviroment (with or without hot reload) is a serious downgrade from what i am used to in javascript.
@negaduck you maybe want to look into :closure-defines
as a compiler option, that allows you to define goog.DEBUG
for your build
@ashnur so ... if you want to start that subject, I need to make a disclaimer: I wrote shadow-build
which is basically a replacement to any other build tooling you might have used. ie lein-cljsbuild
and lein-figwheel
. I won't comment on any of these as I haven't used them in over three years.
I wouldn't recommend my build tooling to anyone (yet) as documentation sucks but one of the reasons that motivated me to start all of it was performance and caching errors
so my judgement about caching errors may actually be incorrect I only know that I fixed all the issues I could find
@ashnur lein clean
might not do what you think it does
it’ll clean your build only if it’s listed under :clean-targets
in your project.clj
@anmonteiro I have to say though: every time you actually run lein clean
and a CLJS problem goes away that probably was a bug in CLJS. So I'm very unhappy that this is still a suggestion that is made frequently.
My comment was only about a particular feature of Lein that may be misleading to users
@thheller I haven’t actually used Lein for more than a year, and I haven’t had any issues since then
most likely because Boot caches a lot less
which I understand may also not be the solution
you know, there are way more build tools in js i think than in cljs, yet most people tried all of them for some time (well, most people who are working with js more than 6 six years, not beginners, of course)
I don’t know what that is supposed to mean
@ashnur I suppose that’s a theme better suited for #off-topic if it’s not related to ClojureScript or adding anything to the conversation
I’m trying to build in a foreign-lib and I’m getting the following error from the compiler:
Cannot build without root node being specified
Anyone have an idea what’s up?@mruzekw that means your module has an error being processed
I discovered last night that these errors are getting swallowed
@mruzekw actually glad you reminded me, just submitted a patch for it http://dev.clojure.org/jira/browse/CLJS-1957
If a foreign lib uses UMD do I need to specify a :module-type
?
:foreign-libs [{:file "react-scroll-horizontal.js"
:provides ["cljsjs.scroll-horizontal"]
:requires ["cljsjs.react-motion"]}]}
@mruzekw would this be your error? https://github.com/google/closure-compiler/issues/2308
@mruzekw sorry that stack trace doesn’t mean anything to me. I’m happy to look at a repro which doesn’t include Figwheel or Sierra’s component
there’s just no useful information in that stacktrace
@tbaldridge how long did your page loads take in local dev with 30MB of js? We’re at 18MB and it takes 8-9s.
that's about right 15sec or so, with adv compilation it was almost instant.
I would not recommend having that much JS...this was a worst-case situation, and I wasn't really in a position of power to demand a code-cleanup of the unused deps.
That being said, with figwheel + react we didn't have to reload the app often. I probably reloaded once an hour or so when I was really digging into a bug.
@leroix if you’re loading cljs.js
there are some other tricks you can do to lower the bundle size
for example: :dump-core false
in your compiler options and lazy-load the analysis cache
http://blog.fikesfarm.com/posts/2016-01-04-planck-lazy-analysis-cache-loading.html
you can use with / without optimizations
btw, I don’t know if many people realize this but a hefty part of the initial compilation time for cljs comes from lein
. If you just run
java -cp cljs.jar:src clojure.main build.clj
@leroix also relevant, on
we were able to compress our main.js
to 707kb (gzipped)
options are here: https://github.com/Lambda-X/cljs-repl-web/blob/devel/build.boot#L93
@richiardiandrea nice, what was it without gzip and advanced optimizations?
@leroix no, advanced is not possible in cljs-in-cljs
:dump-core false
is a must, and you load the cache on load
found https://github.com/clojure/clojurescript/wiki/Optional-Self-hosting about :dump-core false
@leroix here’s how I load the analysis caches in Lumo https://github.com/anmonteiro/lumo/blob/master/src/cljs/snapshot/lumo/common.cljs
plenty of examples now among planck
, lumo
and replumb
now, I am happy cljs-in-cljs is taking over 😄
One thing I’ve been curious about is packaging cljs modules as npm modules. I wonder if cljs-in-cljs makes that a lot more feasible
@leroix for cljs libs I created a boot
task at the time: https://github.com/Lambda-X/boot-pack-source
it takes the sources and put them in a folder on the boot
fileset
that folder is dumped then on the server (in case of a website deploy)