Fork me on GitHub
#clojurescript
<
2015-06-19
>
mfikes00:06:11

@dnolen: Wait… so the .cljc file, when interpreted as :cljs requires itself which is then interpreted as :clj to grab the macros in it?

razum2um00:06:39

@dnolen: so macroses are possible without clj/jvm?

mfikes00:06:59

Damn. Reminds me a bit of Enum<E extends Enum<E>> for some reason. Beautiful.

razum2um00:06:49

or jvm is still needed to expand maroses and they are loaded back into same ns?

dnolen00:06:48

There some backlog from yesterday or before that explains macros in bootstrapped context

andrewhr01:06:17

@dnolen: this meta-thing is beautiful, really

andrewhr01:06:26

call me crazy

mfikes01:06:36

@razum2um: Also, the current (Clojure/JVM) ClojureScript compiler will be able to compile its own implementation into JavaScript. That (JavaScript) analyzer/compiler implementation won't be able to again compile the original implementation source, if I'm understanding correctly.

mfikes01:06:28

So, with ClojureScript JS, so long as you play by the rules and keep macros in separate files from runtime code files, it sounds like you will be able to use ClojureScript JS to compile things, right?

roberto02:06:09

Is there a way in Reagent to trigger an event on another element? I’m trying to accomplish this http://stackoverflow.com/posts/12035542/revisions

mfikes02:06:36

Perhaps in the future .cljc will find new use in writing ClojureScript macro files that are portable between ClojureScript JVM and ClojureScript JS. (For macros that use host interop when executing.)

roberto02:06:39

Trying out the google closure way, but was wondering if Reagent has some utility functions to do this.

bostonou03:06:27

@roberto: I believe react (and thus reagent) doesn't provide a public api for triggering events programmatically. There is supposed to be code that simulates events for testing, but I don't know if it's appropriate for user facing production code

danielcompton05:06:12

What do people do for environment variables in ClojureScript?

gonzih07:06:10

@danielcompton: you can use macro and read env variables in there. And can propogate value to clojurescript or do something based on this value with macro arguments.

danielcompton07:06:48

Ahh that makes sense

borkdude08:06:57

@danielcompton: I also use different src folders for dev and prod, so I can have some dev or prod settings

estsauver08:06:03

Hey There, I’m getting started with Sente and I’m coming across a Websocket error. WebSocket connection to '<ws://localhost:3000/chsk?client-id=93475a0e-107e-4807-a6a7-1e34b712b737>' failed: Invalid frame header encore.cljs: Anyone happen to know if I should be looking at HttpKit or Sente to track this down?

gonzih08:06:15

@borkdude: is there figwheel for boot?

borkdude08:06:46

@gonzih: the reload task is the equivalent for reloading assets

gonzih08:06:55

and for repl?

borkdude08:06:36

@gonzih: cljs-repl is the task for that

gonzih08:06:02

ok, makes sense, will need to migrate my project some day simple_smile thanks!

danielcompton08:06:04

@estsauver: have you tried the initial example?

borkdude08:06:20

@gonzih: the boot tasks seem to be more decomplected, whereas figwheel is more a monolith

estsauver08:06:27

@danielcompton: Got that error adding the readme to my project.

estsauver08:06:51

I’ll try adding the example with no changes.

borkdude08:06:53

@gonzih: I'm still using leiningen and figwheel though, nothing wrong with it, works great

gonzih08:06:12

@borkdude: of course, but new shiny things, you know simple_smile

borkdude08:06:24

@gonzih: javascript mentality 😉

estsauver08:06:08

@danielcompton: still getting the Opcode -1

danielcompton08:06:39

@estsauver: just from running the example project?

gonzih08:06:43

@estsauver: if you get error with raw exapmle project please report issue to the sente project. might be related to your setup or might be that example is outdated. hard to tell.

estsauver08:06:12

Not from running the example project, from copying the code from the readme into my project. The bare example project works.

gonzih08:06:27

@estsauver: then it's your setup simple_smile

