bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.88k stars 209 forks source link

Figwheel + Electron with nREPL: Error: Can't pop empty vector #580

Open oskarkv opened 7 years ago

oskarkv commented 7 years ago

If I do lein figwheel and start Electron, everything works. But if I start lein repl and do (use 'figwheel-sidecar.repl-api) and (start-figwheel!) then when I start Electron I get the error:

Error: Can't pop empty vector
    at cljs.core.PersistentVector.cljs$core$IStack$_pop$arity$1 (/home/oskar/typestack/out/cljs/core.js:18988:8)
    at Object.cljs$core$_pop [as _pop] (/home/oskar/typestack/out/cljs/core.js:1777:13)
    at cljs$core$pop (/home/oskar/typestack/out/cljs/core.js:6626:18)
    at /home/oskar/typestack/out/figwheel/client/file_reloading.js:611:60
    at /home/oskar/typestack/out/figwheel/client/file_reloading.js:660:3
    at ContextifyScript.Script.runInThisContext (vm.js:26:33)
    at Object.exports.runInThisContext (vm.js:79:17)
    at nodeGlobalRequire (/home/oskar/typestack/out/goog/bootstrap/nodejs.js:87:6)
    at global.CLOSURE_IMPORT_SCRIPT (/home/oskar/typestack/out/goog/bootstrap/nodejs.js:75:3)
    at Object.goog.importScript_ (/home/oskar/typestack/out/goog/base.js:951:9)

And the prompt does not appear. I want to do it this way to be able to connect from Emacs/CIDER.

My project.clj is:

(defproject typestack "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/clojurescript "1.9.671"]
                 [com.cemerick/piggieback "0.2.2"]
                 [figwheel-sidecar "0.5.8"]
                 [reagent "0.7.0"]]
  :plugins [[lein-figwheel "0.5.11"]
            [lein-cljsbuild "1.1.6"]]
  :source-paths ["src"]
  :clean-targets [:target-path "out"]
  :cljsbuild {:builds [{:id "dev"
                        :source-paths ["src"]
                        :figwheel {:websocket-host "localhost"}
                        :compiler {:main "typestack.core"
                                   :target :nodejs
                                   :output-to "main.js"
                                   :output-dir "out"
                                   :optimizations :none
                                   :source-map true}}]})

My code is:

(ns typestack.core
  (:require
   [cljs.nodejs :as nodejs]
   [reagent.core :as r]))

(def Electron (nodejs/require "electron"))
(def app (.-app Electron))
(def BrowserWindow (.-BrowserWindow Electron))
(def path (nodejs/require "path"))
(def url (nodejs/require "url"))
(def dirname (js* "__dirname"))

(def win (atom nil))

(enable-console-print!)

(defn create-window []
  (reset! win (BrowserWindow. (clj->js {:width 800 :height 600})))
  (.loadURL @win "file:///home/oskar/typestack/index.html")
  (.openDevTools (.-webContents @win))
  (.on app "closed" (fn [] (reset! win nil))))

(defn -main []
  (.on app "ready" (fn []
                     (println "hello")
                     (create-window)))
  (.on app "window-all-closed"
       (fn [] (.quit app)))
  (.on app "activate"
       (fn [] (create-window))))

(nodejs/enable-util-print!)
(.log js/console "App has started!")
(set! *main-cli-fn* -main)

Any idea what could be wrong?

bhauman commented 7 years ago

It does look like there is something wrong here.