Skip to content

Browser Support for module.exports

Compare
Choose a tag to compare
@losandes losandes released this 04 Dec 04:59
· 68 commits to master since this release

[Browser Only] You can now use module.exports syntax to register your modules. Beyond syntax candy, this allows you to decouple your modules from Hilary, making it easier to refactor, or inject global DI behaviors.

You have to add the script: <script src="[PATH]/release/hilary.moduleExports.min.js" />. Then you can define your modules like this:

module.exports = {
    scope: 'myApp',
    name: 'myModule',
    dependencines: [],
    factory: function () {
        'use strict';

        // do something
    }
};

Note: You should ALWAYS have a names scope, like the example above, in addition to the requirements of Hilary's register feature.