Fork me on GitHub
#boot
<
2017-07-08
>
kurt-o-sys08:07:30

I'm trying to start a boot-nodejs project. I follow this guide: https://specious.github.io/blog/2016/12/07/Starting-a-NodeJS-app-with-ClojureScript-and-Boot/ For some reason, I get this error:

$ node main.js
<PROJECT_HOME>/target/main.js:16
var k="undefined"!==typeof Math.imul&&0!==Math.imul(4294967295,5)?function(a,d){return Math.imul(a,d)}:function(a,d){var e=a&65535,f=d&65535;return e*f+((a>>>16&65535)*f+e*(d>>>16&65535)<<16>>>0)|0};function l(a){a=k(a|0,-862048943);a=0^(
k(a<<15|a>>>-15,461845907)|0);a=(k(a<<13|a>>>-13,5)+-430675100|0)^0;a=k(a^a>>>16,-2048144789);k(a^a>>>13,-1028477387)}l(1);l(0);throw Error("cljs.core/*main-cli-fn* not set");                                                              
                                                                                                                                                                                                                                              
                                                                                                                                ^                                                                                                            

Error: cljs.core/*main-cli-fn* not set
    at Error (native)
    at Object.<anonymous> (<PROJECT_HOME>/server/target/main.js:16:373)
    at Module._compile (module.js:570:32)
There's only 1 ns so far:
(ns server.core
  (:require [cljs.nodejs :as nodejs]))

(nodejs/enable-util-print!)

(defn main [& args]
  (println "Abracadabra!"))

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

kurt-o-sys08:07:27

build.boot:

(def project 'server)
(def version "0.1.0-SNAPSHOT")

(set-env!
 :source-paths #{"src"}
 :dependencies '[[adzerk/boot-cljs "RELEASE" :scope "test"]])

(require
 '[adzerk.boot-cljs :refer [cljs]])

(deftask dev
  "Watch/compile files in development"
  []
  (comp
   (watch)
   (cljs :source-map true
         :optimizations :none
         :compiler-options {:target :nodejs})
   (target)))

(deftask prod
  "Compile for production"
  []
  (comp
   (cljs :optimizations :advanced
         :compiler-options {:target :nodejs})
   (target)))

martinklepsch08:07:18

@kurt-o-sys try setting a :main namespace in the compiler options

martinklepsch08:07:33

e.g. :main 'server.core

kurt-o-sys08:07:38

oh... right.

kurt-o-sys08:07:26

... problem was wrong file extension (`.clj` -> .cljs)

onetom17:07:38

i was googling around but can't find how to pretty print the return values in boot repl

onetom17:07:50

i even see there is boot.from.io.aviso.repl/pretty-print but it's not used... (okay, maybe i should grep the boot source for this function to get a clue...)

dominicm18:07:22

@onetom Any nrepl middleware (like puget's) will work 🙂

onetom18:07:31

looks like puget uses this package to provide a middleware, but it also seems very leiningen specific: https://github.com/greglook/whidbey (im not using cider, btw. i was just talking about using boot repl from the terminal)

onetom18:07:18

i have this cider boot task in my ~/.boot/profile.boot but this doesn't seem to help with pretty printing:

(deftask cider "CIDER profile"
  []
  (require 'boot.repl)
  (swap! @(resolve 'boot.repl/*default-dependencies*)
         concat '[#_[org.clojure/tools.nrepl "0.2.12"]
                  [cider/cider-nrepl "0.14.0"]
                  [refactor-nrepl "2.3.0-SNAPSHOT"]])
  (swap! @(resolve 'boot.repl/*default-middleware*)
         concat '[cider.nrepl/cider-middleware
                  refactor-nrepl.middleware/wrap-refactor])
  identity)

onetom18:07:54

i see the last commit in https://github.com/clojure-emacs/cider-nrepl is yours 🙂 im reading the via Boot section now...

dominicm21:07:58

@onetom sorry, yes. Whidbey 🙂. The gist of it is the same as the cider task. Many things seem lein specific, but that's just because leiningen is so dominant