Fork me on GitHub
#clojurescript
<
2015-10-08
>
mfikes01:10:36

@settinghead: One limitation is that :advanced Google Closure optimization is not supported by the bootstrapped compiler

maria01:10:39

@mfikes: Not just :advanced, but also :whitespace and :simple shouldn't work, right?

mfikes01:10:57

@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

maria01:10:18

But how can :simple work without Google Closure? Or do you mean initially when compiling a project which uses cljs.js?

mfikes01:10:16

@maria: Very good point… I haven’t even explored anything other than :none.

mfikes01:10:07

@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.

maria01:10:46

that makes sense simple_smile

mfikes01:10:12

@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)

mfikes01:10:01

@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. simple_smile

mfikes01:10:51

This makes me wonder what Joel Martin is using for http://clojurescript.net

maria01:10:32

@mfikes: Do you know why :optimize-constants is not listed on the wiki page for the compiler options?

mfikes02:10:14

@maria: I have deja vu wondering the same thing several months back when David mentioned it. Probably an oversight

dnolen03:10:00

Bootstrapped only generates :none. You can apply Closure yourself on the results

maria05:10:08

@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

wildermuthn05:10:21

@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.

wildermuthn05:10:54

ThreeJS works, so thinking maybe there’s something simple about Quil that needs work, but haven’t had much luck.

yusup05:10:59

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

yusup05:10:53

is this leiningen related issue?

yusup05:10:12

'lein new chesnut ss'

yusup05:10:43

Tested on various machines, the same result

wildermuthn05:10:46

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.

redbeardymcgee05:10:42

@yusup: could be a lein problem, i'm still on 2.4.3 and that command ran just fine

bensu08:10:40

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.

thheller09:10:18

@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

thheller09:10:55

REPL won't work either

oskarth09:10:17

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?

thheller09:10:21

@oskarth: pretty sure that is not possible at the moment

maria09:10:48

@thheller: Why do you think that it would break incremental compilation and the REPL?

oskarth09:10:21

thheller: It must be, if I run (println "foo") in the terminal process it shows up there (and in the browser console, of course).

oskarth09:10:39

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

thheller09:10:56

@oskarth you are correct, calling (figwheel.client/enable-repl-print!) seems to enable that.

oskarth09:10:44

hm, when I run that I get a no print-fn set for evaluation env, which makes sense, but nothing is printed in repl

oskarth09:10:33

Unable to parse print-fn js output

thheller09:10:52

@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.

thheller09:10:32

@maria but I just realized that constants are no longer numbered so that might actually work now

thheller09:10:21

@maria forgot that http://dev.clojure.org/jira/browse/CLJS-1086 made it into core some time ago

oskarth10:10:01

@thheller: got it to work! needed to change println to use custom figwheel printer

oskarth10:10:22

so now it's just a matter of fixing the weird spacing in the printing and writing a toggle-log fn. Thanks simple_smile

oskarth10:10:56

for some reason the println didn't work for me with an xhr req, not sure why

oskarth10:10:59

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

oskarth10:10:08

but just guesses. is @bhauman here?

maria10:10:31

@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.

thheller10:10:30

@maria yeah, the situation improved after constants received stable names but things are still weird is many cases

thheller10:10:55

I'd definitely advise against using them unless it is :advanced

thheller10:10:07

I experimented with emitting the constants when they are first encountered but that turned out way more difficult and error prone than I anticipated

thheller10:10:17

especially due to all the REPL stuff

maria10:10:46

@thheller: cool, thank you for clarifying simple_smile should probably add this to the compiler options wiki page that it is only recommended to use :optimize-constants for your release build.

thheller10:10:35

@maria yeah I fought many battles with constants, definitely best to keep people out of that as much as possible

thheller10:10:53

but everything is much better now since the worst issues were fixed

oskarth10:10:33

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.

maria10:10:55

@oskarth: great that you got it working 😉

dnolen12:10:48

@maria looks great! thanks

maio12:10:53

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?

dnolen12:10:58

@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

maio12:10:39

@dnolen: there are just 2 functions in this file. 😕

dnolen12:10:32

@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.

maio12:10:13

@dnolen: ok, thanks anyway. I'll try to dig into it a little.

ricardo13:10:02

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.

mahinshaw14:10:09

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 '$'?

thheller14:10:49

