A dependency is a module or component another module requires to work correctly. In AMD, a module lists required module IDs, and its factory receives the corresponding modules as arguments. section 11.1.2
AMD requests dependencies asynchronously and calls the factory after they are downloaded and evaluated. CommonJS uses require to obtain a dependency, as in a module that requires jQuery. section 11.1.2
Listing 11.3. Using AMD to specify a module dependent on jQuery
define('MouseCounterModule',['jQuery'], $ => { #A
let numClicks = 0;
const handleClick = () => {
alert(++numClicks);
};
return { #B
countClicks: () => {
$(document).on("click", handleClick);
}
};
});
An AMD module depends on jQuery to register a click handler for a click-counting module. section 11.1.2


























