Fork me on GitHub
#cljsjs
<
2016-11-27
>
mikebelanger15:11:21

Hey has anyone tried the auto externs generator lately? I get a failed response for a certain file and I'm unsure why: http://www.dotnetwise.com/Code/Externs/index.html

mikebelanger15:11:49

I feel like I'm missing something

mikebelanger17:11:32

I'm wary of manually creating the externs simply due to the work (Tonejs is ~ 20k lines) and find out its not even compatible, but referencing this closed PR https://github.com/google/closure-compiler/pull/1048 (by a core cljs contributor) it looks like AMD modules are at the very least, Google Closure compatible. Might just be the auto-externs generator doesn't cover all usage cases, and I'll have to just manually do these externs 😞

juhoteperi17:11:09

And even if you need to create externs manually, you don't need to go through the code, it is easier to just go through API docs: https://tonejs.github.io/docs/#Split

mikebelanger17:11:10

@juhoteperi yes, I had to use the -> trick with that, and it just repeatedly hanged (using FF)

mikebelanger17:11:02

@juhoteperi you mean just list off each module in the API?

juhoteperi17:11:08

Pretty much yeah

juhoteperi17:11:16

Each class & their methods

juhoteperi17:11:13

There is also some change that Closure module processing world work in this case.

mikebelanger17:11:28

Tone.js has a lot of type annotations, do you think those would be useful to Closure compiler?

juhoteperi17:11:24

Not at least if you are using the lib as foreign-lib, with the concatenated file

mikebelanger17:11:31

Sorry, I don't know what you mean by concatenated file, like the minified file?

juhoteperi17:11:21

concatenated file = all source in one file, minified = all source in one file + minified

mikebelanger17:11:36

@juhoteperi Ah I see, thanks. I might just use the Tone.js source (un-minified, but concatenated), and delete everything in the blocks, and save it as an extern. There's a lot of prototypes, objects, etc.

juhoteperi17:11:27

That is one way.

juhoteperi17:11:01

But just keep in mind that only the public API matters, the functions you could call from Cljs

juhoteperi17:11:23

There are lots of internal functions that don't need to be present in the extern

mikebelanger17:11:00

@juhoteperi true, oh I see what you mean -- because if I cross-reference the API to figure out which functions are public vs. which aren't, I'm probably going to spend as much time doing that as just listing them off in a new file anyways.

juhoteperi17:11:56

Btw. they have TypeScript annotations which also lists the public API: https://github.com/Tonejs/TypeScript/blob/master/Tone.d.ts

mikebelanger18:11:11

@juhoteperi oh cool, good find! Translating that doesn't look like it would take nearly as long

mikebelanger18:11:37

@juhoteperi well thanks a lot for your help, its going to make my life much easier

mikebelanger20:11:34

Ok, I'm just writing them up, and seeing there's lots of methods inside of other prototype functions. Seeing that using this in externs is strongly discouraged, would the best bet be writing the full method name (ie Tone.Foo.prototype.bar = function() {})?

mikebelanger20:11:57

At least, it appears Google Closure doesn't like this due to its context-dependent reference http://stackoverflow.com/questions/13109358/javascript-this-keyword-and-closure-compiler-warnings

juhoteperi20:11:37

Full name is fine

mikebelanger23:11:02

alright thanks