@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.
@shaun-mahood is there a bunch of stuff in the cljsjs/openlayers/development/
directory in that jar?
if not the packaging is almost certainly broken
@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.
@shaun-mahood Looks like version 4 changed the externs in openlayers
but the release zip now has ol.ext folder, instead of externs folder which is used by the packaging script
but ol.ext files seem to be something else, not externs
perhaps openlayers 4 doesn't need externs?
aha, the release zip doesn't contain the externs even in older versions
repository contains the files
the repository has been renamed -> the folder inside archive is also renamed -> regexes are broken
@juhoteperi Seems like the Circle CI stumbled:
clojure.lang.ExceptionInfo: User limit of inotify watches reached
just random failure
I know
Just thought Iād say š
@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. š
@shaun-mahood Already fixed, update the package
@shaun-mahood Also, depending on your mapping needs, I can recommend Leaflet. I guess it is a bit higher level lib.
@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?
extern files only need to be mentioned in deps.cljs
and they are on cljsjs jar file
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?
no
as openlayers is Closure lib, you only need to require the module where the function is defined
Closure modules work the same as Cljs namespaces
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.
extern doesn't have anything to do with the real code
it is only used by Closure compiler
Ok, glad that I got that part right at least š
Nearly all Cljsjs packages include the real sourcecode, and that is automatically included as part of your application
In dev it is dynamically loaded similar to how compiled Cljs and Closure output files are loaded
And in optimized build the foreign library source is prepended to the output file
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.
I don't think jquery is required for openlayers? It is probably optional
cljsjs openlayers doesn't even include the jquery extern (in deps.cljs)
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!