This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-08
Channels
- # alda (10)
- # beginners (15)
- # boot (16)
- # business (2)
- # clojure (68)
- # clojure-czech (1)
- # clojure-italy (3)
- # clojure-japan (71)
- # clojure-russia (32)
- # clojure-uk (2)
- # clojurescript (134)
- # core-async (84)
- # datomic (27)
- # devcards (13)
- # hoplon (3)
- # ldnclj (8)
- # ldnproclodo (1)
- # lein-figwheel (2)
- # melbourne (1)
- # off-topic (29)
- # om (53)
- # re-frame (7)
- # reagent (15)
- # yada (50)
@settinghead: One limitation is that :advanced
Google Closure optimization is not supported by the bootstrapped compiler
@maria: From IRC on 29-JUL-2015, David confirmed that :none
and :simple
are the supported modes, but I see that our FAQ seems to imply only :none
But how can :simple
work without Google Closure? Or do you mean initially when compiling a project which uses cljs.js
?
@maria: I suspect your distinction is the correct one (the initial compilation can be :simple
) but after that cljs.js
just gives you JavaScript for things like compile-str
and source to be cached, etc.
@maria: I bet things fall apart if you use :optimize-constants true
with :optimizations :simple
and then attempt to produce additional JavaScript at runtime… (just speculation on my part, never tried)
@maria: Actually, I did try a little experimentation with :simple
with Planck, and it made launch latency slower than with :none
, so I stopped messing with it.
The test here actually uses those both options: https://github.com/clojure/clojurescript/blob/923e1d9aa139b299bfe91522009e5fdc67ec0e9f/script/test-self-host
This makes me wonder what Joel Martin is using for http://clojurescript.net
@mfikes: Do you know why :optimize-constants
is not listed on the wiki page for the compiler options?
@maria: I have deja vu wondering the same thing several months back when David mentioned it. Probably an oversight
@dnolen: @mfikes Added the :optimize-constants
option to the wiki. Hope the description is correct 😉 https://github.com/clojure/clojurescript/wiki/Compiler-Options#optimize-constants
@dnolen, @mfikes: I used the Ejecta+Ambly template, works great for direct canvas drawing. I decided to push my luck and throw Quil in there. It loads up, doesn’t give errors, but doesn’t draw either.
ThreeJS works, so thinking maybe there’s something simple about Quil that needs work, but haven’t had much luck.
Failed to resolve version for chesnut:lein-template:jar:RELEASE: Could not find metadata chesnut:lein-template/maven-metadata.xml in local
I cant jump start chesnut with the lein 2.5.3
Quil was waiting for the window load event to draw to the canvas, so the silent failure was due to it never attempting to draw in the first place. When I force it to draw, processingjs gives errors related to document references being null. Would have been cool to see Quil hook into seamlessly. Probably better off trying to use React Native instead of Ejecta for this particular case.
@yusup: could be a lein problem, i'm still on 2.4.3 and that command ran just fine
@redbeardymcgee: thanks
Try removing :aot
from the ClojureScript compiler dependency. It's not great for debugging. Also, can you post back the final app.js
? I have a feeling that the tooling is messing up and compiling in :none
, ignoring your config.
@maria: I think the reason :optimize-constants isn't mentioned anywhere is because it is automatic for :advanced and problematic anywhere else as it breaks incremental compilation
Using lein figwheel
, what's the easiest way to get println's from function calls to show up in the terminal process, as opposed to (just) in the browser console?
thheller: It must be, if I run (println "foo")
in the terminal process it shows up there (and in the browser console, of course).
it would still just in the browser repl (the only connection), just redirect printing to a different console. But browser hijacks printer when it isn't initiated from the terminal, I think
@oskarth you are correct, calling (figwheel.client/enable-repl-print!) seems to enable that.
hm, when I run that I get a no print-fn set for evaluation env, which makes sense, but nothing is printed in repl
@maria constants are emitted in a single file that all other cljs namespaces depend on. so if you use a constant AFTER that file is created (ie. REPL) it will emit the constant in the code but the constant does not exist. the REPL prevents that by disabling emit-constants I believe but you then have a mix of constants of freshly instantiated pseudo constants.
@maria but I just realized that constants are no longer numbered so that might actually work now
@maria forgot that http://dev.clojure.org/jira/browse/CLJS-1086 made it into core some time ago
@oskarth: this simple example works for me: https://gist.github.com/mneise/e39484340ff4a2789da6
so now it's just a matter of fixing the weird spacing in the printing and writing a toggle-log fn. Thanks
@oskarth wonder why it is disabled by default. https://github.com/bhauman/lein-figwheel/blob/master/support/src/figwheel/client.cljs#L355
guessing because it's (a) not reliable (println not working for me when it's in a fn, printing "foo" => "f o o" for some reason)) (b) not desirable to print everything twice
@thheller: ah, I see, so the constants table is not emitted again when a new constant is added? But yeah, I see that :optimize-constants
is not really intended to be used in dev mode and is only relevant for your release build.
@maria yeah, the situation improved after constants received stable names but things are still weird is many cases
I experimented with emitting the constants when they are first encountered but that turned out way more difficult and error prone than I anticipated
@thheller: cool, thank you for clarifying should probably add this to the compiler options wiki page that it is only recommended to use :optimize-constants
for your release build.
@maria yeah I fought many battles with constants, definitely best to keep people out of that as much as possible
oops sorry, I missed the gist message from you, @maria - I tried the xhr req with just println in a new ns and your gist works great, thanks! I wonder if it's because I was defining things in the browser repl, or if a previous enable-console-print made it act weird.
I'm trying to convert cljx files to cljc, but it acts weird with cljsbuild auto. When I touch cljc file it seems to trigger full build (looking at time it takes to finish) instead of incremental. Any idea what might be wrong?
@maio that might be because .cljc could have macros or affect macro code? cljsbuild doesn’t do any fancy analysis about that, perhaps the full build bit is a safety thing
@maio I can’t say conclusively that what I said is true. Might be worth taking at a look at the GitHub issues, maybe somebody else will chime in here as well.
I’m missing something here… I have a :closure-defines {the-app.core/api-uri "
property on my cljsbuild configuration, but it never seems to override the value done from (goog-define api-uri “the-default”)
on namespace the-app.core
.
I was looking through the source code for om and I noticed the use of $
in a number of places - i.e om$isComponent
https://github.com/omcljs/om/blob/master/src/main/om/next.clj#L157. What is the purpose of the '$'?
@ricardo: try setting the munged name as it ends up in js {:closure-defines {"the_app.core.api_url" ...}}
cljs did not support closure-defines in :none for a long time. not sure what the current state of that is. are you trying in :none?
I noticed that, found a patch from August and the issue was closed. I expect it got merged by now, but can’t say for sure. I’m using :whitespace
, although it seemed like it applied to it as well.
@thheller: If you mean if I verified that the goog.define call ends up on the JS with the default and the munged name, yes, it does.
oh an which version? I remember something changed very recently that stopped defines from working
@mahinshaw: the $ is just used as a divider to namespace those attribute definitions under om
or omcljs
. If I recall correctly, it is also the character used during google closure's symbol munging.
@mahinshaw: @bensu: it’s not an idiom
React requires dynamic objects for props, so Om does this to avoid issues with advanced optimizations
@mahinshaw: rewritten not clobbered
I wasn't thinking I would use the properties, I was just curious of the significance of the $
@bensu: I just got to trying the :aot
thing you suggested. It still looks not minified to me. Here's my app.js
after running rm -rf resources/public/js/*; lein clean; lein run
:
https://gist.github.com/bmaddy/4c1e92592410836ca13a
My current project.clj
:
https://gist.github.com/bmaddy/3109b23181afba0b13ba
So it calls my -main
method to start the app so I can see what files are served up (and if they're concatenated/minified or not). I thought lein run
and lein repl
compiled everything for you. Somewhere I got the idea that you don't really need to run lein cljsbuild ...
manually anymore, but maybe that's wrong... I'll try lein cljsbuild once app
and see if that changes anything.
Interesting! My resources/public/js/app.js
looks minified now! I'm going to try running it...
yeah, I don't know if cljsbuild
has a lein run
hook, but I wouldn't count on it. Use, lein cljsbuild once app
or read the Quick Start to write a short script with your config.
lein repl
overwrites it also. However, running lein uberjar
after the lein cljsbuild once app
seemed to get the minified code into the uberjar and serving up. It's not running the main method quite right, but maybe I'll get some tips from reading the Quick Start (I haven't looked at that in years...). Thanks a ton for the help @bensu. I think you really got me back on track.
@bmaddy: no problem. I guess the advice is: don't depend on built-in lein
commands like run
, uberjar,
and repl
to manage your ClojureScript. Use your own scripts or cljsbuild
for that.
I sewed together a couple of libraries into https://github.com/bensu/asterion
here is a demo https://www.youtube.com/watch?v=NOJLmkIyS2A
working on some scripting Docs for figwheel https://github.com/bhauman/lein-figwheel#scripting-figwheel
looking for feedback as, while this should and will be my normal workflow it isn't right now
bhauman: i'm sorry, if this question have been asked before. why the reload workflow for figwheel-reload-hook is something like "notified if file changes" -> "load newly compiled files" -> teardown -> setup ? i'm used to clojure's reloaded component style where the reloaded flow is something like teardown -> reload changed clj file -> setup
bhauman: or do i misunderstand the "writing reloadable code" section ? https://github.com/bhauman/lein-figwheel#writing-reloadable-code
https://github.com/bhauman/lein-figwheel/blob/master/support/src/figwheel/client.cljs#L289
Does it make sense to use reagent-forms with re-frame?
@mavbozo: you can use the before js load hook Iinked above. I never use either of them. I try to make the code implicitly reloadable but I understand there is a need for this.
bhauman: noted, i still use lein-figwheel for developing js in conventional multiple-page website, not single page web application with react. Still, the reloadable code concept is awesome cause it makes me aware of so many states i put in the dom.
Anybody knows what’s going on here: http://i.imgur.com/6r855Lw.png Is the source map just wrong?
It’s not the first time it happened, but before it was on my own files.
seems like a Chrome bug to me, Safari and Firefox also support source mapping, I’d be surprised if they showed this
I am experiencing the same error in Firefox (I disabled sourcemaps): http://i.imgur.com/zFaofAF.png
thheller: https://gist.github.com/pupeno/61c62eb81d850cbb35b6 (cljs and js).
what's happening at the bottom?
looks like the file ends twice
@pupeno stuff like this happens if you have two processes writing to the ouput directory at the same time
Ahhh. Doh!