Fork me on GitHub
#clojurescript
<
2019-05-23
>
scknkkrer11:05:00

Hi guys. I wanted to use foreign-libs feature with my webpack result file. My purpose is using External Libraries with my Clojurescript project. Reagent with ReactStrap --bootstrap implementation for React--. I have exclude cljsjs.react and cljsjs.react.dom from dependency vector. In cljsbuild, I have give the foreign-libs entry;

[{:file "app/dev/js/bundle.js"
                                                              :provides ["cljsjs.react" "cljsjs.react.dom"]
                                                              :global-exports {react React
                                                                               react.dom ReactDOM}}]
But, repl gives me an error, and doesn’t compile my js file.
WARNING: 3 error(s), 0 warning(s)
ERROR: JSC_MISSING_PROVIDE_ERROR. required "module$Users$sckn$projects$business$qulak$desktopnew$node_modules$react$react" namespace never provided at /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/reagent/core.js line 4 : 0
ERROR: JSC_MISSING_PROVIDE_ERROR. required "module$Users$sckn$projects$business$qulak$desktopnew$node_modules$react$react" namespace never provided at /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/reagent/impl/component.js line 4 : 0
ERROR: JSC_MISSING_PROVIDE_ERROR. required "module$Users$sckn$projects$business$qulak$desktopnew$node_modules$react$react" namespace never provided at /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/reagent/impl/template.js line 4 : 0

scknkkrer11:05:15

It’s compiled now. But, when I run the script. It’s telling me;

goog.require could not find: module$Users$sckn$projects$business$qulak$desktopnew$node_modules$react$index

scknkkrer12:05:28

Is it true ?

scknkkrer12:05:49

@mfikes I have done it. Continue with this thread, please. It’s just spamming the main thread.

mfikes12:05:35

Cool. So, are you still seeing $node_modules$react$react embedded in your generated code?

scknkkrer14:05:58

Nope. I have update my foreign-libs value properly. And the problem is gone. One tip: If you want to override some namespaces with external libraries. You don’t have to exclude them from dependencies vector.

mfikes11:05:17

@scknkkrer In the long dollar-sign-separated symbols is node_modules. I'm wondering if it is picking up the dep in there.

scknkkrer11:05:40

I can upload my files.

scknkkrer11:05:06

It’s an template from called Descjop. Electron interfacer for Clojurescript.

mfikes11:05:43

I suppose that would also be the case if you ran through . Hrm.

mfikes11:05:15

@scknkkrer Do you have :npm-deps in your configuration?

mfikes11:05:29

It might be worth setting its value to false if you can, to avoid any interaction with that feature.

mfikes12:05:57

@scknkkrer Maybe move your node_modules out of the way? (Dunno how you can do that for your project.)

mfikes12:05:58

(I'd have to look at the code, but I would have thought that with it set to false the ClojureScript compiler would ignore that directory, not index it, etc.)

mfikes12:05:19

@scknkkrer You may also want to do a clean build, especially if your project had node modules as part of the game previously.

scknkkrer12:05:52

There is no pre-defined clean command. Give me a sec.

scknkkrer12:05:54

I don’t need it, I think. I just generate a file.

cgrand15:05:12

Hi! A quick search on jira turns nothing but peek on empty subvecs throws exceptions

cljs.user=> (peek (subvec [] 0 0))
#object[Error Error: No item -1 in vector of length 0]
while in clojure it returns nil.

cgrand15:05:19

Should I open a ticket?

mfikes16:05:38

@cgrand Indeed. Seems like a new bug.

cgrand16:05:42

and since subvec are “contagious” in cljs, the exception can arise quite far from the subveccall

cgrand16:05:22

like

cljs.user=> (peek (pop (conj (subvec [] 0 0) 3)))
#object[Error Error: No item -1 in vector of length 1]

mfikes16:05:56

Cool. On the surface, looks like an easy fix

$ clj -A:cljs/dev -re node -r
cljs.user=> (peek (subvec [] 0 0))
nil
cljs.user=> (peek (pop (conj (subvec [] 0 0) 3)))
nil

mfikes16:05:23

I can cobble together a proper patch with tests, etc. but this might be what is needed https://github.com/mfikes/clojurescript/commit/dd1ba02c8e1987172972411ffe6da1775fcfb518

cgrand16:05:03

you were faster to fix it than me to recover my jira password 😄

mfikes16:05:39

Well, my first fix above is incorrect. So... but anyway, will put together a proper one.

cgrand16:05:37

yes it’s more like (pos? (- end start))

Alex Miller (Clojure team)16:05:15

@cgrand if you have any trouble with getting in, let me know

cgrand16:05:25

@alexmiller I’m in now, the hardest part was figuring out the exit icon is in fact the “log in” icon https://files.slack.com/files-pri/T03RZGPFR-FJYCZT6GG/image.png

👍 8
ejelome21:05:49

Q: Is there any benefit to try Google Closure to better understand ClojureScript? I recalled that some examples in ClojureScript tutorials were actually fromGoogle Closure's that initially gave me some confusion.