MCPcopy
hub / github.com/moxiecode/plupload / makeModuleMap

Function makeModuleMap

tests/js/require.js:416–495  ·  view source on GitHub ↗

* Creates a module mapping that includes plugin prefix, module * name, and path. If parentModuleMap is provided it will * also normalize the name via require.normalize() * * @param {String} name the module name * @param {String} [parentModuleMap] parent m

(name, parentModuleMap, isNormalized, applyMap)

Source from the content-addressed store, hash-verified

414 * @returns {Object}
415 */
416 function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
417 var url, pluginModule, suffix, nameParts,
418 prefix = null,
419 parentName = parentModuleMap ? parentModuleMap.name : null,
420 originalName = name,
421 isDefine = true,
422 normalizedName = '';
423
424 //If no name, then it means it is a require call, generate an
425 //internal name.
426 if (!name) {
427 isDefine = false;
428 name = '_@r' + (requireCounter += 1);
429 }
430
431 nameParts = splitPrefix(name);
432 prefix = nameParts[0];
433 name = nameParts[1];
434
435 if (prefix) {
436 prefix = normalize(prefix, parentName, applyMap);
437 pluginModule = getOwn(defined, prefix);
438 }
439
440 //Account for relative paths if there is a base name.
441 if (name) {
442 if (prefix) {
443 if (pluginModule && pluginModule.normalize) {
444 //Plugin is loaded, use its normalize method.
445 normalizedName = pluginModule.normalize(name, function (name) {
446 return normalize(name, parentName, applyMap);
447 });
448 } else {
449 // If nested plugin references, then do not try to
450 // normalize, as it will not normalize correctly. This
451 // places a restriction on resourceIds, and the longer
452 // term solution is not to normalize until plugins are
453 // loaded and all normalizations to allow for async
454 // loading of a loader plugin. But for now, fixes the
455 // common uses. Details in #1131
456 normalizedName = name.indexOf('!') === -1 ?
457 normalize(name, parentName, applyMap) :
458 name;
459 }
460 } else {
461 //A regular module.
462 normalizedName = normalize(name, parentName, applyMap);
463
464 //Normalized name may be a plugin ID due to map config
465 //application in normalize. The map config values must
466 //already be normalized, so do not need to redo that part.
467 nameParts = splitPrefix(normalizedName);
468 prefix = nameParts[0];
469 normalizedName = nameParts[1];
470 isNormalized = true;
471
472 url = context.nameToUrl(normalizedName);
473 }

Callers 3

newContextFunction · 0.85
callGetModuleFunction · 0.85
localRequireFunction · 0.85

Calls 3

splitPrefixFunction · 0.85
normalizeFunction · 0.85
getOwnFunction · 0.85

Tested by

no test coverage detected