From the Logs, Backbone now registers itself for AMD (Require.js) Since v1.1.1.
Great, So I try to do the same for a module but there is something I don't understand.
If we look at section 4 of annotated sources the sources, The module doesn't return the global Backbone.
No need shim and window.Backbone is available. But How Backbone can not be undefined ?
// Definition Backbone Module
define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
root.Backbone = factory(root, exports, _, $);
});
// Require Backbone module
require(['backbone'], function (Backbone) {
Backbone // is not undefined ?
});
// Modal module Definition
define(['jquery'], function ($) {
root.Modal = factory(root, {}, $);
});
// Require Modal module
require(['modal'], function (Modal) {
Modal // undefined
});
Into my module (using the same structure), When I require my module, I got undefined
if I don't return anything.
I have to return root.Modal in order to make it work. return root.Modal = factory(root, {}, $);
The main question is "How a module can be required while the module doesn't return anything ? "
I have missing something on requireJS, but I don't find it.