When using the Module pattern to extend a module we do something like this:
var NewModule = (function (Main) {
Main.extension = function () {};
return Main;
})(Main || {});
That works great and the question is, if Main is not declared we avoid errors by passing an empty object Main || {}. How do we prevent this dependency from breaking? Granted, we wont have any errors at first but if we are not able to attach our extension to Main we will encounter other type of errors.
Mainto have all the methods available when needed in the future.Mainobject is not present at the application level but yet again leave some sort of flexibility for unit testing.