MCPcopy
hub / github.com/webpack/webpack / _processModuleDependencies

Method _processModuleDependencies

lib/Compilation.js:1803–2139  ·  view source on GitHub ↗

* Process module dependencies. * @param {Module} module to be processed for deps * @param {ModuleCallback} callback callback to be triggered * @returns {void}

(module, callback)

Source from the content-addressed store, hash-verified

1801 * @returns {void}
1802 */
1803 _processModuleDependencies(module, callback) {
1804 /** @type {{ factory: ModuleFactory, dependencies: Dependency[], context: string | undefined, originModule: Module | null }[]} */
1805 const sortedDependencies = [];
1806 /** @type {boolean} */
1807 const hasLowPriorityDependencies = module.dependencies.some(
1808 Dependency.isLowPriorityDependency
1809 );
1810
1811 // lazy barrel: defer re-export targets of side-effect-free modules
1812 const hasLazyBarrel = this._lazyBarrelController.classify(module);
1813
1814 /** @type {DependenciesBlock} */
1815 let currentBlock;
1816
1817 /** @type {Map<ModuleFactory, Map<string, Dependency[]>>} */
1818 let dependencies;
1819 /** @type {DependencyConstructor} */
1820 let factoryCacheKey;
1821 /** @type {ModuleFactory} */
1822 let factoryCacheKey2;
1823 /** @typedef {Map<string, Dependency[]>} FactoryCacheValue */
1824 /** @type {FactoryCacheValue | undefined} */
1825 let factoryCacheValue;
1826 /** @type {string} */
1827 let listCacheKey1;
1828 /** @type {string} */
1829 let listCacheKey2;
1830 /** @type {Dependency[]} */
1831 let listCacheValue;
1832
1833 let inProgressSorting = 1;
1834 let inProgressTransitive = 1;
1835
1836 /**
1837 * On dependencies sorted.
1838 * @param {WebpackError=} err error
1839 * @returns {void}
1840 */
1841 const onDependenciesSorted = (err) => {
1842 if (err) return callback(err);
1843
1844 // early exit without changing parallelism back and forth
1845 if (sortedDependencies.length === 0 && inProgressTransitive === 1) {
1846 return callback();
1847 }
1848
1849 // This is nested so we need to allow one additional task
1850 this.processDependenciesQueue.increaseParallelism();
1851
1852 for (const item of sortedDependencies) {
1853 inProgressTransitive++;
1854 // eslint-disable-next-line no-loop-func
1855 this.handleModuleCreation(item, (err) => {
1856 // In V8, the Error objects keep a reference to the functions on the stack. These warnings &
1857 // errors are created inside closures that keep a reference to the Compilation, so errors are
1858 // leaking the Compilation object.
1859 if (err && this.bail) {
1860 if (inProgressTransitive <= 0) return;

Callers

nothing calls this directly

Calls 4

classifyMethod · 0.80
popMethod · 0.80
callbackFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected