MCPcopy
hub / github.com/requirejs/requirejs / localRequire

Function localRequire

require.js:1405–1468  ·  view source on GitHub ↗
(deps, callback, errback)

Source from the content-addressed store, hash-verified

1403 options = options || {};
1404
1405 function localRequire(deps, callback, errback) {
1406 var id, map, requireMod;
1407
1408 if (options.enableBuildCallback && callback && isFunction(callback)) {
1409 callback.__requireJsBuild = true;
1410 }
1411
1412 if (typeof deps === 'string') {
1413 if (isFunction(callback)) {
1414 //Invalid call
1415 return onError(makeError('requireargs', 'Invalid require call'), errback);
1416 }
1417
1418 //If require|exports|module are requested, get the
1419 //value for them from the special handlers. Caveat:
1420 //this only works while module is being defined.
1421 if (relMap && hasProp(handlers, deps)) {
1422 return handlers[deps](registry[relMap.id]);
1423 }
1424
1425 //Synchronous access to one module. If require.get is
1426 //available (as in the Node adapter), prefer that.
1427 if (req.get) {
1428 return req.get(context, deps, relMap, localRequire);
1429 }
1430
1431 //Normalize module name, if it contains . or ..
1432 map = makeModuleMap(deps, relMap, false, true);
1433 id = map.id;
1434
1435 if (!hasProp(defined, id)) {
1436 return onError(makeError('notloaded', 'Module name "' +
1437 id +
1438 '" has not been loaded yet for context: ' +
1439 contextName +
1440 (relMap ? '' : '. Use require([])')));
1441 }
1442 return defined[id];
1443 }
1444
1445 //Grab defines waiting in the global queue.
1446 intakeDefines();
1447
1448 //Mark all the dependencies as needing to be loaded.
1449 context.nextTick(function () {
1450 //Some defines could have been added since the
1451 //require call, collect them.
1452 intakeDefines();
1453
1454 requireMod = getModule(makeModuleMap(null, relMap));
1455
1456 //Store if map config should be applied to this require
1457 //call for dependencies.
1458 requireMod.skipMap = options.skipMap;
1459
1460 requireMod.init(deps, callback, errback, {
1461 enabled: true
1462 });

Callers 1

newContextFunction · 0.85

Calls 8

isFunctionFunction · 0.85
onErrorFunction · 0.85
makeErrorFunction · 0.85
hasPropFunction · 0.85
makeModuleMapFunction · 0.85
intakeDefinesFunction · 0.85
getModuleFunction · 0.85
checkLoadedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…