I have defined a RequireJs configuration which defines paths and shims:
require.config({
// define application bootstrap
deps: ["main"],
// define library shortcuts
paths: {
app: "app"
, jquery: "lib/jquery"
, underscore: "lib/underscore"
, backbone: "lib/backbone"
, bootstrap: "lib/bootstrap"
},
// define library dependencies
shim: {
jquery: {
exports: "$"
},
underscore: {
exports: "_"
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
bootstrap: {
deps: ['jquery'],
exports: "bootstrap"
},
// main application
app: {
deps: ["backbone"],
exports: "App"
}
}
});
As you see the last "shim" declaration should make it able to access backbone (and it deps) when I load the main App(-namespace).
In reality this doesn't work:
require(["app"], function($, _, Backbone, App){
app.router = new Backbone.Router.extend({
// routing and route actions
});
});
What makes me wondering is that in the "backbone-boilderplate"-project, Backbone (and its deps) are available this way: https://github.com/tbranyen/backbone-boilerplate/blob/master/app/main.js
The not even had to define this in the function.
So what am I doing wrong?