Reputation: 1545
I am following the learning ClojurScript book from Packt, and I am a little lost on something. I have a project.clj file with the following configuration
(defproject piggieback_project "0.5.2"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/clojurescript "1.10.879"]
[weasel "0.7.1" :exclusions
[org.clojure/clojurescript]]]
:profiles {:dev {:dependencies [[cider/piggieback "0.5.2"]
[org.clojure/tools.nrepl"0.2.10"]]
:repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}})
I am able to run lein repl and get a repl
I then run the following with this result
Clojure 1.10.3
OpenJDK 64-Bit Server VM 1.8.0_302-b08
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (require 'cljs.build.api)
nil
user=> (cljs.build.api/build "src"
#_=> {:main 'piggieback-project.core
#_=> :output-to "out/main.js"
#_=> :verbose true})
Options passed to ClojureScript compiler: {:output-dir "out", :closure-warnings {:check-types :off, :check-variables :off}, :closure-defines {}, :ups-libs nil, :cache-analysis true, :closure-module-roots [], :optimizations :none, :ups-foreign-libs [], :verbose true, :aot-cache false, :preloads [process.env], :ignore-js-module-exts [".css"], :output-to "out/main.js", :preamble ["cljs/imul.js"], :ups-externs nil, :opts-cache "cljsc_opts.edn", :source-map true, :cache-analysis-format :transit, :main piggieback-project.core, :language-in :es6, :emit-constants nil}
Unexpected error compiling at (REPL:1).
Could not write JavaScript nil
user=> (require 'weasel.repl.websocket)
user=> (cider.piggieback/cljs-repl
#_=> (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port
#_=> 9001))
<< started Weasel server on ws://0.0.0.0:9001 >>
<< waiting for client to connect ...
This is correct according to the book as to my result. But The next step is to open up my html file at the root which looks like this
<html>
<body>
<script type="text/javascript" src="out/main.js"></script>
</body>
</html>
and in my src directory I have a core.clj file with the following
(ns piggieback-project.core
(:require [weasel.repl :as repl]))
(when-not (repl/alive?)
(repl/connect "ws://localhost:9001"))
When I open the html file it's supposed to connect to the weasel websocket server and give me a user repl but it does not.
I am brand new to Clojurscript, So any help here at all would be great thanks
Upvotes: 0
Views: 64
Reputation: 1281
Your core.clj file should be named core.cljs! (Full path from the project root: src/piggieback_project/core.cljs
.)
P.S. Remove the incomplete "out" directory before you try again, to give the compiler a fresh start.
Upvotes: 1