Reputation: 6049
In another SO post here, the second option is to write G.this;
in the first "top" file in order to create a namespace.
And then write "use strict" on the top of every other js file.
Is that all the content of such a file? and if so, where the "top" file should be located (server, client, both) and what name? as Meteor loads files based on their paths. Thanks
Upvotes: 2
Views: 122
Reputation: 2666
One of ways to create a global namespace in Meteor (as suggested in the SO answer) is to have a file where a global alias to this
is declared, such as:
G = this;
This file should, ideally, be loaded first and on both client and server.
To achieve this, according to the doc:
lib/
directory are loaded first (after loading template files on client).client/
or server/
directories on both client and server.So, in keeping with these rules I would save the file as app.js
(or any similar name that would come first alphabetically). Then I would place this file at the root of lib/
folder so that it gets loaded both on client and server.
So, the path to app.js
would be : ./your_meteor_project_root/lib/app.js
Upvotes: 1