Skip to content

Commit

Permalink
improved loader to mark modules w/out factories as immediately execut…
Browse files Browse the repository at this point in the history
…ed; improved dojo/text plugin process with built code; refs #12672; refs #12673; !strict

git-svn-id: http://svn.dojotoolkit.org/src/dojo/trunk@25008 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
rcgill committed May 18, 2011
1 parent 0abb2c9 commit 261694c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
12 changes: 7 additions & 5 deletions dojo.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@

getModule = function(mid, referenceModule, fromRequire){
// compute and optionally construct (if necessary) the module implied by the mid with respect to referenceModule
var match, plugin, pluginResource, result, existing, pqn, syntheticMid;
var match, plugin, pluginResource, result, existing, pqn;
match = mid.match(/^(.+?)\!(.*)$/);
//TODO: change the regex above to this and test...match= mid.match(/^([^\!]+)\!(.+)$/);
if(match){
Expand All @@ -725,10 +725,9 @@
return modules[pqn] || (modules[pqn] = {plugin:plugin, mid:pluginResource, req:(referenceModule ? createRequire(referenceModule) : req), pqn:pqn});
}else{
if(fromRequire && /^.*[^\/\.]+\.[^\/\.]+$/.test(mid)){
// anything* anything-other-than-a-dot+ dot anything-other-than-a-dot+ => a url that ends with a filetype
syntheticMid = uid(),
pqn = "*" + syntheticMid;
return modules[pqn]= makeModuleInfo(0, syntheticMid, pqn, 0, mid, mid);
// anything* anything-other-than-a-dot+ dot anything-other-than-a-dot-or-slash+ => a url that ends with a filetype
pqn = "*" + mid;
return modules[pqn]= modules[pqn] || makeModuleInfo(0, mid, pqn, 0, mid, mid);
}
result = getModuleInfo(mid, referenceModule, packs, modules, req.baseUrl, packageMapProg, pathsMapProg);
return modules[result.pqn] || (modules[result.pqn] = result);
Expand Down Expand Up @@ -1112,6 +1111,9 @@
}
}
});
if(!isFunction(def) && !deps.length){
mix(module, {result:def, executed:executed});
}

// resolve deps with respect to pid
for(var i = 0; i < deps.length; i++){
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"amd": "return /\\.js$/.test(name) && !/\\/nls\\//.test(name) && !/_base\\/config.+/.test(name) && !/OpenAjax\\.js$/.test(name) && !/resources\\/_modules\\.js/.test(name);"
},
"trees": [
[".", ".", "/\\.", "/dojo/_base/_loader/", "/dojo/lib/"]
[".", ".", "/\\.", "~$"]
]
}
}
}
22 changes: 16 additions & 6 deletions text.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define(["./_base/kernel", "./_base/xhr", "require", "./has"], function(dojo, xhr
var
theCache= {},

getCacheId= function(resourceId) {
getCacheId= function(resourceId, require) {
if(require.toAbsMid){
var match= resourceId.match(/(.+)(\.[^\/\.]+)$/);
return match ? require.toAbsMid(match[1]) + match[2] : require.toAbsMid(resourceId);
Expand Down Expand Up @@ -69,7 +69,7 @@ define(["./_base/kernel", "./_base/xhr", "require", "./has"], function(dojo, xhr
var
parts= id.split("!"),
resourceId= parts[0],
cacheId= getCacheId(resourceId),
cacheId= getCacheId(resourceId, require),
stripFlag= parts.length>1,
url;
if(cacheId in theCache){
Expand All @@ -81,10 +81,20 @@ define(["./_base/kernel", "./_base/xhr", "require", "./has"], function(dojo, xhr
load(stripFlag ? strip(theCache[url]) : theCache[url]);
return;
}
getText(url, !require.async, function(text){
cache(cacheId, url, text);
load(stripFlag ? strip(theCache[url]) : theCache[url]);
});
var
inject= function(text){
cache(cacheId, url, text);
load(stripFlag ? strip(theCache[url]) : theCache[url]);
},
text;
try{
text= require("*text/" + cacheId);
if(text!==undefined){
inject(text);
return;
}
}catch(e){}
getText(url, !require.async, inject);
},

cache:function(cacheId, mid, type, value) {
Expand Down

0 comments on commit 261694c

Please sign in to comment.