estsauver08:06:00

Agreed, I was hoping someone had seen something of this ilk before.

acron08:06:58

I recently put sente into a project and never saw that issue 😞

Petrus Theron08:06:49

How can I embed Figwheel reload JS without transforming index.html, or hosting my HTML with jetty/figwheel? Is there a static bit of JS I can include in my index.html?

thheller08:06:45

@petrus the reloader needs a connection to a server that tells it when something has changed

Petrus Theron08:06:08

ok that makes sense

thheller08:06:07

the browser cannot check the filesystem itself

Petrus Theron08:06:23

Created a new project from reagent template, but I'm not seeing in-browser reloads. Code reload seems to be working, but I have to manually refresh my browser. Am I missing some JS include?

Petrus Theron08:06:03

In console I can see

Figwheel: trying to open cljs reload socket
Figwheel: socket connection established

thheller08:06:15

I don't use figwheel so I cannot help you there, sorry.

Petrus Theron08:06:41

How do you do your frontend dev? Do you refresh every time you change something?

thheller08:06:38

well, it's complicated. simple_smile

gonzih08:06:20

@petrus you need to call reagent/render again to mount new components

Petrus Theron08:06:20

got it working. Mismatched ports.

Petrus Theron09:06:50

Running lein with-profile dev run works, but if I try to run a REPL, I get this error:

#error {
 :cause Could not locate qt/dev__init.class or qt/dev.clj on classpath.
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message java.io.FileNotFoundException: Could not locate qt/dev__init.class or qt/dev.clj on classpath., compiling:(qt/repl.clj:1:1)
Where my project is named qt. Did I mess up my project.clj file?

Petrus Theron09:06:08

- seen when running lein repl or lein with-profile repl.

gonzih09:06:17

@petrus check your repl entry point configuration (namespace that should be loaded by default in relp)

estsauver09:06:54

@gonzih: WS connection was getting wrapped by a middleware. Fixed it.

estsauver09:06:14

@danielcompton: Thanks you two for the rubber ducky debugging.

Petrus Theron09:06:41

@gonzih, where should I look? Is this it:

:cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]
                                              :compiler {:main "qt.repl"
                                                         :source-map true}}
                                        }
                               }}

gonzih09:06:41

@petrus looks like you have naming issue, can you should me content of env/dev/cljs folder?

Petrus Theron09:06:02

It was set to qt.dev, which seems right. Probably shouldn't be looking at :cljsbuild,. Higher up in project.clj:

