I have read this question & I want to understand this concept more clearly so I have created my two files
lorem.js
:
var lorem = {};
lorem.fun1 = function(){
console.log('aaa');
};
ipsum.js
:
var ipsum = {};
ipsum.color = 'a';
ipsum.fun1 = function(){
lorem.fun1();
};
Ipsum depends on lorem. In the shim configuration I have done something like this:
// Filename: main.js
// Require.js allows us to configure shortcut alias
// There usage will become more apparent further along in the tutorial.
require.config({
baseUrl: 'js',
paths: {
/*jquery: [
// 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min' ,
'libs/jquery/jquery'
],
backbone:[
'libs/backbone/backbone'
],
underscore:[
'libs/underscore/underscore'
],*/
ipsum: 'nonamd/ipsum',
lorem: 'nonamd/lorem'
},
shim : {
/*jquery : {
exports : 'jQuery'
},
underscore : {
exports : '_'
},
backbone : {
deps : ['jquery', 'underscore'],
exports : 'Backbone'
},*/
ipsum : {
deps : ['lorem'],
exports : 'Ipsum'
}
}
});
require(['ipsum'],function (Ipsum) {
console.log(Ipsum);
});
However, console.log(Ipsum)
prints undefined
in console. What am I doing wrong?