Fork me on GitHub
#shadow-cljs
<
2018-06-21
>
caleb.macdonaldblack04:06:02

A dependency I’m using uses cljsjs firebase and I’m getting The required namespace "firebase.app" is not available, it was required by "com/degel/re_frame_firebase/core.cljs". In the firebase cljsjs library it seems to export firebase.app like this:

{:file "cljsjs/development/firebase-app.inc.js"  :provides ["firebase.app"]}
I’ve installed firebase app and firebase through npm but it is not picking it up. How would shadow-cljs know to point firebase-app to firebase.app? Just wondering how I would begin to fix this

justinlee04:06:32

@caleb.macdonaldblack is something you are using still requiring something through cljsjs? If so, you need to shim the cljsjs file. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs

justinlee04:06:35

otherwise, if this is your file, you just add something like [firebase :as firebase] to your (require...) vector

caleb.macdonaldblack04:06:31

Yea this it another dependency requiring. The link you sent looks like it exactly what I need. Thank you!

justinlee04:06:49

okay yea, just create that little file and it should work

caleb.macdonaldblack05:06:20

I am still having trouble here. the library is requiring it like this: [firebase.app :as firebase-app]

caleb.macdonaldblack05:06:02

and in the cljsjs package it is setting it up to work on the firebase.app namespace with the :provides option in the deps.cljs

caleb.macdonaldblack05:06:49

I’m looking at this repo: https://github.com/thheller/shadow-cljsjs for examples but none of them help me here

justinlee06:06:07

I thought you’d need to something like (ns firebase.app (:require ["firebase" :as firebase])) (js/goog.exportSymbol "firebase" firebase))

caleb.macdonaldblack06:06:57

oh i see your namespace is firebase.app I didn’t take notice of that

justinlee06:06:25

the thing i’m not sure about is whether that export is right

caleb.macdonaldblack06:06:32

Yea that did it. I was wondering what was with the weird file structure in the shadow-cljsjs repo. It was matching the required namespace

justinlee06:06:23

oh good i’m glad that worked

albert.lai14:06:37

Recently, I try to change my project using this amazing shadow-cljs. It is a great success! I love the idea, the build tools itself is built as a library. I want to take this one step further, if all the internal api could take a map instead of hard coded to (config/load-cljs-edn), it would be easier to integrate with other libraries (like Component/Integrant).

albert.lai14:06:27

Another idea is we can have api to access the data in manifest.edn, it would be very useful information for adding caching list in serviceworker.

albert.lai14:06:51

@thheller don’t know if they are good ideas for shadow-cljs

thheller14:06:25

@albert.lai you have access to all the data. not sure what you want to do with it.

thheller14:06:54

integrating with component/integrant should be pretty straightforward. config file isn't going away for the time being though.

albert.lai15:06:06

https://github.com/duct-framework/server.figwheel, I am trying to integrate shadow-cljs to duct framework. everything is working, the only different is the shadow-cljs’s config is not inside the system map. This make sharing information abit indirect. e.g. the webpush’s application server key string must first export to environment variable for shadow-cljs to include.

thheller15:06:57

I reaaaaaaaaallly do not recommend running shadow-cljs as part of your clojure server

💡 4
thheller15:06:19

I wouldn't do this with figwheel either though

thheller15:06:20

In my production app I have a "component" which just watches for changes to the manifest.edn

thheller15:06:31

so I compile elsewhere and rsync the compiled output to the production server

thheller15:06:38

you can run it as part of your server if you really want but you are just making life harder IMHO

thheller15:06:53

if you run it standalone you get a couple of benefits

thheller15:06:04

like automatically recompiling when you change your config

thheller15:06:34

and way less dependency conflicts

albert.lai15:06:08

I know your idea. But duct will only load figwheel in development mode, figwheel will be excluded in production.

albert.lai15:06:54

But, yes, it did have more chance to have dependency conflicts..

thheller15:06:09

I understand that the goal is to start everything at once but to me it just looks way more complicated than running them separately

albert.lai15:06:43

when it works, it works well. when it stop working, now we have a bigger mud ball. It might not worth the effort. Thanks for your explanation.

Jon17:06:24

I need some help on auto generated externs,

Jon17:06:53

I added ^js and :compiler-options {:infer-externs :auto} in my project, the warnings are gone.

Jon17:06:46

however is the js file generated the method name is still renamed.

Jon17:06:13

(.use app "/" (.static ^js express dir) (serve-index dir (clj->js {:icons true})))

Jon17:06:31

=>> client=local node server.js
Using default schema.
/Users/chen/repo/cirru/calcit-editor/dist/server.js:731
function Kv(){var a=ek.a(Hv),b=Bv(),c=mv.join(__dirname,"app");a=100+a;b.use("/",Bv.Yd(c),function(){var a=Ni(new u(null,1,[yj,!0],null));return Cv(c,a)}());b.listen(a);return Gi(P([["Serving local editor at ",x.a(Yq.blue(["",x.a(a)].join("")))].join("")]))}
                                                                                    ^

TypeError: Bv.Yd is not a function
    at Kv (/Users/chen/repo/cirru/calcit-editor/dist/server.js:731:85)
    at Function.<anonymous> (/Users/chen/repo/cirru/calcit-editor/dist/server.js:733:377)
    at $e (/Users/chen/repo/cirru/calcit-editor/dist/server.js:152:111)
    at /Users/chen/repo/cirru/calcit-editor/dist/server.js:733:270
    at Object.<anonymous> (/Users/chen/repo/cirru/calcit-editor/dist/server.js:734:3)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)

Jon17:06:00

Did I miss some steps?

thheller20:06:21

@jiyinyiyong try compiling with shadow-cljs release server --pseudo-names to confirm that it is actually that part of the code

thheller20:06:59

certainly looks like it but want to be sure

thheller20:06:45

check if the .shadow-cljs/builds/server/release/externs.shadow.js file contains the .static property

thheller20:06:56

static is one of those reserved "special" properties that the CLJS compiler will munge

thheller20:06:05

but then your code wouldn't work in dev either

thheller20:06:46

@jiyinyiyong just saw that you use .static express when express is a ns :as alias. try express/static instead. that has protection against the built-in munging from the CLJS compiler

thheller20:06:54

I think the issue is that static gets renamed to static$ by the cljs compiler and your code isn't used in dev so you only notice it on release?

thheller20:06:37

oh right or set :compiler-options {:language-out :ecmascript5} maybe

thheller21:06:49

@jiyinyiyong found it. fixed in 2.4.8. it was in my externs generation code which munged reserved properties when it shouldn't have.

theasp23:06:41

How did you know I was going to ask about that??? 😉