Skip to content

Commit aa154b6

Browse files
committed
update to master require.js and snapshot.
1 parent 606200e commit aa154b6

File tree

2 files changed

+82
-24
lines changed

2 files changed

+82
-24
lines changed

dist/r.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
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.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
2020

2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib,
23-
version = '1.0.4+ 20120125 8:40pm',
23+
version = '1.0.4+ 201226 5:50pm',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
2626
useLibLoaded = {},
@@ -499,8 +499,8 @@ var requirejs, require, define;
499499
* per module because of the implication of path mappings that may
500500
* need to be relative to the module name.
501501
*/
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);
504504

505505
mixin(modRequire, {
506506
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
@@ -715,7 +715,22 @@ var requirejs, require, define;
715715
//Use parentName here since the plugin's name is not reliable,
716716
//could be some weird string with no path that actually wants to
717717
//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);
719734
}
720735
}
721736

@@ -1082,8 +1097,8 @@ var requirejs, require, define;
10821097
//It is possible to disable the wait interval by using waitSeconds of 0.
10831098
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
10841099
noLoads = "", hasLoadedProp = false, stillLoading = false,
1085-
onlyPluginResourceLoading = true,
1086-
i, prop, err, manager, cycleManager;
1100+
cycleDeps = [],
1101+
i, prop, err, manager, cycleManager, moduleDeps;
10871102

