Hi all,

I updated the links in the quick start to point to the 0.0-3165 cljs.jar,
since it contains the fix for CLJS-1156
<http://dev.clojure.org/jira/browse/CLJS-1156>. But there's still some
weirdness there with load-file that I don't understand. A transcript is
below. If I load-file the hello-world.core namespace file first, it gives
no error but does not load the namespace correctly - I cannot invoke the
foo function defined in the file. Additionally, something in the REPL state
seems to be screwy since I then also can't require the namespace
afterwards. If I restart the REPL and just require the namespace rather
than using load-file, it works.

Am I misunderstanding something, or is this a bug?

Cheers,
Colin

~/d/cljs> cat node_repl.clj
(require 'cljs.repl)
(require 'cljs.closure)
(require 'cljs.repl.node)

(cljs.closure/build "src"
  {:main 'hello-world.core
   :output-to "out/main.js"
   :verbose true})

(cljs.repl/repl (cljs.repl.node/repl-env)
  :watch "src"
  :output-dir "out")

~/d/cljs> cat src/hello_world/core.cljs
(ns hello-world.core
  (:require [cljs.nodejs :as nodejs]))

(nodejs/enable-util-print!)

(defn -main [& args]
  (println "Hello world!"))

(set! *main-cli-fn* -main)

(defn foo [a b] (+ a b))

~/d/cljs> rlwrap java -cp cljs.jar:src clojure.main node_repl.clj
Reading analysis cache for
jar:file:/Users/colin/dev/cljs/cljs.jar!/cljs/core.cljs
Compiling src/hello_world/core.cljs
Analyzing jar:file:/Users/colin/dev/cljs/cljs.jar!/cljs/nodejs.cljs
Compiling out/cljs/nodejs.cljs
Compiling out/cljs/core.cljs
Using cached cljs.core out/cljs/core.cljs
ClojureScript Node.js REPL server listening on 55907
Watch compilation log available at: out/watch.log
To quit, type: :cljs/quit
cljs.user=> (load-file "/Users/colin/dev/cljs/src/hello_world/core.cljs")
nil
cljs.user=> (hello-world.core/foo 1 2)
repl:13
throw e__3976__auto__;
      ^
TypeError: Cannot read property 'call' of undefined
    at repl:1:109
    at repl:9:3
    at repl:14:4
    at Object.exports.runInThisContext (vm.js:74:17)
    at Domain.<anonymous> ([stdin]:41:34)
    at Domain.run (domain.js:197:16)
    at Socket.<anonymous> ([stdin]:40:25)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
cljs.user=> (require '[hello-world.core :as hello] :reload)
/Users/colin/dev/cljs/out/hello_world/core.js:5
cljs.nodejs.enable_util_print_BANG_.call(null);
           ^
TypeError: Cannot read property 'enable_util_print_BANG_' of undefined
    at Object.<anonymous>
(/Users/colin/dev/cljs/out/hello_world/core.cljs:4:2)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at global.CLOSURE_IMPORT_SCRIPT (repl:75:16)
    at Object.goog.require (repl:19:60)
    at repl:3:6
cljs.user=> :cljs/quit

~/d/cljs> rlwrap java -cp cljs.jar:src clojure.main node_repl.clj
Reading analysis cache for
jar:file:/Users/colin/dev/cljs/cljs.jar!/cljs/core.cljs
Compiling src/hello_world/core.cljs
Reading analysis cache for
jar:file:/Users/colin/dev/cljs/cljs.jar!/cljs/nodejs.cljs
Compiling out/cljs/nodejs.cljs
ClojureScript Node.js REPL server listening on 50817
Watch compilation log available at: out/watch.log
To quit, type: :cljs/quit
cljs.user=> (require '[hello-world.core :as hello] :reload)
nil
cljs.user=> (hello-world.core/foo 1 2)
3
cljs.user=> :cljs/quit
~/d/cljs>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to