Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 532
speedcell4 Avatar asked Dec 16 '15 06:12

speedcell4


People also ask

Do I need a web browser to use ClojureScript?

Note that the requirement of a web browser excludes headless environments, and we then recommend skimming to the Node.js portion of the tutorial. In this tutorial we will guide you through compiling and running a simple ClojureScript project, as well as running REPLs to interactively develop and test your code.

What do I need to install Clojure on my computer?

If you are using macOS or Linux the only dependencies required for the main part of this tutorial are a web browser and an installation of Clojure. On Windows you will need Java 8 and the standalone ClojureScript JAR.

How big is the ClojureScript library?

If you zip this file you’ll see that it’s around 20K. This is significantly smaller than a jQuery dependency yet when using ClojureScript you have implicit dependencies on the entire ClojureScript standard library (10KLOC) and the Google Closure Library (300KLOC). You can thank dead code elimination.

Where can I find the cursive settings in IntelliJ?

All Cursive settings are searchable in this way. To describe where to configure something in the IntelliJ settings, we'll describe them like this: Settings→Plugins. This means to open the settings and then to select the "Plugins" configuration panel from the list on the left.


1 Answers

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

like image 80
Chris Murphy Avatar answered Oct 22 '22 23:10

Chris Murphy