10881103
//If there are items still in the paused queue processing wait.
10891104
//This is particularly important in the sync case where each paused
@@ -1114,13 +1129,18 @@ var requirejs, require, define;
11141129
} else {
11151130
stillLoading = true;
11161131
if (prop.indexOf('!') === -1) {
1117-
onlyPluginResourceLoading = false;
11181132
//No reason to keep looking for unfinished
11191133
//loading. If the only stillLoading is a
11201134
//plugin resource though, keep going,
11211135
//because it may be that a plugin resource
11221136
//is waiting on a non-plugin cycle.
1137+
cycleDeps = [];
11231138
break;
1139+
} else {
1140+
moduleDeps = managerCallbacks[prop] && managerCallbacks[prop].moduleDeps;
1141+
if (moduleDeps) {
1142+
cycleDeps.push.apply(cycleDeps, moduleDeps);
1143+
}
11241144
}
11251145
}
11261146
}
@@ -1141,10 +1161,22 @@ var requirejs, require, define;
11411161
return req.onError(err);
11421162
}
11431163

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+
11441176
//If still waiting on loads, and the waiting load is something
11451177
//other than a plugin resource, or there are still outstanding
11461178
//scripts, then just try back later.
1147-
if (!expired && ((stillLoading && !onlyPluginResourceLoading) || context.scriptCount)) {
1179+
if (!expired && (stillLoading || context.scriptCount)) {
11481180
//Something is still waiting to load. Wait for it, but only
11491181
//if a timeout is not already in effect.
11501182
if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
@@ -1167,10 +1199,7 @@ var requirejs, require, define;
11671199
if (context.waitCount) {
11681200
//Cycle through the waitAry, and call items in sequence.
11691201
for (i = 0; (manager = waitAry[i]); i++) {
1170-
if ((cycleManager = findCycle(manager, {}))) {
1171-
forceExec(cycleManager, {});
1172-
break;
1173-
}
1202+
forceExec(manager, {});
11741203
}
11751204

11761205
//If anything got placed in the paused queue, run it down.

require.js

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ var requirejs, require, define;
396396
* per module because of the implication of path mappings that may
397397
* need to be relative to the module name.
398398
*/
399-
function makeRequire(relModuleMap, enableBuildCallback) {
400-
var modRequire = makeContextModuleFunc(context.require, relModuleMap, enableBuildCallback);
399+
function makeRequire(relModuleMap, enableBuildCallback, altRequire) {
400+
var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback);
401401

402402
mixin(modRequire, {
403403
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
@@ -612,7 +612,22 @@ var requirejs, require, define;
612612
//Use parentName here since the plugin's name is not reliable,
613613
//could be some weird string with no path that actually wants to
614614
//reference the parentName's path.
615-
plugin.load(name, makeRequire(map.parentMap, true), load, config);
615+
plugin.load(name, makeRequire(map.parentMap, true, function (deps, cb) {
616+
var moduleDeps = [],
617+
i, dep, depMap;
618+
//Convert deps to full names and hold on to them
619+
//for reference later, when figuring out if they
620+
//are blocked by a circular dependency.
621+
for (i = 0; (dep = deps[i]); i++) {
622+
depMap = makeModuleMap(dep, map.parentMap);
623+
deps[i] = depMap.fullName;
624+
if (!depMap.prefix) {
625+
moduleDeps.push(deps[i]);
626+
}
627+
}
628+
depManager.moduleDeps = (depManager.moduleDeps || []).concat(moduleDeps);
629+
return context.require(deps, cb);
630+
}), load, config);
616631
}
617632
}
618633

@@ -979,8 +994,8 @@ var requirejs, require, define;
979994
//It is possible to disable the wait interval by using waitSeconds of 0.
980995
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
981996
noLoads = "", hasLoadedProp = false, stillLoading = false,
982-
onlyPluginResourceLoading = true,
983-
i, prop, err, manager, cycleManager;
997+
cycleDeps = [],
998+
i, prop, err, manager, cycleManager, moduleDeps;
984999

9851000
//If there are items still in the paused queue processing wait.
9861001
//This is particularly important in the sync case where each paused
@@ -1011,13 +1026,18 @@ var requirejs, require, define;
10111026
} else {
10121027
stillLoading = true;
10131028
if (prop.indexOf('!') === -1) {
1014-
onlyPluginResourceLoading = false;
10151029
//No reason to keep looking for unfinished
10161030
//loading. If the only stillLoading is a
10171031
//plugin resource though, keep going,
10181032
//because it may be that a plugin resource
10191033
//is waiting on a non-plugin cycle.
1034+
cycleDeps = [];
10201035
break;
1036+
} else {
1037+
moduleDeps = managerCallbacks[prop] && managerCallbacks[prop].moduleDeps;
1038+
if (moduleDeps) {
1039+
cycleDeps.push.apply(cycleDeps, moduleDeps);
1040+
}
10211041
}
10221042
}
10231043
}
@@ -1038,10 +1058,22 @@ var requirejs, require, define;
10381058
return req.onError(err);
10391059
}
10401060

1061+
//If still loading but a plugin is waiting on a regular module cycle
1062+
//break the cycle.
1063+
if (stillLoading && cycleDeps.length) {
1064+
for (i = 0; (manager = waiting[cycleDeps[i]]); i++) {
1065+
if ((cycleManager = findCycle(manager, {}))) {
1066+
forceExec(cycleManager, {});
1067+
break;
1068+
}
1069+
}
1070+
1071+
}
1072+
10411073
//If still waiting on loads, and the waiting load is something
10421074
//other than a plugin resource, or there are still outstanding
10431075
//scripts, then just try back later.
1044-
if (!expired && ((stillLoading && !onlyPluginResourceLoading) || context.scriptCount)) {
1076+
if (!expired && (stillLoading || context.scriptCount)) {
10451077
//Something is still waiting to load. Wait for it, but only
10461078
//if a timeout is not already in effect.
10471079
if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
@@ -1064,10 +1096,7 @@ var requirejs, require, define;
10641096
if (context.waitCount) {
10651097
//Cycle through the waitAry, and call items in sequence.
10661098
for (i = 0; (manager = waitAry[i]); i++) {
1067-
if ((cycleManager = findCycle(manager, {}))) {
1068-
forceExec(cycleManager, {});
1069-
break;
1070-
}
1099+
forceExec(manager, {});
10711100
}
10721101

10731102
//If anything got placed in the paused queue, run it down.

0 commit comments

Comments
 (0)