Open JimLynchCodes opened 6 years ago
(require 'ok-then.core)
;; => No such namespace: ok-then.core, could not locate ok_then/core.cljs, ok_then/core.cljc, or JavaScript source providing "ok-then.core"
(in-ns 'ok-then.core)
;; => ok-then.core=>
(ok)
;; => WARNING: Use of undeclared Var ok-then.core/ok_ at line 1
;; Cannot read property 'call' of undefined
@JimTheMan this plugin doesn't affect how your code is compiled or executed or anything like that - so do whatever you normally do to get a REPL going. The template doesn't include a dependency on the cljsbuild plugin - if that's what you're used to doing, maybe add that - or else you can use the cljs compiler API.
Thanks but this is what I normally do to get the REPL going, but it is not working- hence why I opened this issue. Can you please post how you are doing it?
Ah, when I cd into src directory and remove the cljs-lambda.macros then I am able to access my functions. However, I'm still unsure about other dependencies.
The problem is that I need to be in the src directory in order to access my namespaces, but it does not see any dependencies installed through something like lein deps
.
@JimTheMan I'm not sure what you mean about "being in the src directory" - the REPL doesn't know what directory you're in, beyond the directory it was started in. I successfully did lein new serverless-cljs ok-then
, started a REPL (M-x cider-jack-in-clojurescript
in emacs), and added a var called ok
- so I think whatever issue you are seeing is not related to this project / template.
Note that my ~/.lein/profiles.clj
file looks like so:
{:user
{:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:dependencies [[com.cemerick/piggieback "0.2.2"]]
:plugins
[[cider/cider-nrepl "0.15.1"]]}}
But that stuff is going to be dependent on your setup, and is just general configuration. Can you point me to another cljs project you can successfully start a REPL against? How are you starting it?
I have also struggled with this. In the end I followed https://github.com/bhauman/lein-figwheel/wiki/Node.js-development-with-figwheel#nodejs-standalone-application-development-with-figwheel with some changes to keep it separate from the lambda function itself (as I only use it locally):
To my project.clj
I have added
;...
:profiles {:dev {:dependencies [[org.clojure/tools.nrepl "0.2.12"]
[com.cemerick/piggieback "0.2.2"]
[figwheel-sidecar "0.5.14"]]
:cljsbuild
{:builds
{:dev
{:source-paths ["src"]
:figwheel true
:compiler
{:main node-main
:output-to "target/rbot-lambda/node-main-with-figwheel.js"
:output-dir "target/rbot-lambda"
:target :nodejs
:language-in :ecmascript5
:optimizations :none
:source-map true
:pretty-print true}}}}
:source-paths ["dev"]
:repl-options {:init-ns user
:nrepl-middleware
[cemerick.piggieback/wrap-cljs-repl]
}}}
and I have created dev/node_main.cljs
with the same content as the ./server_src/figwheel4node_server/core.cljs
in the guide, only with the namespace changed (figwheel4node-server.core -> node-main
).
and then I run lein with-profile dev, repl
and inside this Clojure REPL I start first figwheel, then the cljs REPL:
(require '[figwheel-sidecar.repl-api :as ra])
(ra/start-figwheel!)
(ra/cljs-repl)
the last thing i need to do is to start Node:
node target/rbot-lambda/node-main-with-figwheel.js
Hi, I scaffold a new project with
lein new serverless-cljs ok-then
and cd into the directory with project.clj.I then add one function to my core.clj like this:
How can I call this function from the REPL?