Fork me on GitHub
#cljsjs
<
2017-03-01
>
shaun-mahood16:03:50

@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.

martinklepsch16:03:05

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

martinklepsch16:03:14

if not the packaging is almost certainly broken

shaun-mahood17:03:04

@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.

juhoteperi19:03:09

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

juhoteperi19:03:38

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

juhoteperi19:03:01

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

juhoteperi19:03:11

perhaps openlayers 4 doesn't need externs?

juhoteperi19:03:03

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

juhoteperi19:03:27

repository contains the files

juhoteperi19:03:31

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

bleadof19:03:35

@juhoteperi Seems like the Circle CI stumbled:

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

juhoteperi19:03:47

just random failure

bleadof19:03:13

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

shaun-mahood19:03:43

@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. šŸ™‚

juhoteperi20:03:16

@shaun-mahood Already fixed, update the package

juhoteperi20:03:48

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

shaun-mahood20:03:16

@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?

juhoteperi20:03:15

extern files only need to be mentioned in deps.cljs

juhoteperi20:03:42

and they are on cljsjs jar file

shaun-mahood20:03:16

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?

juhoteperi20:03:55

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

juhoteperi20:03:18

Closure modules work the same as Cljs namespaces

shaun-mahood21:03:29

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.

juhoteperi21:03:05

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

juhoteperi21:03:11

it is only used by Closure compiler

shaun-mahood21:03:58

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

juhoteperi21:03:03

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

juhoteperi21:03:19

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

juhoteperi21:03:32

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

shaun-mahood21:03:01

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.

juhoteperi21:03:30

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

juhoteperi21:03:10

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

shaun-mahood21:03:46

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!