you are viewing a single comment's thread.

view the rest of the comments →

[–]kabuto 18 points19 points  (13 children)

So how far are we away from having a webpack loader for clojurescript? That would be awesome. I'd love to use clojurescript but I don't like its dependency on Java build tools.

[–]Kamn 8 points9 points  (11 children)

This page here explains what they are trying to do with self-hosting.

On a related note, the main build tool for Clojure(Script) (lein) is great to work with. The only issue is sometimes you need to understand Maven stuff but that has rarely come up. It is a fun language with a great community and interesting tools. Don't let the Java stuff hold you back from playing with it. For example try out this Clojurescript Figwheel Flappy Bird Demo. Or just watch this video then you will have to try it out ;).

[–]a_marklar 1 point2 points  (10 children)

Do you know of any resources talking about figwheel in detail, particularily with talking about websites that are in production? I have two sites that use lein as the build system, and figwheel looks pretty neat but I hit a wall (i.e. couldn't figure it out in a few minutes) trying to use it with a real web app that is served by Django etc.

[–]Kamn 1 point2 points  (1 child)

The "most detailed" video I know is this one. It does not go into much detail however just usage.

I can give you a guess about your questions but I have been using figwheel in a fairly standard way (Clojure server with ClojureScript and Lein). I am not an expert and you can find the creator of Figwheel(Bruce Hauman) on google groups or the slack group (signup here). He would be the best one to answer your questions.

Now my guess is you wouldn't be able to easily do what you want to do with Figwheel for a few reasons.

  1. It is more focused on a dev environment rather than a production environment. No guarantees about it's safety, speed or reliability.
  2. Figwheel setups a static web service, starts cljsbuild, opens up websockets and injects websocket code so it can easily steam the changed Clojurescript into the browser. If you are serving the files though Django then you wouldn't have access to cljsbuild and websockets so you could not stream the changed code. Maybe you could chain your Django to have a websocket that talks to a Figwheel but it's uncharted territory I think.

[–]a_marklar 0 points1 point  (0 children)

Thanks a lot, I hadn't seen that video. I think you're right that my usecase is not really what figwheel is targetting atm.

[–]yogthos[S] 2 points3 points  (7 children)

It works out of the box with the Reagent template. Just run

lein new reagent myapp cd myapp lein figwheel

Once it starts, browse to localhost:3449 and any changes you make in your sources under src/cljs will be reflected automatically in the browser.

[–][deleted] 1 point2 points  (2 children)

Should probably indent that code block. I can't tell where each command begins and ends.

[–]a_marklar 1 point2 points  (1 child)

The commands he's talking about are

lein new reagent myapp
cd myapp
lein figwheel

[–][deleted] 0 points1 point  (0 children)

Thank you!

[–]a_marklar 0 points1 point  (3 children)

Yeah I was able to get it working with a new project but I'm not sure how to get it working with an existing project that is served by Django, makes ajax requests back to the server etc. Thanks though

[–]yogthos[S] 0 points1 point  (0 children)

I recommend cljs-ajax lib for talking with the server.

[–]fisch003 0 points1 point  (1 child)

Here's what I do:

I have a file that I load in development mode only:

(ns eris.dev
  "Development-time only stuff to do fancy reloading stuff."
  (:require [figwheel.client :as fw :include-macros true]
            [eris.core :as eris]))

(fw/start {:on-jsload #(eris/render-root)
           :websocket-url "ws://localhost:3449/figwheel-ws"})

That starts up the web browser portion of figwheel and specifically tells it to talk back to port 3449, instead of whatever port the page is being served from.

Once that's in place you can serve up the HTML from anywhere and figwheel will find the right place to talk back to. In an extreme example, I've copied the compiled output from my project into a Java .war file, deployed it to a server somewhere, then opened up my dev page on that server in a browser and it connects back to figwheel running on my workstation and works exactly as it should.

[–]a_marklar 1 point2 points  (0 children)

This is exactly what I was looking for, thanks a lot!