clojurescriptcursive

How to set up the configuration in Cursive for Clojurescript?


Just how to init a new project? How to compile, test and run?

Since the cursive user guide says nothing about cljs.


Solution

  • From the command line use boot or leiningen (also known as lein) to set up your project, then from within IntelliJ go File->Open on the directory for your application and edit the source files that will be collected up in a project for you. An important file to look at is project.clj - that's lein's project file, that IntelliJ will have picked up.

    Setting up a lein cljs project from scratch is explained at Try Figwheel in here.

    Best to use the Chrome browser. With Figwheel as you save the source files you are editing, your viewable changes show up in the browser window (or perhaps in the browser developer's console - good to have that open) you have open.

    So you can just use IntelliJ as an editor. In the background Figwheel will see the changes you have made and if there's an error it will either show up in the 'heads up' display of the browser (i.e. the browser window), or in the console REPL which you have open. From the REPL you can do things like alerts that show up in the browser. All this explained on the Figwheel page...

    There's quite a few moving parts (four altogether - two consoles, an editor and the browser Window). An interesting thing to note is that your FigWheel REPL console (your 'dos box') will be telling you where to open the browser, most likely at http://localhost:3449/.

    Edit
    Here's an alternative way of doing the Figwheel cljs project setup. More recent, and a bit more 'manual' than the 'Try Figwheel' description. Once finished just remove the Om-Next dependency if you don't want it.

    Edit
    Wanted to share that it is now quite possible to have a REPL in Cursive itself, so can confirm there is a better way than the 'dos box'. See Running it in here

    Edit
    Chestnut "beginner friendly Leiningen template for web applications" has just been made up-to-date with the current state of the art.

    Edit (26/04/2017)
    Starting from scratch with Clojurescript