/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/cases/errors/load-module-cycle-multiple/loader.js
31 строка
1 KB
Alexander Akait
fix: no `object` types and less `any` types
02 апр 2025, 19:02
Не верифицирован
02 апр 2025, 19:02
e911f52
Код
Авторство
О чём код?
const { promisify } = require("util"); /** @type {import("../../../../").LoaderDefinitionFunction} */ exports.default = function (source) { const content = JSON.parse(source); // content is one reference or an array of references const refs = Array.isArray(content) ? content : [content]; const callback = this.async(); const loadModulePromise = promisify(this.loadModule.bind(this)); async function loadReferencedModules() { // Modules are loaded sequentially as the false-positive circular reference // bug from https://github.com/webpack/webpack/issues/14379 doesn't occur if // they are loaded in parallel. const loadedRefs = [] for(const ref of refs) { try { const source = await loadModulePromise("../loader!" + ref); loadedRefs.push([ref, JSON.parse(source)]); } catch(_err) { const err = /** @type {Error} */ (_err); loadedRefs.push([ref, `err: ${err && err.message}`]); } } return loadedRefs; } loadReferencedModules().then((loadResults) => { callback(null, JSON.stringify(loadResults)); }); };