Yeah modules are a must. Right now we need to do the following,imports.searchPath.unshift(".");const ModName = imports.filenameThen all functions, variables etc become available under our constant ModName,which is not what we always want. Many modules might want to expose just one or 2 objects/methods while keeping everything private.
This also has another problem, since there is no way to know the current directory in which the file is situated, you really cannot have modules in a subdirectory.
ES6 modules will solve this problem. But then what will happen to the current method? It'll suck to use imports for the core libraries and the import ModName from filename syntax for third party libraries.
On 2015-03-07, 19:54 GMT, Emmanuele Bassi wrote:
>> it would be nice that developer documentation of gjs would be extended,
>> also with examples of how to write a module in a *modern* and *easy*
>> way...
>
> What do you mean "write a module in a modern and easy way"?
> What kind of module?
>
> Not saying that the documentation is good — because it isn't — but it
> would help to specify what you want to achieve, and what were the
> obstacles you met. I'm sure we can make the documentation at least
> passable, if not good.
Perhaps he is talking about ES6? I believe when it will be in
the Spidermonkey (or whatever monkey is now running underneath
GJS) we will have modules, classes, etc. as well. See
https://hacks.mozilla.org/category/es6-in-depth/ and
https://bugzilla.mozilla.org/show_bug.cgi?id=694100
I cannot get it soon enough, for example.