jrburke/almond — pull request #71 by gerrod (2013-11-11 22:29:33+00:00)
Title: Allow module definitions with no callback function

requirejs allows you to create a module definition with no "callback" function. An example of why you may want to do this is to add your own custom validators into a base validation framework (e.g. knockout.validation). You may define your own module "knockout/validation" as follows:

define("knockout/validation", ["knockout", "knockout.validation", "knockout.validation.customValidators"]);

In this example, the `knockout.validation` module does not return anything (i.e. it does not define a module, it extends the `knockout` module); similarly, the `knockout.validation.customValidators` does not define a module.

requirejs allows for this type of definition, and correctly loads the dependencies when the `knockout/validation` module is required.

Almond will only load the dependencies when there is a "callback" function provided; otherwise it treats the definition as a simple object definition. To cater for this, we would need to change the object definition as follows:

var noop = function() {};
define("knockout/validation", ["knockout", "knockout.validation", "knockout.validation.customValidators"], noop);

The attached pull request allows almond to correctly define a module even when no callback function is supplied.