Here is an example of what I’m doing:
Client
/client/main.js
import '/imports/startup/client';
/imports/startup/client/index.js
import '/imports/startup/client/routes;
/imports/startup/client/routes.js
This file containes my FlowRouter configs...
/imports/tools/index.js
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import React from 'react';
import ReactDOM from 'react-dom';
...
export {
React,
ReactDOM,
Meteor,
Accounts,
...
};
/client/imports/ui/components/index.js
import CompA from './CompA';
import CompB from './CompB';
export { CompA, CompB };
/client/imports/ui/components/CompA.jsx
import { React, Meteor } from '/imports/tools';
... use React and Meteor as you wish
/client/imports/ui/components/CompB.jsx
import { React, Meteor } from '/imports/tools';
import { CompA } from '/client/imports/ui/components';
import { Icon, Button } from '/client/imports/ui/semantic'; (i have my semantic-ui comps there)
... use React and Meteor as you wish
I think it simplifies the way to load your stuff. As you add components, you add them to your index.js file inside the directory. When you have to move stuff, it is really easy.
In /imports/tools
I also have underscore, moment, and a few other libs that I use almost everywhere.
I also have /imports/tools/server.js
for server-side aggregation or Meteor, underscore, HTTP, etc.
I believe that imports translate to nodejs requires… So the modules should be loaded only once.
Any comments or suggestions would be appreciated!