Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not require cljsjs.firebase in file matchbox/registry.cljc #83

Open
JimLynchCodes opened this issue Feb 17, 2018 · 1 comment
Open

Comments

@JimLynchCodes
Copy link

JimLynchCodes commented Feb 17, 2018

I am getting strange errors when I try to use this.

My project.clj:

(defproject joke-generator-firebase "0.1.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/clojurescript "1.8.51"] [io.nervous/cljs-lambda "0.3.5"] [matchbox "0.0.9"]] :plugins [[lein-npm "0.6.2"] [io.nervous/lein-cljs-lambda "0.6.6"]] :npm {:dependencies [[serverless-cljs-plugin "0.1.2"] ]} :cljs-lambda {:compiler {:inputs ["src"] :options {:output-to "target/joke-generator-firebase/joke_generator_firebase.js" :output-dir "target/joke-generator-firebase" :target :nodejs :language-in :ecmascript5 :optimizations :none}}})

And some code in core.cljs:

(ns joke-generator-firebase.core
  (:require
;    [cljs-lambda.macros :refer-macros [defgateway]]
            [matchbox.core :as m]))

;(defgateway echo [event ctx]
;  {:status  200
;   :headers {:content-type (-> event :headers :content-type)}
;   :body    (event :body)})


(defn okthen [] (println "COOl"))


(def root (m/connect "https://<app>.firebaseio.com"))

(m/auth-anon root)

(m/listen-children
  root [:users :mike :friends]
  (fn [[event-type data]] (prn data)))

(def mikes-friends (m/get-in root [:users :mike :friends]))
(m/reset! mikes-friends [{:name "Kid A"} {:name "Kid B"}])
(m/conj! mikes-friends {:name "Jean"})

(m/deref
  mikes-friends
  (fn [key value]
    (m/reset-in! root [:users :mike :num-friends]
                 (count value))))

(m/unauth)

I run lumo -c $(lein classpath)

Then (load-file "src/joke_generator_firebase/core.cljs")

And it gives me this error:

Could not require cljsjs.firebase in file matchbox/registry.cljc
	 (new)
	 Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1928:72)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2539:92)
	 (NO_SOURCE_FILE <embedded>:5845:320)
	 Object.cljs.js.run_async_BANG_ (NO_SOURCE_FILE <embedded>:5823:122)
	 Object.cljs.js.process_deps (NO_SOURCE_FILE <embedded>:5823:185)
	 Object.cljs.js.process_libs_deps (NO_SOURCE_FILE <embedded>:5825:60)
	 (NO_SOURCE_FILE <embedded>:5843:474)
	 Object.cljs.js.run_async_BANG_ (NO_SOURCE_FILE <embedded>:5823:122)
	 Object.cljs.js.process_deps (NO_SOURCE_FILE <embedded>:5823:185)

Cannot read property 'navigator' of undefined
	 (evalmachine.<anonymous>:12:345)
	 (evalmachine.<anonymous>:277:278)
	 ContextifyScript.Script.runInThisContext (vm.cljs:44:33)
	 Object.runInThisContext (vm.cljs:116:38)
	 (Object.lt)
	 lumo.repl.caching_node_eval (NO_SOURCE_FILE <embedded>:6373:68)
	 (NO_SOURCE_FILE <embedded>:5844:410)
	 Object.cljs.js.run_async_BANG_ (NO_SOURCE_FILE <embedded>:5823:122)
	 Object.cljs.js.process_deps (NO_SOURCE_FILE <embedded>:5823:185)
	 Object.cljs.js.process_libs_deps (NO_SOURCE_FILE <embedded>:5825:60)


@crisptrutski
Copy link
Owner

Him Jim! I'm not very familiar with Lumo - the bulk of the stacktrace seem to refer to its internals and doesn't mean much to me. Taking a guess it seems like the code is trying to use window.navigator, and window is not defined - maybe you'd just need a shim. Firebase's client library has also likely improved environment sniffing and support since the version Matchbox is wrapping.

And I don't think that Matchbox's version is even supported for new database instances.

I suggest trying a recent version directly using [cljsjs/firebase "4.9.0-0"], or a more recent wrapper like https://github.com/degree9/firebase-cljs.

If you appreciate the Matchbox API (it worked well for me!), you're welcome to fork, or become a contributor here. Unfortunately the rot here is bad, and I have zilch spare time or incentive to pull the socks back up 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants