cljsjs

shaun-mahood 2017-03-01T16:57:50.001214Z

@martinklepsch: I didn't even know this channel existed, awesome! So openlayers seems to be a kind of unique package as it has both Closure and normal externs. For the externs in the deps.cljs file, it points everything to the cljsjs/openlayers/common folder - but when I go to that folder in the JAR file there's nothing there. I assume the externs files at the very least should be there, is that correct? Do the full .js files also have to be included in the JAR for it to work? I've only started looking into all of this earlier this week so my understanding is still pretty minimal.

martinklepsch 2017-03-01T16:59:05.001215Z

@shaun-mahood is there a bunch of stuff in the cljsjs/openlayers/development/ directory in that jar?

martinklepsch 2017-03-01T16:59:14.001216Z

if not the packaging is almost certainly broken

shaun-mahood 2017-03-01T17:42:04.001217Z

@martinklepsch: Yes, the development directory has a bunch of stuff in it - looks like all the same GClosure files as in openlayers. Openlayers also has some docs on compiling your own application with GClosure as well (https://openlayers.org/en/latest/doc/tutorials/closure.html), and it includes some externs files on top of the openlayers ones - but I can't find those externs files, or the ones included in the deps.cljs under :externs in the JAR file.

juhoteperi 2017-03-01T19:23:09.001221Z

@shaun-mahood Looks like version 4 changed the externs in openlayers

juhoteperi 2017-03-01T19:23:38.001222Z

but the release zip now has ol.ext folder, instead of externs folder which is used by the packaging script

juhoteperi 2017-03-01T19:25:01.001223Z

but ol.ext files seem to be something else, not externs

juhoteperi 2017-03-01T19:25:11.001224Z

perhaps openlayers 4 doesn't need externs?

juhoteperi 2017-03-01T19:27:03.001225Z

aha, the release zip doesn't contain the externs even in older versions

juhoteperi 2017-03-01T19:27:27.001226Z

repository contains the files

juhoteperi 2017-03-01T19:30:31.001227Z

the repository has been renamed -> the folder inside archive is also renamed -> regexes are broken

bleadof 2017-03-01T19:47:35.001231Z

@juhoteperi Seems like the Circle CI stumbled:

clojure.lang.ExceptionInfo: User limit of inotify watches reached

juhoteperi 2017-03-01T19:47:47.001232Z

just random failure

bleadof 2017-03-01T19:47:50.001233Z

I know

bleadof 2017-03-01T19:48:13.001234Z

Just thought Iā€™d say šŸ™‚

shaun-mahood 2017-03-01T19:59:43.001242Z

@juhoteperi: Ok, so the cljsjs package doesn't have everything that it needs. I'm going to try and figure out how compile a JS app with Google Closure then, and I'll see about updating the cljsjs package after that (once I understand it well enough). Openlayers seems like it's more complicated than most things - but I really don't want to have to write my programs in JS so I'm pretty motivated to figure it out. šŸ™‚

juhoteperi 2017-03-01T20:01:16.001244Z

@shaun-mahood Already fixed, update the package

juhoteperi 2017-03-01T20:02:48.001245Z

@shaun-mahood Also, depending on your mapping needs, I can recommend Leaflet. I guess it is a bit higher level lib.

shaun-mahood 2017-03-01T20:15:16.001246Z

@juhoteperi: Oh cool, thanks! I'll try the new package and see. The main reason I wanted to use openlayers is because I figured it would work better with CLJS, so maybe I'll try leaflet too and see if it's a good fit. I'm not sure what my mapping needs are quite yet. I get the same error as before, but it's entirely possible I'm doing something else wrong - I'm not super clear on what is necessary for working with externs. If I needed to use the functions from one of those extern files (say bingmaps.ext.js), then I need to have bingmaps.js accessible from somewhere, right? Should it be in the CLJSJS JAR file as well, or would I just include it in my HTML file?

juhoteperi 2017-03-01T20:16:15.001247Z

extern files only need to be mentioned in deps.cljs

juhoteperi 2017-03-01T20:16:42.001248Z

and they are on cljsjs jar file

shaun-mahood 2017-03-01T20:23:16.001249Z

Ok, so the jar file includes the extern files, but if my code uses any of those functions then I will need to have included the original .js file in my html beforehand, right?

juhoteperi 2017-03-01T20:24:32.001250Z

no

juhoteperi 2017-03-01T20:24:55.001251Z

as openlayers is Closure lib, you only need to require the module where the function is defined

juhoteperi 2017-03-01T20:25:18.001252Z

Closure modules work the same as Cljs namespaces

shaun-mahood 2017-03-01T21:18:29.001253Z

I think I've got most of how to use the Closure lib part at least mostly understood, my main confusion right now is that openlayers is a Closure lib with externs as well - so if we look at the extern for jQuery as an example, if I want to call one of the jQuery methods that's listed in the extern, where does the code to run the actual jQuery functions come from? Is it all included as part of the extern, or does it have to be included as part of the code with the closure modules, or on your page? Some of the other CLSJS jars I've got also have the original JS files included so I'm a little confused as to what is necessary in this case.

juhoteperi 2017-03-01T21:20:05.001254Z

extern doesn't have anything to do with the real code

juhoteperi 2017-03-01T21:20:11.001255Z

it is only used by Closure compiler

shaun-mahood 2017-03-01T21:20:58.001256Z

Ok, glad that I got that part right at least šŸ™‚

juhoteperi 2017-03-01T21:21:03.001257Z

Nearly all Cljsjs packages include the real sourcecode, and that is automatically included as part of your application

juhoteperi 2017-03-01T21:21:19.001258Z

In dev it is dynamically loaded similar to how compiled Cljs and Closure output files are loaded

juhoteperi 2017-03-01T21:21:32.001259Z

And in optimized build the foreign library source is prepended to the output file

juhoteperi 2017-03-01T21:22:26.001262Z

https://clojurescript.org/guides/externs

shaun-mahood 2017-03-01T21:33:01.001263Z

Ok, I think I've got the basics of that for both the purely externs packages and for the pure Closure packages. Still unclear on where the sourcecode for the externs in openlayers are coming from - the externs are there but I can't find the original jQuery source in either the CLJSJS package or the the node package they use to compile (https://openlayers.org/en/latest/doc/tutorials/closure.html). Openlayers has a custom node application that they use to compile your own app and their source code together - could they be using that to include the source files that are required? Thanks for the help, even if I'm not getting anywhere yet as far as getting things to work it's definitely helping me understand things better.

juhoteperi 2017-03-01T21:35:30.001264Z

I don't think jquery is required for openlayers? It is probably optional

juhoteperi 2017-03-01T21:36:10.001265Z

cljsjs openlayers doesn't even include the jquery extern (in deps.cljs)

shaun-mahood 2017-03-01T21:52:46.001267Z

Yeah, I think that's probably the case - it's included in their node_module under externs but not listed in their instructions for building it by default. It looks like most of the other externs have a matching source file somewhere though. I've managed to get to the point where I hit the same error using CLJS (with the old package missing the externs) and by including the JS files manually and building a Closure application (just by adding files that Closure complains about). My suspicion is that I'm missing a dependency that I don't know about, and I've narrowed it down to a particular line where the working JS example returns a value and my bad translations return null. I'm going to see if I can get the Closure version working first with their custom compiler (or manually and painfully) so I can track down what I'm missing. Thanks again for the help!