shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
valerauko 2021-05-27T02:56:04.150700Z

a node-script generated output needs a node_modules folder too?

valerauko 2021-05-27T02:57:00.151500Z

i have some dependencies in package.json and after shadow-cljs release the generated file errors saying the dependencies are missing

valerauko 2021-05-27T02:59:21.151900Z

(dependencies are missing = Error: Cannot find module)

caleb.macdonaldblack 2021-05-27T03:28:31.153400Z

In Cursive, I connect to the remote repl for shadow-cljs. Then I have to type (shadow/repl :app). Can I set this up to run that command by default when I connect to the remote repl?

thheller 2021-05-27T07:11:07.154500Z

@vale yes, node-script does not bundle dependencies by default. you can post-process the file with something like https://github.com/vercel/ncc to make it standalone. or just include the node_modules whereever you are publishing (recommended)

thheller 2021-05-27T07:11:56.155200Z

@caleb.macdonaldblack I don't think so. problem is that cursive needs to create the second nrepl session for CLJS, can't start out the REPL that way.

caleb.macdonaldblack 2021-05-27T07:12:25.155500Z

Ah ok. No worries.

simongray 2021-05-27T09:25:49.158100Z

I can’t seem to get shadow-cljs 2.14.0 working in my deps.edn setup. I do have the required dependencies at the correct versions (Clojure, ClojureScript, closure-compiler-unshaded), but somehow I end up getting this error every time I try to run shadow-cljs watch app :

11:22 $ shadow-cljs watch app
------------------------------------------------------------------------------

   WARNING: shadow-cljs not installed in project.
   See <https://shadow-cljs.github.io/docs/UsersGuide.html#project-install>

------------------------------------------------------------------------------
shadow-cljs - config: /Users/rqf595/Code/louis-hjelmslev/shadow-cljs.edn
shadow-cljs - starting via "clojure"
--- SHADOW-CLJS FAILED TO LOAD! ----------------------

This is most commonly caused by a dependency conflict.
When using deps.edn or project.clj you must ensure that all
required dependencies are provided with the correct version.

You are using shadow-cljs version: 2.14.0

The important dependencies are:

  org.clojure/clojure "1.10.3"
  org.clojure/clojurescript "1.10.866"
  com.google.javascript/closure-compiler-unshaded "v20210505"

Please verify that you are loading these versions.
You can find all required dependencies here:

  <https://clojars.org/thheller/shadow-cljs/versions/2.14.0>

Please refer to the Guide for more information:

  <https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load>

-----------------------------------------------------

The error encountered was:

Syntax error macroexpanding at (closure.clj:78:5).
        at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1742)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3705)
        at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457)
        at clojure.lang.Compiler.eval(Compiler.java:7186)
        at clojure.lang.Compiler.load(Compiler.java:7640)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6856.invoke(core.clj:6115)
        at clojure.core$load.invokeStatic(core.clj:6114)
        at clojure.core$load.doInvoke(core.clj:6098)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5897)
        at clojure.core$load_one.invoke(core.clj:5892)
        at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
        at clojure.core$load_lib.invokeStatic(core.clj:5936)
        at clojure.core$load_lib.doInvoke(core.clj:5917)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:669)
        at clojure.core$load_libs.invokeStatic(core.clj:5974)
        at clojure.core$load_libs.doInvoke(core.clj:5958)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:669)
        at clojure.core$require.invokeStatic(core.clj:5996)
        at clojure.core$require.doInvoke(core.clj:5996)
        at clojure.lang.RestFn.invoke(RestFn.java:551)
        at shadow.build.js_support$eval11454$loading__6737__auto____11455.invoke(js_support.clj:1)
        at shadow.build.js_support$eval11454.invokeStatic(js_support.clj:1)
        at shadow.build.js_support$eval11454.invoke(js_support.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:7181)
        at clojure.lang.Compiler.eval(Compiler.java:7170)
...
...
...
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:40)
Caused by: java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
        at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:257)
...
...
...
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
        at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1735)
        ... 211 more

✅ 1
thheller 2021-05-27T09:26:37.158400Z

@simongray thats a dependency conflict on guava