:profiles {:dev {:repl-options {:init-ns qt.repl
                                  :nrepl-middleware []} ... 

Petrus Theron09:06:23

I have a file at ~/env/clj/qt/repl.clj which has namespace qt.repl

gonzih09:06:44

what is your source-path configuration for lein project?

gonzih09:06:15

there is cljs specific configuration for compiler and clojure specific in lein configuration

gonzih09:06:43

looks like lein can't find qt.dev namespace that is required in qt.repl

gonzih09:06:53

is qt.dev clojure namespace and not clojurescript?

Petrus Theron09:06:45

qt.repl is clj namespace. qt.dev is cljs. Think I fixed it. I had (:use ... qt.dev ...) in my qt.repl namespace

gonzih09:06:00

now you know what this compiler error means simple_smile

jrychter09:06:45

Does anybody know if serving stuff out of resources incurs a (noticeable) performance penalty? I really like the fact that I can deploy a single jar, but I wonder if there are hidden dragons and tarpits somewhere?

thheller09:06:38

@jrychter: you have to restart your server to serve "new" javascript 😉

martinklepsch09:06:50

@jrychter: I’d be surprised if so. I mean it’s really all just files in jars right?

jrychter09:06:38

@thheller: well, I have to do that anyway, usually new JavaScript means API changes on the server side. @martinklepsch: something could (for example) reopen the jar and unzip it on every access. I don't know.

borkdude09:06:06

FYI: If you want to use figwheel with the newest cider-nrepl 0.9.0 do this: [lein-figwheel "0.3.3" :exclusions [cider/cider-nrepl]]

martinklepsch09:06:24

I tend to serve JS and CSS via S3, just so much easier to deploy simple_smile

borkdude09:06:51

@martinklepsch: any advice on gzip on s3? last time I looked at it, it seemed pretty clunky

thheller09:06:19

@jrychter: I can constantly update client side only stuff (cljs, css, images ...) and have a deploy script that only restarts the server if any .clj changed

martinklepsch09:06:34

you gzip, supply Content-Type and Content-Encoding metadata and be done simple_smile

thheller09:06:37

at least half of my deploys do not require server restarts

jrychter09:06:42

I am scared of touching my (barely working) cider installation. I dream of the day when all the REPL stuff will come together and there will be a single stable solution… (though I suspect that will mean a singularity and the end of the world as we know it).

borkdude09:06:03

@martinklepsch: that doesn't sound too difficult simple_smile

martinklepsch09:06:07

@borkdude: if you want to support clients that do not accept gzip, you’ll need some extra handling selecting which files to load

martinklepsch09:06:01

@borkdude: boot-clj FTW haha

(deftask s3-deploy []
  (comp
   (gzip :files {"app.js"  "app.js.gz"
                 "app.css" "app.css.gz"})
   (s3p :secret-key ""
        :access-key ""
        :bucket ""
        :put {"app.js.gz"    "app.js"
              "app.css.gz"   "app.css"})))

jrychter09:06:50

@martinklepsch: wow, that looks useful. I'm thinking about switching to boot.

borkdude10:06:20

@martinklepsch: the handling of non-gzip files, do you do that in ring, to direct them at the right s3 file?

martinklepsch10:06:24

@borkdude: tbh, in that particular project I didn’t care enough to set it up, can’t find recent stats on accept-encoding headers but I’d guess it just works 99.9% of the time

borkdude10:06:38

thanks for your honesty 😉

Petrus Theron10:06:57

Routing with secretary: I want to highlight the current menu item if the route matches. How do I ask secretary if "this url" matches a particular route without dispatching to that route?

borkdude10:06:24

@petrus: just (defroutes "....." [] ...)?

Petrus Theron10:06:23

Given (defroute users "/users/:id" [] ...), something like, (find-route "/users/1234") => value of users-route. In my navbar I render links like [:a {:href (users-route)} "Users"] and I'd like to add an .active class when the current url matches that route.

Petrus Theron10:06:28

secretary.core/locate-route-value looks like it might be it.

borkdude10:06:53

@petrus: what does locate-route-value return?

borkdude10:06:25

@petrus: usually I just save some state inside defroute to remember which route is currently being shown

Petrus Theron10:06:38

it's pretty short:

(defn locate-route-value
  "Returns original route value as set in defroute when passed a URI path."
  [uri]
  (-> uri locate-route :route route-value))
Yeah that sounds simple too.

borkdude10:06:40

@petrus: including the parameters

borkdude10:06:02

@petrus: yes, I looked at it, but I still wondered what does it return and what can you do with it

martinklepsch10:06:00

@borkdude: regarding ring: I would probably make the html response contain either a link to the S3 file that’s gzipped or not. (no redirects)

martinklepsch10:06:15

@jrychter: well, if you have any questions etc, there’s #C053K90BR simple_smile

borkdude10:06:41

@martinklepsch: that's how I'd do it too, or configure it in nginx somehow

martinklepsch10:06:38

@borkdude: how would you do it with nginx without redirects? modify response with some regex type thing?

borkdude10:06:09

@martinklepsch: I'm not sure, haven't tried it

borkdude10:06:51

@martinklepsch: maybe this is why I haven't tried S3 gzip before, it still sounds more work than just nginx gzip

borkdude10:06:14

@martinklepsch: provided your assets don't really have to be on s3

martinklepsch10:06:44

yeah, if you don’t want/need CDN probably nginx gzip is just fine. I personally just really like the lack of any maintenance w/ S3 simple_smile

jrychter10:06:05

Just wanted to say that what @shaunlebron is doing for cljs documentation is fantastic. I already use the Dash.app docs regularly (one of the first versions), and just saw https://github.com/shaunlebron/ClojureScript-Syntax-in-15-minutes which looks great for bringing new people up to speed.

martinklepsch10:06:58

:thumbsup: also very happy with the Dash.app docset! simple_smile

jrychter10:06:25

Is an "official" version coming? I'd love to be able to use it on my iOS Dash, too. (answering myself: just found it in the "User Contributed" section, not sure if it works on iOS)

borkdude11:06:02

where can you get the Dash.app docset?

martinklepsch11:06:06

In the User Contributed section.

borkdude11:06:54

cool, I didn't know about Dash before

borkdude11:06:13

this is really useful for development during commute (no wifi)

martinklepsch11:06:00

yep, it’s really handy. And there are tools for Windows and Linux that can make use of the same docset format I believe simple_smile

vschepik11:06:33

Is there something like Node-Webkit (NW.js) for building desktop apps with Clojure and ClojureScript? Some JVM-Webkit pairing?

gonzih12:06:28

@vschepik: you can just use node-webkit or atom or something else

gonzih12:06:39

js interop should be your friend in that case

gonzih12:06:29

@mikethompson: that is super cool!

vschepik12:06:00

@mikethompson: That’s nice but what I am looking for is something where I can use Clojure on the JVM and distribute it together with the cljs node webkit GUI. That way I could do heavy stuff like data analysis in Clojure and the GUI in CLJS/Webkit. The data analysis part needs to parse large files and transform the data. The GUI would visualize it.

gonzih12:06:07

@vschepik: I think your node-webkit gui can start clojure server and communicate with it using web sockets for example

mikethompson13:06:15

@vschepik: If you want to see an Electron app (alternative to NW.js) running JVMs look at Cuttle: https://github.com/oakmac/cuttle

mikethompson13:06:56

Electron (formerly atom shell) apps are a little harder to code than NW.js apps because there is a proper separation between "nodejs bit" and "chromium bit", but the full split has benifits.

vschepik13:06:26

@gonzih: I am looking for an integrated solution but thanks for the hint.

mikethompson13:06:32

@vschepik: an integrated solution seems impossible to me.

mikethompson13:06:08

Electron and NW.js are nodejs combined with Chromium. There's no JVM in sight.

vschepik13:06:23

@mikethompson: Looks very interesting. I am open for alternatives to NW.js and Electron sounds interesting. I will definitely check Cuttle.

mikethompson13:06:05

As @gonzih suggests you'll have to run the JVM as a seperate process and talk via some means ... for example websockets.

mikethompson13:06:50

One sneaky approach is to try and run the JVM as an applet within Chromium. But that has a very limited life given applets are being dropped in the near future. And anyway, it probably won't do what you want.

vschepik13:06:26

@mikethompson: Yes, an applet is very restricted as far as I remember when I worked with applets many years ago.

mikethompson13:06:24

Indeed. But that is the only way I can imagine a "fused" JVM and NW.js thing happening.

mikethompson13:06:48

Other than that, you'll have to get your NW.js (or Electron) process to start a separate JVM process.

mikethompson13:06:28

Good luck simple_smile Cuttle will be a really good resource if you go that way.

vschepik13:06:31

@mikethompson: Thanks simple_smile Perhaps it is sensible to use a Webkit component in a Java GUI window. But than the question is if it provides some API integration between JavaScript and the JVM. I build once something similar with Qt which provides a nice integration between JavaScript running in a Webkit control and C++.

mikethompson13:06:45

@vschepik: JavaFx2 has a webkit component of some description. No idea how capable it is. Someone on the #C03S1KBA2 channel might have an idea.

vschepik13:06:00

@mikethompson: I will have a look at it. Seems to become a challenge simple_smile

dnolen13:06:26

huzzah ClojureScript can now compile its own macros file w/o error. Still more to do but cool simple_smile

gonzih13:06:27

@dnolen: that is amazing news! simple_smile

micah15:06:07

I'm getting errors using cljsbuild with new clojurescript (1.7). Is cljs.build.api the preferred way to build now?

dnolen15:06:32

@micah: haven't heard of issues need more info

micah15:06:33

@dnolen: I get No such var: ana/forms-seq*

micah15:06:07

am trying to get Speclj converted to reader conditionals instead of cljx.

micah15:06:26

ironic that the example on http://dev.clojure.org/display/design/Reader+Conditionals use speclj code.... I'm just working on conversion now

micah15:06:21

pushed code that demonstrates problem: https://github.com/slagyr/speclj/tree/clj17 $ lein cljsbuild once dev

shaunlebron15:06:33

@jrychter: if you use the docset from user-contributed section, it’ll auto-update. I update it pretty often

jrychter15:06:57

@shaunlebron: I switched to it now. Thanks for your work!

shaunlebron16:06:11

thanks, I’m so close to getting usage examples, and cross-refs; it’ll be a lot more useful soon

shaunlebron16:06:49

just trying to create the workflow for merging manual docs with the generated ones

jrychter16:06:51

@shaunlebron: I have a suggestion, btw. I'd move the box with the ClojureScript file hierarchy down to the bottom, as I think it is the least useful one to someone accessing the docs with Dash. The description, then the source, and then the map (though I'm not quite sure how it's useful, either).

shaunlebron16:06:47

I agree, I’ve been finding the file hierarchy takes too much space

shaunlebron16:06:31

the map is useful for me currently so I know the data that generated the markdown file

jrychter16:06:13

And BTW, now the Clojure docs in Dash look dated… 😄

shaunlebron16:06:16

well, they’re concise. I like that it does what it aims for

shaunlebron16:06:14

this is just an intermediate view of the docs btw, it’ll look like this eventually in some form: http://oakmac.com/cljs.info/docs/cljs.core/bit-and

jrychter16:06:20

I wish there was a way to find, for example clojure.string/replace. Right now I think the only way is to find the clojure.string namespace and then click on "replace"

shaunlebron16:06:05

haha, bummer, I took the namespace out of the search key on your request, lol

shaunlebron16:06:23

but I see the benefit of having that as an option

jrychter16:06:42

😄 — well, you know how it is with users. But really, I am mostly surprised that just typing "replace" doesn't find string/replace.

dnolen16:06:12

@micah double check your assumptions. lein deps :tree first. Start a ClojureScript REPL and check clojurescript-version next

jrychter16:06:18

@micah: I saw this error recently, when trying to update to newer versions of libraries and tools. I think it was when trying to launch nrepl in figwheel, but I'm not sure anymore. I decided it isn't worth the effort after all.

shaunlebron16:06:27

jrychter: if you click the cljs logo by the replace search result, you’ll get the duplicates

dnolen16:06:30

The error implies you have the wrong version of ClojureScript

jrychter16:06:07

@shaunlebron: oh, that's better, nice! And I just noticed that shift-enter will open the duplicates window, too. That's basically what I wanted — I don't actually want to type the full namespace.

micah16:06:42

@dnolan ok, working on it

martinklepsch16:06:59

@shaunlebron: the http://cljs.info preview looks really nice!

micah16:06:43

@jrychter: I got this error with figwheel too. I think it fixed that one by reverting to an older version of clojurescript (the figwheel author's recomendation)

dnolen16:06:31

This is just guessing. I never encounter these kinds of problems with Maven + bash scripts

shaunlebron16:06:00

@martinklepsch: it’s a start, it’s @chrisoakman’s mockup

dnolen16:06:08

All the cljsbuild corner cases are crazy

micah16:06:00

@dnolen: does the following imply wrong clojurescript version too? clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate cljs/util__init.class or cljs/util.clj on classpath: , compiling:(cljs/closure.clj:1:1)

dnolen16:06:19

you need Clojure 1.7.0 to use ClojureScript

dnolen16:06:29

I already mentioned checking lein deps :tree

dnolen16:06:39

latest ClojureScript I mean

micah16:06:56

Yeah, been checking deps. Looks like right version to me: https://gist.github.com/slagyr/d05ba187f03c5ab19c04#file-gistfile1-txt-L15

dnolen16:06:48

step 2 - paste the entire stacktrace simple_smile

dnolen16:06:01

that error can only happen if you’re not actually getting Clojure 1.7.0 somehow

dnolen16:06:41

I suspect some crazy plugin is loading Clojure 1.6.0 but attempting to share the ClojureScript version in your project.

roberto16:06:15

I had to exclude clojure and tools.reader from ring-middleware-format when I upgraded

micah16:06:40

@dnolen: Okay... that was helpful. :eval-in :leiningen looks like the trouble maker

micah16:06:51

@dnolen: Thanks for the help! cljsbuild works once again. But I'm still curious... do you recommend using cljs.build.api over cljsbuild? Now that I've got a custom build script using cljs.build.api, I'm appealed by it's simplicity.

dnolen16:06:31

I’m not the person to ask about cljsbuild, I don’t use it for app development only library development where the dependencies are highly controlled - also zero plugins

dnolen16:06:52

so I don’t encounter these problems often, and when I do I want to break my computer simple_smile

dnolen16:06:01

for Cognitect stuff only Maven + bash

dnolen16:06:23

but that’s not true for everyone at Cognitect, just me

micah16:06:38

Oh, I see. Interesting... no leiningen? You prefer XML?

dnolen16:06:51

No I prefer not encountering crpytic bugs

dnolen16:06:55

XML is a small price to pay

roberto16:06:48

maven isn’t that bad simple_smile

roberto16:06:19

i have more issues with ruby gems and python pip than with maven

Petrus Theron18:06:52

I'm having a hard time getting a browser-repl working with Cursive.

Petrus Theron18:06:33

I made a new project from the regent template and when I run lein figwheel I can issue commands in browser from this repl, but I'd like to be able to evaluate forms from Cursive in the browser. What am I doing wrong?

dnolen18:06:47

@petrus you cannot use lein in that way to run a figwheel REPL

dnolen18:06:13

@petrus if you’re familiar with the Quick Start you need a figwheel REPL script, same as any other plain CLJS REPL

arohner19:06:29

yay for reading chat history...

sherpc19:06:03

Hello all! I have idiomatic question about re-frame. What is the best practice creating forms in re-frame? As example simple case -- login/register form in big SPA application (with validation, etc.)

sander19:06:06

is there a way to make node.js automatically reload namespaces recompiled by cljs.build.api/watch? in particular, i'm running a web server in node.js and would like for url handlers to be reloaded as soon as i change them

sander19:06:48

i'm also ok with watch auto-killing and restarting node.js

sander19:06:14

maybe figwheel meets the first scenario?

dnolen19:06:32

@sander: I was under the impression Figwheel supported Node.js

sander19:06:36

@dnolen: ok thanks, let's try then simple_smile wasn't sure whether that was still about reloading within the browser (but from a node web server)

dnolen19:06:25

ClojureScripts supports reloading in a variety of contexts, I assume Figwheel rides on that but would need to ask @bhauman to be sure

cfleming20:06:51

@dnolen: @sander: Figwheel does support node.js, it’s just better understood in a browser context.

cfleming20:06:00

@petrus: You can either run the figwheel REPL over nREPL (instructions are here: https://cursiveclojure.com/archive/1081.html#1082), or using a plain clojure.main REPL (gist here: https://www.refheap.com/101322, not properly written up yet, sorry)

mfikes20:06:26

@sander: Figwheel's the best route, but if you need another option, cljs REPLs support :watch and :watch-fn. Was able to imitate the basic functionality of Figwheel with this: http://blog.fikesfarm.com/posts/2015-05-30-poor-mans-figwheel-for-ambly.html

sander20:06:14

mfikes: nice clear example, thanks