Module system for Meteor

Let me introduce you fragments. It’s a simple module system for Meteor.

What? Yet another module system?

Well… yeah. For today, Meteor does not play well with any kind of modules (es6/amd/commonjs). Fragments are not better than other module systems. Fragments will be deprecated someday. But for now it’s a very easy-to-use solution for Meteor.

Benefits:

  1. Easy-to-use
  2. No matter files load order
  3. No global variables

Usage:

There is object modules:

// modules == {}

Register module foo:

f('foo');

// modules == { foo: {} }

Define some field for foo module:

f('foo', function() {
  this.bar = 'baz';
});

// modules == { foo: { bar: 'baz' } }

Now let’s create another module, which uses foo's bar field:

f('foo', function() {
  this.bar = 'baz';
});

// Use `foo.bar` as `bar` variable
f([ 'foo.bar' ], function(bar) {
  console.log(bar); // => 'baz'
});

NOTE: modules is not in global scope! You can’t use modules variable.

That’s all you need to know to get started.

If you are interested, you can read more on github: https://github.com/imkost/fragments