I’ve found that without some basic organization, organizing these side-effect driven modules can quickly get out of hand. Using index.js files can help keep things modular and significantly clean up your client/mains.js and server/main.js files.
Hopefully this helps out the folks transitioning to modules!
your articles are always quality stuff, thanks one thing I’ve never seen any recommendation on is imports structure for atmosphere packages. any chance you could write one up on that? it’s not even mentioned in the guide. I’ve been using something similar to the recommended application structure but it’ always felt a little odd in a packge
If you’re using a package that works through side-effects, like accounts-password, there shouldn’t be any reason to import it into any modules. The Meteor build tool will ensure that it’s built into your final bundle for you.
oh I meant something similar to how the Meteor Guide recommends an application structure of file/folder organization. When writing an atmosphere package, you’ll end up with a lot of the same stuff as an application (server and client side code per feature, possible some UI elements, etc), but I’ve never come across a defined recommended file structure for atmosphere packages. Following the application structure recommendation always felt a little weird in a package
Objects in the system (e.g. users, tasks, etc. – typically mapping to collections)
Meteor-special directories like packages, private and tests.
A few other directories like lib, bin and build.
Generally, each object directory contains four things:
Some files that are used on both the server and the client.
A server, client and .admin directory for files specific to those environments.
Here, client is the enduser app and .admin is converted to a client directory in a generated project directory so we can have a second SPA for the admin side of the system. Typically files used on both the server and client have server- and client-specific code. These have the same name as the reused file and extend the object/class it creates.
main.js files live under top-level client, server and admin directories.
Packages are either simple, flat structures where a client.js and a server.js bring everything together if package.js alone isn’t enough -or- they are organized like the objects directories.