Answer the question
In order to leave comments, you need to log in
Why don't named RequireJS modules work?
I write a named module, like this:
define(
'agent/app',
[
'agent/Router'
],
function(Router) {
console.log('app');
new Router();
}
);
{
urlArgs: 'bust=' + (new Date()).getTime(),
baseUrl: '/site_static/js',
paths: {
underscore: 'libs/underscore',
backbone: 'libs/backbone',
jquery: 'libs/jquery'
},
shim: {
underscore: {exports: '_'},
backbone: {exports: 'Backbone'},
jquery: {exports: '$'}
}
};
Answer the question
In order to leave comments, you need to log in
The documentation says that it is better not to use named modules.
It is normally best to avoid coding in a name for the module and just let the optimization tool burn in the module names.
In our project, we map modules through the config, for one we get a bad DI control
paths: {
underscore: 'libs/underscore',
backbone: 'libs/backbone',
jquery: 'libs/jquery',
app : 'agent/app',
router : 'app/router'
},
require('app');
require('router');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question