simongray 2021-05-27T09:28:37.159100Z

I see. How do you know that, though?

thheller 2021-05-27T09:28:56.159700Z

com.google.common.collect.* is a guava package

simongray 2021-05-27T09:29:02.159900Z

aha

simongray 2021-05-27T09:31:20.160500Z

Thank you. Hm, still kinda puzzled why this is now seemingly an issue.

thheller 2021-05-27T09:31:56.161400Z

do you have your server-side CLJ stuff in the default deps.edn :deps? might make sense to move them to a :server alias or so

simongray 2021-05-27T09:32:03.161700Z

yes

thheller 2021-05-27T09:32:31.162300Z

so that they aren't loaded when running CLJS, kinda helps avoiding such conflicts

simongray 2021-05-27T09:32:46.162900Z

Makes sense!

thheller 2021-05-27T09:32:48.163Z

(also why I typically recommend keeping your CLJ and CLJS setups apart)

thheller 2021-05-27T09:33:22.163700Z

but keeping it all in deps.edn with aliases is totally fine

simongray 2021-05-27T09:33:43.164100Z

I guess I’ll make a split into a :backend and :frontend aliases and then keep CLJC libs in the root

simongray 2021-05-27T09:34:13.164400Z

Yeah, I like the utility of a single file

simongray 2021-05-27T09:50:14.166400Z

Ok, so moving the deps into aliases worked! 😄

simongray 2021-05-27T09:50:36.166700Z

Thank you, once again

valerauko 2021-05-27T11:16:26.166800Z

i went with ncc because i couldn't figure out how to make my node_modules "minimal"

simongray 2021-05-27T11:37:11.168Z

BTW @thheller the link in this message

WARNING: shadow-cljs not installed in project.
   See <https://shadow-cljs.github.io/docs/UsersGuide.html#project-install>
