paths.html
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<html>
<head>
<script type="text/javascript" src="../../../dojo.js"></script>
<script type="text/javascript">
var myModule1Value = {}, myModule2Value = {};
define("myModule1", [], myModule1Value);
define("myModule2", [], myModule2Value);
require({
aliases:[
// yourModule --> myModule1
["yourModule", "myModule1"],
// yourOtherModule --> myModule1
[/yourOtherModule/, "myModule1"],
// yourModule/*/special --> yourModule/common/special
// this will result in a resubmission to finally resolve in the next one
[/yourOtherModule\/([^\/]+)\/special/, "yourOtherModule/common/special"],
// yourModule/common/special --> myModule2
// notice the regex above also finds yourOtherModule/common/special;
// the extra parenthesized subexprs make this have priority
[/(yourOtherModule\/(common))\/special/, "myModule2"]
],
paths:{myTopLevelModule:"./tests/_base/loader/myTopLevelModule"}
});
require(["myTopLevelModule", "doh", "myModule1", "myModule2", "yourModule", "yourOtherModule", "yourOtherModule/stuff/special"],
function(myModule, doh, myModule1, myModule2, myModule1_1, myModule1_2, myModule2_1){
doh.register("aliases", [
function(t){
t.is(myModule1Value, myModule1);
t.is(myModule1Value, myModule1_1);
t.is(myModule1Value, myModule1_2);
t.is(myModule2Value, myModule2);
t.is(myModule2Value, myModule2_1);
}
]);
doh.register("top-level-module-via-paths", [
function(t){
t.is(myTopLevelModule.name, "myTopLevelModule");
t.is(myTopLevelModule.myModule.name, "myTopLevelModule.myModule");
}
]);
doh.runOnLoad();
});
</script>
</head>
<body>
</body>
</html>