Skip to content

Module dependencies

azproduction edited this page Jan 28, 2013 · 1 revision
  • Module Property/Flag: depends
  • Property/Flag: depends

Modules may have dependencies that you can put in a separate file. This file has the same format as any lmd.json file. In that file can specify a list of required features and modules. Each module can have only one config file with dependencies. All dependant configs may also have depends.

In other words, each configuration defines a subtree of the file system and the features that it needs to work. The main config file assembles all subtrees and list of features into one big tree and features list.

Example

FS Tree

cfgs/
    index.lmd.json           | Main config
modules/                     |
    some_module/             |
        some_module_deps.js  |
    main.js                  |
    some_module.lmd.json     | Depends config of some_module.js
    some_module.js           |
    some_other_module.js     |

index.lmd.json

{
    "root": "../modules/", // or "path":

    "modules": {
        "main": "modules/main.js",
        "some_module": "modules/some_module.js",
        "some_other_module": "modules/some_other_module.js"
    },

    "depends": true // or mask "*.lmd.json",

    "cache": false
}

You may also use per module depends:

{
    "some_module": {
        "path": "modules/some_module.js",
        "depends": "some_module.lmd.json"
    }
}

modules/some_module.lmd.json

{
    "root": "./some_module/", // or "path":

    "modules": {
        "some_module_deps": "some_module_deps.js"
    },

    "js": true,
    "async": true,

    "cache": true
}

$ lmd index.lmd.json index.js

Result js file will contain all module deps:

{
    "modules": {
        "main": "modules/main.js",
        "some_module": "modules/some_module.js",
        "some_other_module": "modules/some_other_module.js"
        "some_module_deps": "some_module_deps.js"
    },

    "js": true,    // from some_module.lmd.json
    "async": true,

    "cache": false // overwritten by master config index.lmd.json
}

See examples/features/depends for example

Note:

  • LMD will warn if some config declares exists module name
  • "main" module from each depends module will be excluded
  • master config may overwrite flags by setting "flag": false
Clone this wiki locally