Fork me on GitHub
#shadow-cljs
<
2018-06-24
>
smnplk11:06:16

If I add ["firebase/firebase-firestore" :as db], I get the following error. failed to load module$node_modules$firebase$firebase_firestore

smnplk14:06:19

@thheller nope, I get "could not find module-entry: firebase/app." I am using firebase version 5 npm package, but you are using ver 4.

thheller14:06:58

I have not used any firebase at all so I don't know exactly

thheller14:06:51

but typically firebase had "side-effecting" requires

thheller14:06:04

so you only had one main require and the others didn't return anything

thheller14:06:15

and instead just added stuff onto the firebase main thing

smnplk14:06:21

@thheller Yeah I know, but I am trying to use es6 module packaging thingie, where you can require only what you need.

thheller14:06:48

yes thats what the demo above does

smnplk14:06:04

I could probably require the whole thing with (:requie ["firebase" :as fb])

thheller14:06:57

firebase/app used to be an alias for @firebase/app so maybe the alias is just gone?

smnplk14:06:06

yes, but demo above is using firebase ver 4. If I use the import from demo in my code, which uses firebase ver 5 package, it doesnt compile

smnplk14:06:47

i think it's now firebase/firebase-app.

thheller14:06:30

@firebase/app still exists when I npm install firebase

thheller14:06:00

"firebase": "^5.1.0"

thheller15:06:07

@smnplk I get Uncaught ReferenceError: firebase is not defined when trying to load firebase/firebase-firestore so it seems like you are not meant to use those files directly when using a build tool

thheller15:06:28

seems like they are made for direct <script src=...> inclusion

thheller15:06:31

["@firebase/app" :default fb]
    ["@firebase/firestore"]

thheller15:06:35

seems to work fine?

bbss15:06:44

I'm having an issue with releasing, in my chrome-ext with which I develop locally it works but when using shadow-cljs release dev it doesn't anymore. One of the node_modules deps is an empty object when importing.

thheller15:06:10

might be externs? do you have :infer-externs :auto turned on?

bbss15:06:03

reading up on the article

smnplk15:06:23

@thheller I see. But we aren't suppose to use "@firebase" packages directly

thheller15:06:03

@bbss I'm confused. you said chrome-ext but the :dev build is a browser build?

bbss15:06:29

yes, I'm just doing the chrome-ext for development.

bbss15:06:54

I'm doing that so I can develop with the web-page from my production server

bbss15:06:37

It might be possible to do that without a chrome extension.. I'm not sure :thinking_face: .

thheller15:06:49

sorry I'm lost. your cljsc2.cljs.core imports a bunch of chrome specific apis

bbss15:06:26

Oh, yeah it does. Those are not used anymore I think.

bbss15:06:54

I don't think the issue I'm having now is related to the chrome-ext. Sorry for the misdirection.

thheller15:06:17

so shadow-cljs watch dev works?

thheller15:06:33

I can't figure out this project. seems to be a bit all over the place

bbss15:06:28

Yeah.. It's a bit of a mess, in the process of cleaning it up right now. But still a lot of imports that aren't needed.

bbss15:06:24

the shadow-cljs watch dev seems to work. but with externs on I do get some warnings: Cannot infer target type in expression (. (gdom/getElement "notebook-container") prepend el)

thheller15:06:35

thats fine but you are using :optimizations :simple anyways so its probably not externs

smnplk15:06:49

nope. TypeError: module$node_modules$$firebase$app$dist$index_cjs.initializeApp is not a function

thheller15:06:32

:as vs :default?

smnplk15:06:15

the above type error is if I use :as , If I use :default, I get "BUILD-WARNING in app/firebase.cljs at [13:2] No such namespace: firebase, could not locate firebase.cljs, firebase.cljc, or JavaScript source providing "firebase""

thheller15:06:29

["@firebase/app" :default fb]
    ["@firebase/firestore"]

thheller15:06:36

(.initializeApp fb ...)

smnplk15:06:44

I asked because it complained about undeclared Var before, I had to restat shadow, now it looks like it's working fine. Thank you kind sir 🙂

bbss15:06:48

is there something wrong with my import syntax maybe? I tried making the first parinfer-codemirror a string. But that didn't change it.

thheller15:06:11

{:forceBalance true} looks wrong. probably should be #js {:forceBalance true}?

bbss15:06:08

hmmm, I'll try. but if I js/console.log parinfer-codemirror it seems to be an empty object, so init is not defined.

thheller15:06:48

just did a release build with parinfer-codemirror and the object is not empty

thheller15:06:20

nope. I just tested with that version. works fine

bbss15:06:04

Hmm, I'm not really sure why for me the import is not working then.

thheller15:06:13

check if node_modules/parinfer-codemirror/parinfer-codemirror.js is the actual file you want?

bbss15:06:31

Yes, it is the one I want. In my chrome-ext it does work. Interestingly in that file codemirror is defined, but the parinfer and parinfer-codemirror are both empty objects. Both are from the same author so could it be the exporting syntax is the culprit?

thheller15:06:58

it works absolutely fine for me

thheller15:06:02

so it must be something in your setup

bbss15:06:22

Okay, I'll dig deeper. I am loading it into a jupyter notebook, and it might be somehow the module systems are clashing

bbss16:06:12

However the codemirror import does have the version from npm, and the one used by jupyter notebook is a different version.

bbss16:06:10

No errors/relevant warnings. 😕

thheller16:06:14

maybe jupyter is using require.js? amd?

bbss16:06:24

yes, it is.

thheller16:06:07

that is checked first so it attempts to make require.js happy

thheller16:06:12

and doesn't get to the part we need

bbss16:06:07

Ah, I will edit the file in node_modules.

thheller16:06:03

probably not a good idea

thheller16:06:35

I know nothing about jupyter but maybe there is a way for you to remove the define?

bbss16:06:59

something like window.define = undefined after the jupyter notebook js?

thheller16:06:17

that might do it? I have no idea how/when jupyter loads the code

bbss16:06:31

yep! included a (:require ["definedeleter.js"] in the file, does the trick!

bbss16:06:47

@thheller thanks so much once again!

thheller16:06:07

@bbss you can also use :entries [..] :prepend "window.define = undefined;" in your :modules config

👌 4
thheller16:06:49

maybe even :prepend "window.defineOriginal = window.define; window.define = undefined;" :append "window.define = window.defineOriginal;"

thheller16:06:14

so its restored properly when CLJS is finished loading

thheller16:06:26

I could probably add a fix for this so the define branch is never taken in amd wrapped files

thheller16:06:33

since we never want that

bbss16:06:15

The prepend append is even cleaner, and it works 🙂 Thanks again.

bbss16:06:40

Thanks for sticking with me and my ridiculously exotic set-ups 😅

thheller16:06:14

you could definitely clean up a little 😉

bbss16:06:52

Hahah, yes for sure.. This weekend was already a big improvement though. Went from a very biiiig main file to splitting it up into somewhat reasonable namespaces.

bbss16:06:14

Recompile times were getting to 20 seconds. Now down to sub second again.

bbss16:06:53

Only dev.. so I'm not too hard on myself 😄