MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / execModule

Function execModule

src/test/resources/libraries/dojo/1.9.3/dojo/dojo.js:1188–1239  ·  view source on GitHub ↗
(module, strict)

Source from the content-addressed store, hash-verified

1186 circleTrace = [],
1187
1188 execModule = function(module, strict){
1189 // run the dependency vector, then run the factory for module
1190 if(module.executed === executing){
1191 req.trace("loader-circular-dependency", [circleTrace.concat(module.mid).join("->")]);
1192 return (!module.def || strict) ? abortExec : (module.cjs && module.cjs.exports);
1193 }
1194 // at this point the module is either not executed or fully executed
1195
1196
1197 if(!module.executed){
1198 if(!module.def){
1199 return abortExec;
1200 }
1201 var mid = module.mid,
1202 deps = module.deps || [],
1203 arg, argResult,
1204 args = [],
1205 i = 0;
1206
1207 if(has("dojo-trace-api")){
1208 circleTrace.push(mid);
1209 req.trace("loader-exec-module", ["exec", circleTrace.length, mid]);
1210 }
1211
1212 // for circular dependencies, assume the first module encountered was executed OK
1213 // modules that circularly depend on a module that has not run its factory will get
1214 // the pre-made cjs.exports===module.result. They can take a reference to this object and/or
1215 // add properties to it. When the module finally runs its factory, the factory can
1216 // read/write/replace this object. Notice that so long as the object isn't replaced, any
1217 // reference taken earlier while walking the deps list is still valid.
1218 module.executed = executing;
1219 while((arg = deps[i++])){
1220 argResult = ((arg === cjsRequireModule) ? createRequire(module) :
1221 ((arg === cjsExportsModule) ? module.cjs.exports :
1222 ((arg === cjsModuleModule) ? module.cjs :
1223 execModule(arg, strict))));
1224 if(argResult === abortExec){
1225 module.executed = 0;
1226 req.trace("loader-exec-module", ["abort", mid]);
1227 has("dojo-trace-api") && circleTrace.pop();
1228 return abortExec;
1229 }
1230 args.push(argResult);
1231 }
1232 runFactory(module, args);
1233 finishExec(module);
1234 has("dojo-trace-api") && circleTrace.pop();
1235 }
1236 // at this point the module is guaranteed fully executed
1237
1238 return module.result;
1239 },
1240
1241
1242 checkCompleteGuard = 0,

Callers 4

contextRequireFunction · 0.70
getModuleFunction · 0.70
checkCompleteFunction · 0.70
doRequireFunction · 0.50

Calls 8

joinMethod · 0.80
popMethod · 0.80
createRequireFunction · 0.70
runFactoryFunction · 0.70
finishExecFunction · 0.70
traceMethod · 0.65
concatMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…