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?
When I run them through the 2 extern generators online, I get the same response, namespace not found.
Hi all, I’m trying to import 2 packages I need. Both are react components, and both are failing during the extern generation process.
Any suggestions?
How are they failing? What's the error?
ping @jmckitrick
Hi. Let me check….
Both complain that the namespace is not found.
in the console?
One ends with ‘exports.default = FooBar’
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.
The errors are in the browser version, but the same errors appear at the CLI
I might have misunderstood... did you generate the externs with http://jmmk.github.io/javascript-externs-generator/ ?
Yes
`Error generating extern Namespace ‘AvatarEditor’ was not found. Make sure the library is loaded and the name is spelled correctly`
Is there an error in the browser's console?
Uncaught TypeError: Cannot read property ‘Component’ of undefined
the other says: exports is not defined
Right, that's the same error I got yesterday and asked here for what to do.
I think it has to do with the js not being generated/compiled for the browser.
You mean minified?
It seems one of mine is minified, the other not.
Don't you get the same error even with the non-minified version?
(of the same library)
I haven’t tried. One of the libs comes minified, the other does not.
@frozenlock What library are you trying to import?
So yours is webpacked. It looks different from both of mine.
So all 3 are failing, lol.
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.
Yeah, I'm about to give up and just use lein-externs and include the minified js directly in the header.
Yeah, I’m about to give up as well.
So wait, lein-externs might work?
Yes. It generates externs by looking at what methods are used in your code.
I’m having issues getting the file to import. It’s loading, but I’m getting errors anyway.
Hmm. I’m using :foreign-libs but maybe I’ll try that.
@jmckitrick https://clojars.org/org.clojars.rasom/lein-externs
Yeah I got it running….
I’m still getting console errors when referring to the library in cljs… but I’ll keep hacking away.
Do I need foreign-libs as well?
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
(assuming you generated the externs to externs.js)
Just make sure you load it after react.
cljsjs would of course be cleaner 😞
Ah, ok.
Hmm. I’m already importing React via Reagent.
So I’m getting errors in the externally including script where it chokes on ‘PropTypes’
And where are you loading your external library? Before or after your app.js?
It’s last in the list right now, after app.js
Sounds good. I'm afraid you'll have to google your errors from this point on 😕
Wait, I might be onto something.
False alarm. I’m dead in the water 😞