MCPcopy
hub / github.com/webpack/webpack / getUserRequestMap

Method getUserRequestMap

lib/ContextModule.js:639–663  ·  view source on GitHub ↗

* @param {Dependency[]} dependencies all dependencies * @param {ChunkGraph} chunkGraph chunk graph * @returns {UserRequestMap} map with user requests

(dependencies, chunkGraph)

Source from the content-addressed store, hash-verified

637 * @returns {UserRequestMap} map with user requests
638 */
639 getUserRequestMap(dependencies, chunkGraph) {
640 const moduleGraph = chunkGraph.moduleGraph;
641 // if we filter first we get a new array
642 // therefore we don't need to create a clone of dependencies explicitly
643 // therefore the order of this is !important!
644 const sortedDependencies =
645 /** @type {ContextElementDependency[]} */
646 (dependencies)
647 .filter((dependency) => moduleGraph.getModule(dependency))
648 .sort((a, b) => {
649 if (a.userRequest === b.userRequest) {
650 return 0;
651 }
652 return a.userRequest < b.userRequest ? -1 : 1;
653 });
654 /** @type {UserRequestMap} */
655 const map = Object.create(null);
656 for (const dep of sortedDependencies) {
657 const module = /** @type {Module} */ (moduleGraph.getModule(dep));
658 map[dep.userRequest] =
659 /** @type {ModuleId} */
660 (chunkGraph.getModuleId(module));
661 }
662 return map;
663 }
664
665 /**
666 * @param {Dependency[]} dependencies all dependencies

Callers 5

getSyncSourceMethod · 0.95
getWeakSyncSourceMethod · 0.95
getAsyncWeakSourceMethod · 0.95
getEagerSourceMethod · 0.95
getLazyOnceSourceMethod · 0.95

Calls 4

sortMethod · 0.80
getModuleIdMethod · 0.80
getModuleMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected