Code Monkey home page Code Monkey logo

cljs-noderepl's Introduction

cljs-noderepl

Provides a ClojureScript REPL running on Node.JS.

Requirements

You must have Node version 0.8.x or higher installed.

Leiningen Plugin

To setup the Leiningen plugin, add this to your project.clj or ~/.lein/profiles.clj:

:plugins [[org.bodil/lein-noderepl "0.1.11"]]

Then, start the REPL like this:

$ lein trampoline noderepl

In-Project Usage

Add the following dependency to your project.clj:

[org.bodil/cljs-noderepl "0.1.11"]

To launch the REPL the hard way, run lein repl and enter the following:

(require '[cljs.repl :as repl] '[cljs.repl.node :as node])
(repl/repl (node/repl-env))

Environment

The REPL is connected to a live Node process running a sandboxed environment, which provides all of Node's available global variables.

As an example, here's the standard Node hello world, in REPL ready ClojureScript:

(let [http (js/require "http")
      handler (fn [req res] (.end res "Hello sailor!"))
      server (.createServer http handler)]
  (.listen server 1337))

Readline Support

If you have rlwrap installed, the following provides basic readline and paren matching support:

rlwrap -r -m -q '\"' -b "(){}[],^%3@\";:'" lein trampoline noderepl

nREPL With Piggieback

You can get cljs-noderepl running on an nREPL server through Piggieback, though it's a bit fiddly. Here's how.

Add the cljs-noderepl dependency to your project.clj (it will bring in Piggieback transitively):

[org.bodil/cljs-noderepl "0.1.11"]

You may want to add this dependency to your :dev profile so it's not carried along when you deploy your library/application.

Then, add the Piggieback nREPL middleware, also in project.clj:

:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}

Now, launch nREPL through Leiningen as usual - lein repl - and connect to it from wherever you prefer. You'll need to start the ClojureScript REPL manually once you have a Clojure REPL prompt:

user=> (require '[cljs.repl.node :as node])
user=> (node/run-node-nrepl)

License

Copyright © 2012 Bodil Stokke.

Distributed under the Eclipse Public License, the same as Clojure.

cljs-noderepl's People

Contributors

bodil avatar cemerick avatar danskarda avatar joakin avatar neatonk avatar olenhad avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.