[mod-a.js]
// Define a module with dependencies.
// The return value of the dependent module as arguments.
Define('mod-a', ['mod-b', 'mod-c'], function ( b, c ) {
console.log('i am mod-a');
return 'mod-a,' + b + ',' + c;
});
[index.html]
// Do not forget to config the alias.
// Alias is use to control the module version and its path.
Define.alias({
'mod-a': function () {
return 'mod-a@1.0.0';
},
'mod-a@1.0.0': 'mod-a.js',
'mod-b': 'mod-b.js',
'mod-c': 'mod-c.js',
});
// If you want to use module, do not pass any module id.
Define(['mod-a'], function ( result ) {
console.log('I get the value from mod-a >> ' + result);
});
Please open DevTools and try it out for yourself. 😇