Skip to content
azproduction edited this page Mar 13, 2013 · 3 revisions
  • Flag amd

If your project is using AMD (RequireJS) modules and you want to play with LMD - you can just enable flag amd and use your AMD modules without any changes!

Example

  • This is your RequireJS config
requirejs.config({
    paths: {
        main: 'path/to/main',
        jquery: 'path/to/third-party/jquery.min',
        underscore: 'path/to/third-party/underscore.min',
        backbone: 'path/to/third-party/backbone.min',
    }
});
  • First transform it to LMD config.json. Do not forget to add .js tail to your paths.

"main" module will be called first.

{
    "root": "path/to/",
    "modules": {
        "main": "main.js",
        "jquery": "third-party/jquery.min.js",
        "underscore": "third-party/underscore.min.js",
        "backbone": "third-party/backbone.min.js"
    },

    "amd": true
}
  • Than build lmd package lmd config.json result.js
  • Yahoo! - now you can use all LMD features (code coverage, stats) with your AMD modules!

See examples/demos/mock_chat/js/amd for real example

Limitations

  1. All your AMD modules and depends should be declared in modules section (only in-package AMD modules are allowed)
  2. Name parameter in define('name') is ignored (anonymous defines only)
  3. All your modules files should contain only one define() (last one will be declared)

Clone this wiki locally