1
1
/**
2
- * @license r.js 1.0.4+ 20120125 8:40pm Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 1.0.4+ 201226 5:50pm Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
3
* Available via the MIT or new BSD license.
4
4
* see: http://github.com/jrburke/requirejs for details
5
5
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
20
20
21
21
var fileName , env , fs , vm , path , exec , rhinoContext , dir , nodeRequire ,
22
22
nodeDefine , exists , reqMain , loadedOptimizedLib ,
23
- version = '1.0.4+ 20120125 8:40pm ' ,
23
+ version = '1.0.4+ 201226 5:50pm ' ,
24
24
jsSuffixRegExp = / \. j s $ / ,
25
25
commandOption = '' ,
26
26
useLibLoaded = { } ,
@@ -499,8 +499,8 @@ var requirejs, require, define;
499
499
* per module because of the implication of path mappings that may
500
500
* need to be relative to the module name.
501
501
*/
502
- function makeRequire ( relModuleMap , enableBuildCallback ) {
503
- var modRequire = makeContextModuleFunc ( context . require , relModuleMap , enableBuildCallback ) ;
502
+ function makeRequire ( relModuleMap , enableBuildCallback , altRequire ) {
503
+ var modRequire = makeContextModuleFunc ( altRequire || context . require , relModuleMap , enableBuildCallback ) ;
504
504
505
505
mixin ( modRequire , {
506
506
nameToUrl : makeContextModuleFunc ( context . nameToUrl , relModuleMap ) ,
@@ -715,7 +715,22 @@ var requirejs, require, define;
715
715
//Use parentName here since the plugin's name is not reliable,
716
716
//could be some weird string with no path that actually wants to
717
717
//reference the parentName's path.
718
- plugin . load ( name , makeRequire ( map . parentMap , true ) , load , config ) ;
718
+ plugin . load ( name , makeRequire ( map . parentMap , true , function ( deps , cb ) {
719
+ var moduleDeps = [ ] ,
720
+ i , dep , depMap ;
721
+ //Convert deps to full names and hold on to them
722
+ //for reference later, when figuring out if they
723
+ //are blocked by a circular dependency.
724
+ for ( i = 0 ; ( dep = deps [ i ] ) ; i ++ ) {
725
+ depMap = makeModuleMap ( dep , map . parentMap ) ;
726
+ deps [ i ] = depMap . fullName ;
727
+ if ( ! depMap . prefix ) {
728
+ moduleDeps . push ( deps [ i ] ) ;
729
+ }
730
+ }
731
+ depManager . moduleDeps = ( depManager . moduleDeps || [ ] ) . concat ( moduleDeps ) ;
732
+ return context . require ( deps , cb ) ;
733
+ } ) , load , config ) ;
719
734
}
720
735
}
721
736
@@ -1082,8 +1097,8 @@ var requirejs, require, define;
1082
1097
//It is possible to disable the wait interval by using waitSeconds of 0.
1083
1098
expired = waitInterval && ( context . startTime + waitInterval ) < new Date ( ) . getTime ( ) ,
1084
1099
noLoads = "" , hasLoadedProp = false , stillLoading = false ,
1085
- onlyPluginResourceLoading = true ,
1086
- i , prop , err , manager , cycleManager ;
1100
+ cycleDeps = [ ] ,
1101
+ i , prop , err , manager , cycleManager , moduleDeps ;
1087
1102
1088
1103
//If there are items still in the paused queue processing wait.
1089
1104
//This is particularly important in the sync case where each paused
@@ -1114,13 +1129,18 @@ var requirejs, require, define;
1114
1129
} else {
1115
1130
stillLoading = true ;
1116
1131
if ( prop . indexOf ( '!' ) === - 1 ) {
1117
- onlyPluginResourceLoading = false ;
1118
1132
//No reason to keep looking for unfinished
1119
1133
//loading. If the only stillLoading is a
1120
1134
//plugin resource though, keep going,
1121
1135
//because it may be that a plugin resource
1122
1136
//is waiting on a non-plugin cycle.
1137
+ cycleDeps = [ ] ;
1123
1138
break ;
1139
+ } else {
1140
+ moduleDeps = managerCallbacks [ prop ] && managerCallbacks [ prop ] . moduleDeps ;
1141
+ if ( moduleDeps ) {
1142
+ cycleDeps . push . apply ( cycleDeps , moduleDeps ) ;
1143
+ }
1124
1144
}
1125
1145
}
1126
1146
}
@@ -1141,10 +1161,22 @@ var requirejs, require, define;
1141
1161
return req . onError ( err ) ;
1142
1162
}
1143
1163
1164
+ //If still loading but a plugin is waiting on a regular module cycle
1165
+ //break the cycle.
1166
+ if ( stillLoading && cycleDeps . length ) {
1167
+ for ( i = 0 ; ( manager = waiting [ cycleDeps [ i ] ] ) ; i ++ ) {
1168
+ if ( ( cycleManager = findCycle ( manager , { } ) ) ) {
1169
+ forceExec ( cycleManager , { } ) ;
1170
+ break ;
1171
+ }
1172
+ }
1173
+
1174
+ }
1175
+
1144
1176
//If still waiting on loads, and the waiting load is something
1145
1177
//other than a plugin resource, or there are still outstanding
1146
1178
//scripts, then just try back later.
1147
- if ( ! expired && ( ( stillLoading && ! onlyPluginResourceLoading ) || context . scriptCount ) ) {
1179
+ if ( ! expired && ( stillLoading || context . scriptCount ) ) {
1148
1180
//Something is still waiting to load. Wait for it, but only
1149
1181
//if a timeout is not already in effect.
1150
1182
if ( ( isBrowser || isWebWorker ) && ! checkLoadedTimeoutId ) {
@@ -1167,10 +1199,7 @@ var requirejs, require, define;
1167
1199
if ( context . waitCount ) {
1168
1200
//Cycle through the waitAry, and call items in sequence.
1169
1201
for ( i = 0 ; ( manager = waitAry [ i ] ) ; i ++ ) {
1170
- if ( ( cycleManager = findCycle ( manager , { } ) ) ) {
1171
- forceExec ( cycleManager , { } ) ;
1172
- break ;
1173
- }
1202
+ forceExec ( manager , { } ) ;
1174
1203
}
1175
1204
1176
1205
//If anything got placed in the paused queue, run it down.
0 commit comments