cljsjs

jmckitrick 2018-02-27T11:29:19.000213Z

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?

jmckitrick 2018-02-27T15:00:16.000934Z

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

jmckitrick 2018-02-27T17:07:25.000848Z

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

jmckitrick 2018-02-27T17:07:29.000132Z

Any suggestions?

2018-02-27T17:08:13.000155Z

How are they failing? What's the error?

2018-02-27T17:08:53.000501Z

ping @jmckitrick

jmckitrick 2018-02-27T17:09:08.000326Z

Hi. Let me check….

jmckitrick 2018-02-27T17:09:55.000483Z

Both complain that the namespace is not found.

2018-02-27T17:10:00.000519Z

in the console?

jmckitrick 2018-02-27T17:10:22.000759Z

One ends with ‘exports.default = FooBar’

jmckitrick 2018-02-27T17:11:05.000540Z

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.

jmckitrick 2018-02-27T17:11:19.000658Z

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

2018-02-27T17:13:44.000042Z

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

jmckitrick 2018-02-27T17:15:33.000473Z

Yes

jmckitrick 2018-02-27T17:15:49.000801Z

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

2018-02-27T17:16:20.000119Z

Is there an error in the browser's console?

jmckitrick 2018-02-27T17:17:16.000710Z

Uncaught TypeError: Cannot read property ‘Component’ of undefined

jmckitrick 2018-02-27T17:17:27.000352Z

the other says: exports is not defined

2018-02-27T17:18:26.000548Z

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

2018-02-27T17:18:42.000036Z

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

jmckitrick 2018-02-27T17:19:40.000351Z

You mean minified?

jmckitrick 2018-02-27T17:19:48.000821Z

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

2018-02-27T17:20:44.000804Z

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

2018-02-27T17:21:14.000071Z

(of the same library)

jmckitrick 2018-02-27T17:21:15.000505Z

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

jmckitrick 2018-02-27T18:03:12.000447Z

@frozenlock What library are you trying to import?

jmckitrick 2018-02-27T18:04:09.000601Z

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

jmckitrick 2018-02-27T18:04:14.000704Z

So all 3 are failing, lol.

jmckitrick 2018-02-27T18:05:29.000218Z

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.

2018-02-27T18:05:52.000698Z

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

jmckitrick 2018-02-27T18:06:11.000522Z

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

jmckitrick 2018-02-27T18:06:22.000246Z

So wait, lein-externs might work?

2018-02-27T18:06:55.000005Z

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

jmckitrick 2018-02-27T18:06:57.000641Z

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

jmckitrick 2018-02-27T18:07:11.000006Z

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

jmckitrick 2018-02-27T18:11:21.000527Z

Yeah I got it running….

jmckitrick 2018-02-27T18:11:40.000611Z

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

jmckitrick 2018-02-27T18:12:34.000469Z

Do I need foreign-libs as well?

2018-02-27T18:17:39.000502Z

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

2018-02-27T18:17:54.000767Z

(assuming you generated the externs to externs.js)

2018-02-27T18:18:54.000341Z

Just make sure you load it after react.

2018-02-27T18:19:19.000541Z

cljsjs would of course be cleaner 😞

jmckitrick 2018-02-27T18:34:32.000575Z

Ah, ok.

jmckitrick 2018-02-27T18:37:24.000757Z

Hmm. I’m already importing React via Reagent.

jmckitrick 2018-02-27T18:38:02.000462Z

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

2018-02-27T18:40:33.000311Z

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

jmckitrick 2018-02-27T18:41:11.000499Z

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

2018-02-27T18:42:55.000351Z

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

jmckitrick 2018-02-27T18:43:33.000623Z

Wait, I might be onto something.

jmckitrick 2018-02-27T18:45:10.000038Z

False alarm. I’m dead in the water 😞