doesn’t seem to lead anywhere (the #project-install part specifically).

simongray 2021-05-27T11:37:31.168200Z

Just FYI

thheller 2021-05-27T11:40:44.168600Z

oh right. I guess I forgot to write that section 😉

simongray 2021-05-27T11:46:43.168800Z

Haha

simongray 2021-05-27T11:47:10.169200Z

It seems to work fine anyway, so why the warning?

thheller 2021-05-27T11:50:08.170300Z

installing npm shadow-cljs ensures that some runtime dependencies are also installed. ie. ws for node builds or node-libs-browser for browser polyfills. can work without but may fail.

simongray 2021-05-27T11:59:45.170500Z

I see.

thheller 2021-05-27T12:02:47.171200Z

oh and of course it also ensures that you are not dependent on some global shadow-cljs install, which may drift in versions and so on.

2021-05-27T12:19:35.171700Z

In a macro, I need to check if a symbol resolves to an undefined var. Calling (cljs.analyzer/resolve-var env sym nil false) triggers an error : > Wrong number of args (2) passed to: shadow.build.cljs-hacks/shadow-resolve-var Is this a known bug, is there a workaround or a better way ?

thheller 2021-05-27T13:01:57.171900Z

@leonoel just call it with 2 args?

2021-05-27T13:03:33.172500Z

arity 2 works but then how to reliably check that the var is undefined ?

thheller 2021-05-27T13:06:10.173100Z

hmm I must have missed the change where the extra arity was introduced. that only used to have 2 or 3

2021-05-27T13:15:02.173400Z

should I open an issue ?

thheller 2021-05-27T13:18:48.173600Z

already fixed in master

thheller 2021-05-27T13:19:42.174Z

just trying to find a place where the 4th arity is actually used anywhere 😛

thheller 2021-05-27T13:20:55.174400Z

ah, its only used once internally. I guess you are the first trying to use it in what way 😛

2021-05-27T13:23:17.175300Z

awesome, thanks !

thheller 2021-05-27T13:26:34.175700Z

just released 2.14.1 with that fix

👍 1
Volodymyr Huzar 2021-05-27T15:05:52.177200Z

Hello! is there a way to support modules when :target :karma is used? Now I am getting “Uncaught Error: shadow.loader API was called before shadow.loader.init! You are probably calling module loader too early before shadow-cljs got fully initialized.”

thheller 2021-05-27T15:08:24.177500Z

not sure karma allows that

Volodymyr Huzar 2021-05-27T15:13:13.179100Z

From what I saw we need to append shadow.loader.init(""); somehow to the output, but have no idea how to do that properly

thheller 2021-05-27T15:14:45.179700Z

that is true in theory but not enough

thheller 2021-05-27T15:14:59.180100Z

since no modules are configured it'll then just fail wherever you are calling load

thheller 2021-05-27T15:15:35.180600Z

how do you use the loader? typically that code should not be part of tests?

thheller 2021-05-27T15:15:58.181Z

I mean the code should just be loaded directly in the test?

Volodymyr Huzar 2021-05-27T15:18:07.182300Z

another component is loaded in component I’m testing, so I’m not calling it directly but it is called on certain test scenarios

Volodymyr Huzar 2021-05-27T15:19:52.183900Z

actually I have tried it with :browser-test and only adding `

:module-loader true
was enough, without specifying modules. Also I’m requiring the namespace which should be loaded in tests directly, so maybe it is a reason why they are not failing

thheller 2021-05-27T15:23:28.184300Z

something must be calling something from shadow.loader. otherwise you wouldn't get that error.

thheller 2021-05-27T15:27:20.185200Z

in :browser-test you can set :module-loader since it is built on the :browser target. :karma is not so that won't work there

thheller 2021-05-27T15:27:38.185600Z

but :browser-test still won't be able to actually use the shadow.loader api in any way

Volodymyr Huzar 2021-05-28T09:53:31.239100Z

@thheller I haven’t prepared an example yet, but it seems I have found workaround for my issue by adding js file with next content

(function () {
  goog.global.shadow$modules = {infos: {test: null}, uris: {test: []}}
  shadow.loader.init("");
})();
to karma.conf.js -> files

thheller 2021-05-28T09:55:50.239300Z

still don't know why you need that but looks fine

Volodymyr Huzar 2021-05-28T10:58:49.240900Z

@thheller https://github.com/Valdermeyder/karma-modules-support/tree/master I have created a small but enough to reproduce example

thheller 2021-05-28T11:03:19.241400Z

well yeah but that is missing the entire context? I mean why do you call the loadable in the test in the first place? is that rendering actual UI code or what are you doing?

Volodymyr Huzar 2021-05-28T11:14:24.242300Z

I am not calling it in the first place. It is called by the function which is tested. I understand you concern that in this example it looks like a first call but in my real case it is one of the things which happen. In general the context is when user have certain permissions call this method from another module. It was split by modules to load this additional code only for users which have this certain permission. I’ll not argue that it is the best solution which can be implemented but it is already done and I’m not in charge to change it right now.

Volodymyr Huzar 2021-05-28T11:15:49.242500Z

Anyway I think the problem of running karma tests when modules and lazy load are used is not related to the context. As you can see it fails even in very simple example.

thheller 2021-05-28T11:27:44.242700Z

(ns my.app-spec
  (:require
    [cljs.test :as ct :refer [deftest is]]
    [shadow.loader :as sl]
    [<http://my.app|my.app> :as app]
    [my.core]))

(ct/use-fixtures :once
  (fn [test]
    (sl/init "")
    (test)))
may also work

thheller 2021-05-28T11:30:16.242900Z

I'm really unsure how to treat loader related things in tests. since it can't actually load a module the test using it becomes kind of pointless

Volodymyr Huzar 2021-05-28T11:39:22.243100Z

The example above will work only once, the next test suite will fail at least from what I saw in the code.

Volodymyr Huzar 2021-05-28T11:41:33.243300Z

yeah, it is probably hard to achieve fully but when your require lazy loadable namespace in the test (e.g. my.core), lazy loader works fine, so I think here is only a matter of not failing :karma target when modules are used

Volodymyr Huzar 2021-05-28T11:44:47.243500Z

I am not big fun of mocks but probably with-redefs can be used somehow to stub parts of the lazy loaded namespaces in case we don’t want to require them explicitly

Volodymyr Huzar 2021-05-28T12:24:07.243700Z

@thheller are you okay to open issue in GitHub for that case?

thheller 2021-05-28T13:19:37.244700Z

sure

Volodymyr Huzar 2021-05-28T15:11:04.248200Z

https://github.com/thheller/shadow-cljs/issues/889

wcalderipe 2021-05-27T15:49:46.187400Z

hey 👋 does this error ring a bell on someone?

❯ node_modules/.bin/shadow-cljs watch webapp
shadow-cljs - config: /Users/wcalderipe/dev/foo-project/shadow-cljs.edn
shadow-cljs - updating dependencies
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (sharedRuntime.cpp:531), pid=17169, tid=5635
#  Error: ShouldNotReachHere()
#
# JRE version: OpenJDK Runtime Environment (16.0+14) (build 16+14)
# Java VM: OpenJDK 64-Bit Server VM (16+14, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/wcalderipe/dev/foo-project/hs_err_pid17169.log
#
# If you would like to submit a bug report, please visit:
#   <https://bugreport.java.com/bugreport/crash.jsp>
#
===== ERROR =================
ENOENT: no such file or directory, open '/Users/wcalderipe/dev/foo-project/.shadow-cljs/classpath.edn'
=============================
os macOS 11.4 (20F71) shadow-cljs: 2.11.11 java
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment (build 16+14)
OpenJDK 64-Bit Server VM (build 16+14, mixed mode)

thheller 2021-05-27T15:51:47.187800Z

odd. no clue.

👍 1
thheller 2021-05-27T15:56:39.188900Z

do you also get that error with lein or deps.edn? it happens during dependency downloading? so even before shadow-cljs even starts?

wcalderipe 2021-05-27T15:59:11.189900Z

yeah, I also get that just by running clj on the terminal. definitely not related to shadow-cljs

wcalderipe 2021-05-27T15:59:20.190100Z

thanks!

Schpaa 2021-05-27T16:24:59.190700Z

What is the correct way of including firebase into a cljs project?

thheller 2021-05-27T16:25:23.191100Z

npm install it and require it in your ns

Schpaa 2021-05-27T16:25:48.191800Z

And how would the require look like? (:require [“firebase”]) ?

Schpaa 2021-05-27T16:26:44.192700Z

I am really confused about the js/ prefix and why using it

thheller 2021-05-27T16:26:57.193100Z

you don't use js/ for this

thheller 2021-05-27T16:27:07.193400Z

js/ is for accessing global variables

thheller 2021-05-27T16:27:49.194400Z

maybe this helps https://github.com/jacekschae/shadow-firebase

Schpaa 2021-05-27T16:27:53.194600Z

my project cannot see the firebase imported, like your examples, and I don’t know how to fix this

Schpaa 2021-05-27T16:28:24.195200Z

@thheller Yes, I think I follow it

thheller 2021-05-27T16:28:34.195500Z

don't know how you imported it or how you accessed it, so can't say

Schpaa 2021-05-27T16:28:53.195700Z

its in a package.json

Schpaa 2021-05-27T16:29:08.196Z

thats the only place where it is ref.

thheller 2021-05-27T16:29:26.196300Z

that doesn't do anything without requiring it in your code

Schpaa 2021-05-27T16:29:52.196600Z

(:require [cljs-bean.core :refer [-&gt;clj -&gt;js bean]]
            ;["firebase/app"]
            ;["firebase"]
            ;["firebase" :as firebase]
            ;["@firebase/app" :refer (firebase)]

Schpaa 2021-05-27T16:30:00.196800Z

some of my attempts

Schpaa 2021-05-27T16:31:06.197300Z

I’ll try

thheller 2021-05-27T16:32:50.197900Z

usually helps if you have JS examples, those translate 1:1 regarding the requires

Schpaa 2021-05-27T16:37:47.198200Z

I think there is something else, not the requires

Schpaa 2021-05-27T16:37:58.198400Z

something with my config

Schpaa 2021-05-27T16:38:29.198800Z

but I have no grasp of it because there are so many loose ends right now

thheller 2021-05-27T16:38:41.199Z

this requires no extra config at all

Schpaa 2021-05-27T16:39:30.199600Z

unless I’ve done something stupid in my shadow-cljs.edn

thheller 2021-05-27T16:39:54.199900Z

hard to say without seeing it or the code 😉

Schpaa 2021-05-27T16:39:58.200100Z

{:deps       {:aliases [:dev]}
 :dev-http   {8000 "classpath:public"}
 :nrepl      {:port       7002
              :middleware []}

 :builds     {:test     {:target    :browser-test
                         :test-dir  "resources/public/js/test"
                         :ns-regexp "event2-test$"
                         ;:runner-ns tests.client-test-main
                         :devtools  {:http-port          8021
                                     :http-root          "resources/public/js/test"}}

              :app { :git-inject {:version-pattern "^v/(.*)$"
                                  :ignore-dirty?   true}
                    :target            :browser
                    :build-hooks       [(shadow-git-inject.core/hook)]
                    :compiler-options  {:closure-defines {app.system.config/version :shadow-git-inject/version}}
                    :output-dir        "resources/app/js"
                    :asset-path        "/js"
                    :module-hash-names 4
                    :modules           {:main {:init-fn app.core/init!}}
                    :dev               {:dependencies     [#_[day8.re-frame/tracing-stubs "0.5.1"]]
                                        :compiler-options {#_#_:output-feature-set :es6
                                                           :closure-defines {app.system.config/version :shadow-git-inject/version
                                                                             app.system.config/build-time :shadow-git-inject/build-iso-date-time
                                                                             "re_frame.trace.trace_enabled_QMARK_" true}}}

                    :release           {:output-dir       "resources/dist/js"

                                        :compiler-options {#_#_:output-feature-set :es6
                                                           :closure-defines {app.system.config/version :shadow-git-inject/version
                                                                             app.system.config/build-time :shadow-git-inject/build-iso-date-time}
                                                           :optimizations   :simple
                                                           :infer-externs   :auto}}

                    :devtools          {;:preloads   [day8.re-frame-10x.preload]
                                        :after-load app.core/reload!
                                        :http-port  8050
                                        :http-root  "resources/app"
                                        :watch-dir  "resources/app"}}}}

Schpaa 2021-05-27T16:40:17.200400Z

I use the :app branch

Schpaa 2021-05-27T16:40:47.200600Z

Do I do anything crazy here?

thheller 2021-05-27T16:41:26.201100Z

some unnecessary config but looks ok

Schpaa 2021-05-27T16:41:31.201300Z

{:paths   ["src/cljs"]
 :deps    {org.clojure/clojure         {:mvn/version "1.10.3"}
           org.clojure/clojurescript {:mvn/version "1.10.866"}
           org.clojure/core.async      {:mvn/version "1.3.610"}
           thheller/shadow-cljs        {:mvn/version "2.14.1"}
           com.taoensso/timbre         {:mvn/version "5.1.0"}
           #_#_com.schpaa/schpaa           {:mvn/version "0.2.0-SNAPSHOT"}
           expound                     {:mvn/version "0.8.9"}
           reagent                     {:mvn/version "1.0.0"}
           re-frame                    {:mvn/version "1.1.2"}
           kee-frame                   {:mvn/version "1.1.2"}
           cljs-bean                   {:mvn/version "1.6.0"}
           fork                        {:mvn/version "2.4.0"}
           vlad                        {:mvn/version "3.3.2"}
           com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
           thedavidmeister/cljs-i18n   {:mvn/version "0.4.0"}
           arco                        {:mvn/version "0.3.4"}
           fipp                        {:mvn/version "0.6.23"}
           mvxcvi/puget                {:mvn/version "1.3.1"}
           markdown-to-hiccup          {:mvn/version "0.6.2"}
           markdown-clj                {:mvn/version "1.10.5"}
           medley                      {:mvn/version "1.3.0"}
           nrepl                       {:mvn/version "0.8.3"}
           day8/shadow-git-inject      {:mvn/version "0.0.4"}

           ;for codemirror
           #_#_applied-science/js-interop {:mvn/version "0.2.5"}}


 :aliases {:carve
           {:extra-deps {borkdude/carve {:git/url "<https://github.com/borkdude/carve>"
                                         :sha     "$LATEST_CARVE_SHA"}}
            :main-opts  ["-m" "carve.main"]}

           :dev
           {:extra-paths ["src/dev"]
            :extra-deps  {;nubank/workspaces      {:mvn/version "1.0.15"}
                          ;day8.re-frame/re-frame-10x {:mvn/version "1.0.2"}
                          ;org.clojure/clojurescript  {:mvn/version "1.10.773"}

                          binaryage/devtools         {:mvn/version "1.0.2"}}}}}

Schpaa 2021-05-27T16:41:57.201600Z

I’ve eliminated all codemirror related stuff

Schpaa 2021-05-27T16:42:23.201900Z

{
  "dependencies": {
    "create-react-class": "^15.7.0",
    "firebase": "^8.6.2",
    "firebase-auth": "^0.1.2",
    "highlight.js": "10.7.1",
    "image-conversion": "^2.1.1",
    "marked": "^0.7.0",
    "process": "^0.11.10",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-firebaseui": "^5.0.2",
    "react-highlight.js": "1.0.7",
    "react-virtualized": "^9.22.2"
  },
  "devDependencies": {
    "highlight.js": "9.18.1",
    "react-highlight.js": "1.0.7"
  }
}

thheller 2021-05-27T16:42:39.202100Z

all looks fine, except the missing npm install shadow-cljs maybe

Schpaa 2021-05-27T16:42:52.202300Z

hmm

Schpaa 2021-05-27T16:43:21.202600Z

where would that go?

Schpaa 2021-05-27T16:43:36.202800Z

if there is something special

Schpaa 2021-05-27T16:43:45.203Z

I just invoke it from the cli

thheller 2021-05-27T16:44:10.203500Z

in the project, you just npm install shadow-cljs. so you don't rely on some global install

Schpaa 2021-05-27T16:44:30.204Z

oh ok

Schpaa 2021-05-27T16:44:34.204300Z

yes

thheller 2021-05-27T16:44:42.204500Z

but that likely has nothing to do with whatever your issue is

thheller 2021-05-27T16:44:56.204800Z

just recommended and "safer" 😉

Schpaa 2021-05-27T16:46:48.205100Z

There is also the error in the console I cannot really fathom

Schpaa 2021-05-27T16:46:50.205400Z

main.js:1552 TypeError: module$node_modules$firebase$app$dist$index_esm.initializeApp is not a function
    at <http://Object.app|Object.app>$system$database$core$init_BANG_ [as init_BANG_] (core.cljs:71)
    at <http://Object.app|Object.app>$core$init_BANG_ [as init_BANG_] (core.cljs:33)
    at eval (shadow.module.main.append.js:4)
    at eval (&lt;anonymous&gt;)
    at Object.goog.globalEval (main.js:486)
    at Object.env.evalLoad (main.js:1549)
    at main.js:2040

thheller 2021-05-27T16:47:22.205800Z

depending on which firebase version you use it might require a different import. they seem to change it every other version

Schpaa 2021-05-27T16:47:32.206200Z

erroring while init’ing the fb connection

Schpaa 2021-05-27T16:47:40.206500Z

do they?

thheller 2021-05-27T16:47:44.206700Z

so instead of ["firebase/app" :as firebase] try ["firebase/app$default" :as firebase]

Schpaa 2021-05-27T16:47:52.206900Z

interesting

thheller 2021-05-27T16:48:01.207100Z

again .. help if you have JS examples

Schpaa 2021-05-27T16:48:18.207400Z

there are no js I’ve made

thheller 2021-05-27T16:48:40.207700Z

https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages there is a translation table

thheller 2021-05-27T16:48:54.208100Z

but I assume you are looking at JS docs for this stuff which have examples

Schpaa 2021-05-27T16:49:55.208600Z

the js stuff is rel. easy, just have to establish a stable firebase-var access

Schpaa 2021-05-27T16:50:10.208800Z

which is really tripping me up here

Schpaa 2021-05-27T16:50:32.209500Z

I am also using a react-firebaseui comp

thheller 2021-05-27T16:50:36.209700Z

so look at ONE JS example that explains this stuff and then translate it using the table I linked

thheller 2021-05-27T16:51:02.210200Z

there is really no point in guessing here. this stuff should be documented somewhere in the docs

thheller 2021-05-27T16:52:15.210400Z

for example https://www.npmjs.com/package/react-firebaseui

thheller 2021-05-27T16:52:24.210800Z

import firebase from 'firebase';

thheller 2021-05-27T16:52:47.211600Z

that would be ["firebase" :default firebase] OR the new official variant ["firebase$default" :as firebase]

thheller 2021-05-27T16:54:02.212300Z

but yeah for firebase it is extremely important to check the versions you use, they change a lot of stuff constantly

thheller 2021-05-27T16:55:20.212700Z

so stuff that used to work for older versions may be incorrect today

Schpaa 2021-05-27T16:58:02.213100Z

thank you

Schpaa 2021-05-27T17:50:35.213300Z

no dice at all

Schpaa 2021-05-27T17:50:54.213600Z

Maximum call stack size exceeded when trying to peek at firebase

thheller 2021-05-27T17:51:42.213800Z

no idea what you mean by that

Schpaa 2021-05-27T17:52:09.214400Z

env.evalLoad @ main.js:1551
(anonymous) @ main.js:1930
main.js:1552 RangeError: Maximum call stack size exceeded
    at Object.eval [as cljs$core$ILookup$_lookup$arity$2] (core.cljs:6851)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (core.cljs:1959)
    at Object.cljs$core$print_meta_QMARK_ [as print_meta_QMARK_] (core.cljs:10236)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (core.cljs:10246)
    at cljs$core$pr_writer (core.cljs:10339)
    at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (core.cljs:10191)
    at Object.eval [as cljs$core$IPrintWithWriter$_pr_writer$arity$3] (core.cljs:692)
    at Object.cljs$core$_pr_writer [as _pr_writer] (core.cljs:778)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (core.cljs:10257)
    at cljs$core$pr_writer (core.cljs:10339)

Schpaa 2021-05-27T17:52:33.215100Z

that meta_QMARK

thheller 2021-05-27T17:52:47.215500Z

ok, that means you can't print it. likely because is has self-referential circular references

Schpaa 2021-05-27T17:52:59.215900Z

oh

thheller 2021-05-27T17:53:09.216200Z

but if you don't print it thats not a problem 😛

Schpaa 2021-05-27T17:53:28.216700Z

So i cannot do

(-&gt; firebase .-app)

Schpaa 2021-05-27T17:53:45.217400Z

or (.-app firebase)

thheller 2021-05-27T17:54:02.217800Z

sure you can. you just can't print it, so you can't do it in the REPL if thats what you mean

thheller 2021-05-27T17:54:25.218400Z

(js/console.log (-&gt; firebase .-app)) should be ok, or tap&gt; and the Inspect UI (probably rather limited, so use console)

Volodymyr Huzar 2021-05-27T17:55:01.218600Z

@thheller shadow.lazy/loadable is used in the function I’m testing that’s why error happens inside :karma while working fine inside :browser-test I’ll open an issue in GitHub and will try to find some workaround in meanwhile. I think it would be nice to have some recipe to run tests when shadow.lazy is used inside

Schpaa 2021-05-27T17:55:09.219Z

nothing shows up in the console

Schpaa 2021-05-27T17:55:31.219200Z

oh yes

Schpaa 2021-05-27T17:55:57.219400Z

ƒ app(name){name=name||“[DEFAULT]“;if(!(0,_util.contains)(apps, name))throw ERROR_FACTORY.create(“no-app”,{appName:name});return apps[name]}

Schpaa 2021-05-27T17:56:59.219900Z

So it seems I can invoke initializeApp via this firebase thing

thheller 2021-05-27T17:57:59.220Z

if you provide a repro I can give you tips. without knowing what you are doing I really can't give other tips.

thheller 2021-05-27T17:58:51.220700Z

sure, the JS examples seem to do that. don't see the <http://firebase.app|firebase.app> anywhere but the initializeApp I believe is the first thing you are supposed to call

Volodymyr Huzar 2021-05-27T17:59:34.220800Z

sure, I’ll try to prepare some demo tomorrow

Schpaa 2021-05-27T17:59:51.221200Z

yes

Schpaa 2021-05-27T17:59:59.221400Z

and thats passing fine

Schpaa 2021-05-27T18:00:22.221600Z

I do an init at

(defn ^:export init! []

Schpaa 2021-05-27T18:00:39.221900Z

and put the result in an atom

Schpaa 2021-05-27T18:01:03.222700Z

(defn init! []
  (log/info "widd/init!")
  (reset! app (if (zero? (count (.-apps firebase)))
                (-&gt; firebase
                    (.initializeApp (-&gt;js appinfo-vakt)))
                (.-app firebase)))
  (when goog.DEBUG
    (-&gt; firebase
        .database
        (.useEmulator "localhost" 10008))
    (-&gt; firebase
        .firestore
        (.useEmulator "localhost" 10009))))

thheller 2021-05-27T18:01:13.222900Z

that doesn't seem to have a result. or at least the JS stuff never handles it

knubie 2021-05-27T18:11:29.225Z

Is it possible to access closure-defines, or something simlar, in a clojure macro? I have a side effecting macro, and I’d like to somehow disable the side effecting part in certain builds like in CI.

thheller 2021-05-27T18:14:19.225300Z

sure, see https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/prefs.clj#L8-L12 for an example

thheller 2021-05-27T18:15:03.226Z

closure defines are also somewhere in @cljs.env/*compiler*, I think just [:options :closure-defines] but not sure

knubie 2021-05-27T18:16:12.226500Z

awesome, thanks!

Schpaa 2021-05-27T18:26:53.227Z

how did you infer that “firebase$default” was needed in the require

Schpaa 2021-05-27T18:27:26.227200Z

require(‘firebase’).default as it is in js

Schpaa 2021-05-27T18:27:49.227700Z

is this a translation that is only applicable to shadow-cljs?

Schpaa 2021-05-27T18:28:35.228300Z

I cannot find anything in the docs related to adding a $default to the name required

Schpaa 2021-05-27T18:29:01.228700Z

Perhaps I’m formulating this somewhat obtuse

Schpaa 2021-05-27T18:29:36.229200Z

I just dont know where to look and I feel I have no threads to follow

thheller 2021-05-27T19:15:16.230200Z

@schpaencoder if you look at the translation table https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages you'll see the use of :default, more here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports. that is a shadow-cljs only thing that was rejected from CLJS, instead it added the $default thing in the recent release. see https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces

Schpaa 2021-05-27T19:16:01.230700Z

oh, never seen that before

thheller 2021-05-27T19:16:41.231300Z

so the $ really is just sugar for accessing properties directly, ["firebase" :as firebase] and firebase/default is also valid.

thheller 2021-05-27T19:17:01.231600Z

which would equate to the require(‘firebase’).default variant, as does "firebase$default"

Filipe Silva 2021-05-27T21:09:28.233500Z

@thheller I have a bit of a weird question for you: when I have a shadow-cljs server running for a web app, and the browser has the web app open, if the app is unresponsive I will get a message about shadow-cljs reconnecting. How do you display that message?

Filipe Silva 2021-05-27T21:10:30.234700Z

I ask because I just saw that message pop up while the web app was blocked on a synchronous 30s transit deserialization call, which surprised me because nothing else should be able to run.

mauricio.szabo 2021-05-27T22:10:57.236200Z

Hi @thheller. I just started an app that I need to use deps.edn. I just tried to add nextjournal.clojure-mode and shadow-cljs on dependencies, configured a simple browser app, but I'm seeing the following error on console:

cljs$core$ExceptionInfo {message: "failed to encode relay msg", data: {…}, cause: null, name: "Error", description: undefined, …}
eval @ shared.cljs:229
eval @ shared.cljs:229
shadow$remote$runtime$api$relay_msg @ api.cljc:4
...

mauricio.szabo 2021-05-27T22:14:23.236800Z

I downgraded to 2.12.7, the error is gone and the browser can connect to the running instance