/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lib/util/preloadModuleType.js
32 строки
1 KB
Alexander Akait
perf: load webpack's own modules only when a build needs them (#21652)
10 авг 2026, 07:32
Не верифицирован
10 авг 2026, 07:32
8e28763
Код
Авторство
О чём код?
/* MIT License http://www.opensource.org/licenses/mit-license.php Author Alexander Akait @alexander-akait */ "use strict"; /** @typedef {import("../NormalModuleFactory")} NormalModuleFactory */ /** @typedef {import("./lazyModule").LazyModuleAccessor<EXPECTED_ANY>} AnyLazyModuleAccessor */ /** * Warms the modules a type's `createParser`/`createGenerator`/`createModuleClass` * taps read, at the factory's async boundary — those hooks are synchronous, so * they cannot await the load themselves. * @param {NormalModuleFactory} normalModuleFactory the normal module factory * @param {string} pluginName name of the tapping plugin * @param {Iterable<[string, AnyLazyModuleAccessor[]]>} table module type to the accessors its taps read * @returns {void} */ const preloadModuleType = (normalModuleFactory, pluginName, table) => { for (const [type, accessors] of table) { normalModuleFactory.hooks.prepareModuleType .for(type) .tapPromise(pluginName, () => Promise.all(accessors.map((accessor) => accessor())).then( () => undefined ) ); } }; module.exports = preloadModuleType;