I am trying to use RequireJS to load browser modules and I came into an interesting problem.
I have 3 modules named a
, b
and c
having these simple source code:
a.js
define([ ./b , ./c ], function(c, b) {
console.log( A IS LOADED! );
return A ;
});
b.js
define(function() {
console.log( B IS LOADED! );
return B ;
});
c.js
define(function() {
console.log( C IS LOADED! );
return C ;
});
When I load module a
by itself, everything is working just fine, the following code runs and returns A :
require([ ./a ], function(a) {
console.log(a); // A
});
But if I need two different modules, which one of was already loaded:
require([ ./a , ./c ], function(a, c) {
console.log(a, c);
});
RequireJS will error:
C IS LOADED!
B IS LOADED!
require.js load timeout for modules: ./c
when it s obviously already loaded.
Has anyone encountered this issue before? How can I solve it?