MCPcopy
hub / github.com/webpack/webpack / getModuleDeferredAsyncDepsMap

Method getModuleDeferredAsyncDepsMap

lib/ContextModule.js:752–777  ·  view source on GitHub ↗

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

(dependencies, chunkGraph)

Source from the content-addressed store, hash-verified

750 * @returns {UserRequestsMap} map with user requests
751 */
752 getModuleDeferredAsyncDepsMap(dependencies, chunkGraph) {
753 const moduleGraph = chunkGraph.moduleGraph;
754 const comparator = compareModulesById(chunkGraph);
755 // if we filter first we get a new array
756 // therefore we don't need to create a clone of dependencies explicitly
757 // therefore the order of this is !important!
758 const sortedModules = dependencies
759 .map(
760 (dependency) =>
761 /** @type {Module} */ (moduleGraph.getModule(dependency))
762 )
763 .filter(Boolean)
764 .sort(comparator);
765 /** @type {UserRequestsMap} */
766 const map = Object.create(null);
767 for (const module of sortedModules) {
768 if (!(/** @type {BuildMeta} */ (module.buildMeta).async)) {
769 const id = /** @type {ModuleId} */ (chunkGraph.getModuleId(module));
770 map[id] = Array.from(
771 getOutgoingAsyncModules(chunkGraph.moduleGraph, module),
772 (m) => chunkGraph.getModuleId(m)
773 ).filter((id) => id !== null);
774 }
775 }
776 return map;
777 }
778
779 /**
780 * @param {false | UserRequestsMap} asyncDepsMap fake map

Callers 3

getAsyncWeakSourceMethod · 0.95
getEagerSourceMethod · 0.95
getLazyOnceSourceMethod · 0.95

Calls 6

compareModulesByIdFunction · 0.85
getOutgoingAsyncModulesFunction · 0.85
sortMethod · 0.80
getModuleIdMethod · 0.80
getModuleMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected