Atom Shell gives you a way to create a desktop(ish) web application which can access your local OS via the Node.js environment and the npm module ecosystem.
This working example presents a way to use all this power with ClojureScript.
There's some Javascript left: bootstrap.js. This file doesn't
require much changes so I see no problem with leaving it as it is.
The rest of the stuff is ClojureScript, and it's in
src/example/core.js. The UI (not much of that :)) uses Reagent.
There are two types of dependencies here:
- Node modules (installed via apm)
- ClojureScript modules (installed via leiningen)
Using Reagent to render HTML demonstrates that leiningen dependencies are working, and using the walk module shows how to use npm modules.
You can get pre-built binaries from here.
To depend on native Node modules
you should use apm. How do you install
the apm package manager? Well, with npm package manager of course :)
npm install apm
(I used the npm 2.7.1 which comes with io.js 1.6.1)
In our example we depend on the native node module "walk", so let's install it locally to our Atom Shell application directory:
apm install .
Note: do not run apm install , it will not work for Atom Shell app.
You need leiningen. Get it from here
Fetch dependencies:
lein deps
To build once, run:
lein cljsbuild once
To build automatically, run:
lein cljsbuild auto
Sometimes you will get nasty "Uncaught Error: goog.require could not find: example.core" errors. Try to delete everything under out/ directory manually and rebuild. Leiningen's clean doesn't do the trick for some reason.
cd to this checkout directory, and run Atom in there:
/Applications/Atom.app/Contents/MacOS/Atom .
(the path to Atom is specific to your OS and Atom installation of course)
There are a few ways to create REPLs with ClojureScript. Unfortunately,
almost all of them require running our generated JavaScript via a page
served by a web server. With Atom
Shell, there's no web server. We are just browsing local files
via "file://" Here
we can see multiple ways to connect a REPL to browser. The only one of
these that works somewhat is the Rhino one:
lein trampoline cljsbuild repl-rhino
And that can't run our Node environment properly. We can't, for example, require a node module and use it since we are inside Rhino/JVM.