Fork me on GitHub
#cljsjs
<
2018-02-27
>
jmckitrick11:02:19

I’d like a little help with 2 npm react packages I’d like to see in cljsjs. Can someone point me in the right direction?

jmckitrick15:02:16

When I run them through the 2 extern generators online, I get the same response, namespace not found.

jmckitrick17:02:25

Hi all, I’m trying to import 2 packages I need. Both are react components, and both are failing during the extern generation process.

jmckitrick17:02:29

Any suggestions?

frozenlock17:02:13

How are they failing? What's the error?

jmckitrick17:02:08

Hi. Let me check….

jmckitrick17:02:55

Both complain that the namespace is not found.

frozenlock17:02:00

in the console?

jmckitrick17:02:22

One ends with ‘exports.default = FooBar’

jmckitrick17:02:05

where FooBar is the namespace I want. The other is minified, but has ‘e.FooBar=’ near the beginning. So both should be exporting the namespace I want.

jmckitrick17:02:19

The errors are in the browser version, but the same errors appear at the CLI

frozenlock17:02:44

I might have misunderstood... did you generate the externs with http://jmmk.github.io/javascript-externs-generator/ ?

jmckitrick17:02:49

`Error generating extern Namespace ‘AvatarEditor’ was not found. Make sure the library is loaded and the name is spelled correctly`

frozenlock17:02:20

Is there an error in the browser's console?

jmckitrick17:02:16

Uncaught TypeError: Cannot read property ‘Component’ of undefined

jmckitrick17:02:27

the other says: exports is not defined

frozenlock17:02:26

Right, that's the same error I got yesterday and asked here for what to do.

frozenlock17:02:42

I think it has to do with the js not being generated/compiled for the browser.

jmckitrick17:02:40

You mean minified?

jmckitrick17:02:48

It seems one of mine is minified, the other not.

frozenlock17:02:44

Don't you get the same error even with the non-minified version?

frozenlock17:02:14

(of the same library)

jmckitrick17:02:15

I haven’t tried. One of the libs comes minified, the other does not.

jmckitrick18:02:12

@frozenlock What library are you trying to import?

jmckitrick18:02:09

So yours is webpacked. It looks different from both of mine.

jmckitrick18:02:14

So all 3 are failing, lol.

jmckitrick18:02:29

I’m curious about ES6 and the different styles of dependency requirements (I forget the names, I’m not a JS guy) because they aren’t mentioned in the docs on how to generate the externs.

frozenlock18:02:52

Yeah, I'm about to give up and just use lein-externs and include the minified js directly in the header.

jmckitrick18:02:11

Yeah, I’m about to give up as well.

jmckitrick18:02:22

So wait, lein-externs might work?

frozenlock18:02:55

Yes. It generates externs by looking at what methods are used in your code.

jmckitrick18:02:57

I’m having issues getting the file to import. It’s loading, but I’m getting errors anyway.

jmckitrick18:02:11

Hmm. I’m using :foreign-libs but maybe I’ll try that.

jmckitrick18:02:21

Yeah I got it running….

jmckitrick18:02:40

I’m still getting console errors when referring to the library in cljs… but I’ll keep hacking away.

jmckitrick18:02:34

Do I need foreign-libs as well?

frozenlock18:02:39

I don't think so. When I'm using an external library I load it directly in the webpage and add ":externs ["externs.js"]" to the cljsbuild configs

frozenlock18:02:54

(assuming you generated the externs to externs.js)

frozenlock18:02:54

Just make sure you load it after react.

frozenlock18:02:19

cljsjs would of course be cleaner 😞

jmckitrick18:02:24

Hmm. I’m already importing React via Reagent.

jmckitrick18:02:02

So I’m getting errors in the externally including script where it chokes on ‘PropTypes’

frozenlock18:02:33

And where are you loading your external library? Before or after your app.js?

jmckitrick18:02:11

It’s last in the list right now, after app.js

frozenlock18:02:55

Sounds good. I'm afraid you'll have to google your errors from this point on 😕

jmckitrick18:02:33

Wait, I might be onto something.

jmckitrick18:02:10

False alarm. I’m dead in the water 😞