Pardon me for the vague question-issue here. I'm not quite sure what part of the guanlecoja stack this is related to.
I have a buildbot plugin which was working but it has one rather large source file that I'm trying to break up into several smaller source files. For example i have coffeescript a class called ConsoleUIHelpers which I broke into a separate file. Now I'm getting ReferenceError: ConsoleUIHelpers is not defined
Searching the scripts.js that some part of the guanlecoja framework is outputting I do find my class in the outputted code:
(function() {
var ConsoleUIHelpers, consoleUIHelpers,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
ConsoleUIHelpers = (function() {
...
}).call(this);
which appears before the code which is failing with the ReferenceError
It's not clear to me where/why the code is getting surrounded by the (function() { ... }).call(this)
, but that seems to be what is preventing the subsequent code from having ConsoleUIHelpers as an identifier that it can access.
When I pass my class through a regular-old coffeescript-to-js conversion it does not surround it with (function() { ... }).call(this)
, so I'm guessing that it is coming from some other part of the guanlecoja framework, but i have no idea which piece of technology does this.
from reading https://stackoverflow.com/questions/2421911/what-is-the-purpose-of-wrapping-whole-javascript-files-in-anonymous-functions-li, I'm assuming that surrounding the code with (function() { ... }).call(this)
is some kind of namespacing mechanism, though the examples in that stack overflow do something like var myPlugin = (function() { ... }).call(this)
which then gives an identifier with which to access the contents of the namespace.
Apologies for my ignorance, I don't even know what to research in this case since reading about "coffeescript exports", "coffeescript modules" etc. turned up nothing that seemed relevant. I'm familiar with require.js but it doesn't appear to be being used anywhere in buildbot's front-end code, and can't find any examples of any sort of require/import statement to go off.