Skip to content

Instantly share code, notes, and snippets.

@anmonteiro anmonteiro/
Last active Oct 2, 2016

What would you like to do?

Demo of the new "require outside NS" feature in ClojureScript

Given the following directory structure, where cljs.jar is a ClojureScript uberjar built from source (the feature is currently unreleased, follow these instructions and build the compiler with script/uberjar):

├─ src
│  └─ foo.cljs
└─ cljs.jar

and src/foo.cljs:

;; src/foo.cljs
(require '[clojure.test :refer [deftest is run-tests]])

(deftest failing-test
  (is false))


Running the following will drop you into a ClojureScript Node.js REPL:

$ java -cp src:cljs.jar clojure.main -e "(require 'cljs.repl) (require 'cljs.repl.node) (cljs.repl/repl (cljs.repl.node/repl-env))"

Then simply (load-file "src/foo.cljs") and it'll be evaluated:

ClojureScript Node.js REPL server listening on 53518
To quit, type: :cljs/quit

cljs.user=> (load-file "src/foo.cljs")

Testing cljs.user

FAIL in (failing-test) (at .cljs_node_repl/cljs/test.js:432:14)
expected: false
  actual: false

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.