Thin Module

A Thin Module is a module that only has metadata, no payloads.

As Thin Module does not have any payloads, itsmeta.jscan only accept functioninstalland optionon. Any other option likeuse,setorsingletonwill not be applicable. The functioninstallwill be used to initialize the module inself and register it to the container.

Thin Module is useful in case of you want to have a light-weight module with small amount of code, or you want to use the module to install somenode_modulesas mentioned in Customizing Module Installation.

Example below represents a thinconfig.developmentmodule:

// meta.js
module.exports = {
    install: ($, name, path) => {
        $.bind(name).to(Object.freeze({
            DB_HOST: 'localhost',
            DB_NAME: 'mydb'
            // and more...
        }));
    }
}

Last updated