@ricardo: try setting the munged name as it ends up in js {:closure-defines {"the_app.core.api_url" ...}}

ricardo14:10:14

@thheller: I’d tried that, no dice.

thheller14:10:10

did you verify that it ends up in the js?

thheller14:10:00

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?

ricardo14:10:46

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.

thheller14:10:24

no :none is the only thing that does NOT use the closure compiler

ricardo14:10:29

@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.

thheller14:10:56

so you are on :none?

ricardo14:10:03

I am on :whitespace

thheller14:10:53

just checked, :none should work

thheller14:10:18

but probably only with :main

thheller14:10:52

can you try :none? makes it easier to debug

thheller14:10:38

oh an which version? I remember something changed very recently that stopped defines from working

bensu14:10:18

@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.

mahinshaw14:10:25

@bensu Ok, so this an om idiom then (or google closure)?

bensu14:10:26

I think it's a google closure idiom

ricardo14:10:39

@thheller: Currently on 1.7.122. Let me try :none soon and see what happens.

dnolen15:10:27

@mahinshaw: @bensu: it’s not an idiom simple_smile

dnolen15:10:56

React requires dynamic objects for props, so Om does this to avoid issues with advanced optimizations

dnolen15:10:43

more importantly that stuff is implementation details

mahinshaw15:10:47

@dnolen: So this is used to keep the name from getting clobbered?

dnolen15:10:53

you shouldn’t be using any of those properties

dnolen15:10:59

@mahinshaw: rewritten not clobbered

mahinshaw15:10:10

right, that makes sense

mahinshaw15:10:06

I wasn't thinking I would use the properties, I was just curious of the significance of the $

dnolen15:10:17

there is none

dnolen15:10:34

private stuff with weird naming conventions is all

mahinshaw15:10:37

@dnolen: Appreciate the insight

bmaddy15:10:54

@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

bensu15:10:26

@bmaddy: why lein run? I thought you would be running lein cljsbuild once app

bmaddy16:10:08

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.

bmaddy16:10:52

Interesting! My resources/public/js/app.js looks minified now! I'm going to try running it...

bmaddy16:10:24

Hmm, lein run seems to overwrite it with the unminified version. Trying lein repl...

bensu16:10:25

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.

bmaddy16:10:50

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.

bensu16:10:38

@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.

bensu17:10:01

I sewed together a couple of libraries into https://github.com/bensu/asterion

bensu17:10:19

if anybody has feedback, I'd love some.

bhauman17:10:02

@dnolen: let me know if this fits the bill ^

bhauman17:10:32

looking for feedback as, while this should and will be my normal workflow it isn't right now

mavbozo17:10:52

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

mavbozo17:10:13

bhauman: or do i misunderstand the "writing reloadable code" section ? https://github.com/bhauman/lein-figwheel#writing-reloadable-code

bhauman17:10:55

@mavbozo: the reload hook fires after changes, you are reading the section correctly

bhauman17:10:09

@mavbozo: there is a before reload hook as well.

pupeno17:10:08

Does it make sense to use reagent-forms with re-frame?

bhauman17:10:29

@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.

bhauman18:10:25

@mavbozo: React components can be used similary to Stuart's components.

mavbozo18:10:12

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.

bhauman18:10:17

@mavbozo: very cool, I get it. component now works in cljs which is pretty darn cool

pupeno18:10:04

Anybody knows what’s going on here: http://i.imgur.com/6r855Lw.png Is the source map just wrong?

dnolen18:10:58

@pupeno: not wrong, that doesn’t even make sense. Looks like a JS syntax error.

pupeno18:10:59

It’s not the first time it happened, but before it was on my own files.

dnolen18:10:20

seems like a Chrome bug to me, Safari and Firefox also support source mapping, I’d be surprised if they showed this

pupeno18:10:10

I am experiencing the same error in Firefox (I disabled sourcemaps): http://i.imgur.com/zFaofAF.png

thheller18:10:59

can you gist the datepicker.js?

mcgivernsa18:10:01

what's happening at the bottom?

mcgivernsa18:10:06

looks like the file ends twice

thheller18:10:25

yeah that repeated stuff at the bottom is odd

thheller18:10:28

should not be there

dnolen18:10:27

@pupeno stuff like this happens if you have two processes writing to the ouput directory at the same time

pupeno18:10:54

Ahhh. Doh!