-
Notifications
You must be signed in to change notification settings - Fork 27
AMD modules
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!
- 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.jstail 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
- All your AMD modules and depends should be declared in
modulessection (only in-package AMD modules are allowed) - Name parameter in
define('name')is ignored (anonymous defines only) - All your modules files should contain only one
define()(last one will be declared)