jrburke/requirejs — Issue #172: RJS doesn't handle dependencies right
Author: evil-shrike
Created: 2012-01-23 18:38:27+00:00
State: open

Given the following chain of dependencies: main -> module2 -> module1 -> module0

--- index.html ---

----------------------

--- main.js -------

define(["comp2"], function(comp2){
alert("main. comp2 defined: " + (!!comp2));
})
----------------------

--- comp2.js -----

define(["comp1"], function (comp1) {

alert("comp2. comp1 defined: " + (!!comp1));

return {};
});
----------------------

--- comp1.js -----

require(["comp0"], function (comp0) {

alert("comp1. comp0 defined: " + (!!comp0) );

return {};
});
----------------------

--- comp0.js -----

define(function () {
alert("comp0.");

return {};
});
----------------------

**Results**
alerts in the following sequence:
1. "comp2. comp1 defined: false"
2. "main. comp2 defined: true"
3. "comp0."
4. "comp1. comp0 defined: true"

**Expected results**
alerts in the following sequence:
1. "comp0."
2. "comp1. comp0 defined: true"
3. "comp2. comp1 defined: true"
4. "main. comp2 defined: true"