Fork me on GitHub
#shadow-cljs
<
2020-04-10
>
martinklepsch09:04:51

I’m seeing some weird differences between plain node and Shadow’s npm module thing. At first I thought it is an issue with Firebase but it looks like the issue might be related to Shadow’s module processing?

$ node

> const admin = require('firebase-admin');
undefined
> admin.initializeApp();
FirebaseApp { ... }
> const functions = require('firebase-functions')
undefined
> functions.config()
{}
> functions.config().constructor
[Function: Object]
> functions.config().constructor == Object
true
$ npx shadow-cljs cljs-repl :functions

shadow-cljs - config: /Users/martinklepsch/code/06-commercial/icebreaker/shadow-cljs.edn  cli version: 2.8.37  node: v10.16.3
shadow-cljs - connected to server
> (.-constructor (.config fb-functions))
#js {:some :js-obj}
> (object? (.config fb-functions))
false

martinklepsch09:04:04

> (.config fb-functions)
== JS EXCEPTION ==============================
ENCODING FAILED, check host console
==============================================

thheller09:04:17

not entirely sure I see the issue?

thheller09:04:25

do you mean the failing object? check?

thheller09:04:52

because that is not what == Object does?

thheller09:04:22

and literally everything is true for == Object so I don't quite see the point of that check?

martinklepsch10:04:35

Yes I mean the failing object check + the fact that the data that should be returned by .config() is instead returned if you access the constructor. There are some clear differences between these two repl sessions that don’t make sense, no?

thheller10:04:32

don't use object? basically

thheller10:04:25

it only returns true for anything {}

thheller10:04:39

but not anything with a prototype which this is likely returning

thheller10:04:12

whats the actual issue though?

thheller10:04:41

that printing fails can have a variety of reasons

thheller10:04:10

check the browser console. might be a circular reference, might include a js/Symbol, etc

thheller10:04:59

try (js/console.dir (.config functions)) or so

martinklepsch11:04:10

the actual issue is that it can’t be converted using clj->js or cljs-bean

martinklepsch11:04:33

(js/console.dir (.config functions)) logs the config data to the console

martinklepsch11:04:13

js/console.log does too actually

martinklepsch11:04:14

This is a basic question I guess: how do I create a thing “with a prototype” that would allow me to reproduce this behavior outside of firebase’s config stuff?

thheller13:04:08

"this behavior" of not working?

thheller13:04:45

I still don't know what you actual issue is? you want the config data as a CLJS map?

👍 4
thheller13:04:24

you can try (shadow.json/to-clj (.config functions))

martinklepsch16:04:47

I tried the shadow.json thing. I could require the namespace but running to-clj doesn’t exist somehow

jjttjj14:04:43

Is there an obvious reason bootstrapping cljs would work perfectly in dev mode but when I do a release I get Cannot read property 'findInternedVar' of null when using eval-str Here is my http://shadow.cl-cljs.edn

{:deps true
 :builds
 {:app
  {:target     :browser
   :output-dir "resources/public/js"
   :asset-path "/js"
   :compiler-options {:optimizations :simple}
   :modules    {:main {:entries [jt.jt16]}}
   :devtools   {:repl-init-ns jt.jt16}}
  :bootstrap-support
  {:target     :bootstrap
   :output-dir "resources/public/bootstrap"
   :exclude    #{cljs.js}
   :entries    [javelin.core diy.core diy.hoplon.tpl #_ui]
   :macros     []}}}

thheller14:04:03

somewhere x.findInternedVar() is called where x is nil

thheller14:04:31

so find out where that is. stacktrace should show that. dunno why though.

jjttjj14:04:34

Also getting a bunch of

main.js:3742 Uncaught ReferenceError: goog is not defined
    at eval (/bootstrap/js/3bcbd8d8.cljs.core$macros.js:1)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:461)
    at Object.shadow.cljs.bootstrap.browser.script_eval (main.js:10070)
    at Object.shadow.cljs.bootstrap.browser.execute_load_BANG_ (main.js:10073)
    at main.js:10083
    at goog.async.run.processWorkQueue (main.js:3749)
type errors

jjttjj14:04:49

ok hmmm it seems like goog isn't defined when bootstrap/init tries to load the first bootstrap file and this is breaking all my eval-str calls

thheller16:04:20

ah rioght I remember now

thheller16:04:35

you need to set :compiler-options {:output-wrapper false} in your :app config

👍 4
jjttjj16:04:05

That did it, thanks so much!

Brad Kurtz18:04:36

Hello, I have a question about setting up shadow-cljs to work with vim-fireplace

Brad Kurtz18:04:29

I have it seemingly working, where I can eval stuff with piggieback in vim, but as soon as I save the file I'm in, I get a build failure saying >The required namespace "cljs.user" is not available.

Brad Kurtz18:04:01

I see now somebody else asked this yesterday