I am trying to use RequireJS to load browser modules and I had an interesting problem.
I have 3 modules named a , b and c having this 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 works fine, the following code starts and returns "A":
require(['./a'], function(a) { console.log(a);
But if I need two different modules, one of which is already loaded:
require(['./a', './c'], function(a, c) { console.log(a, c); });
RequireJS will be mistaken:
C IS LOADED! B IS LOADED! require.js load timeout for modules: ./c
when it is already loaded.
Has anyone encountered this problem before? How can I solve it?
Liranuna
source share