/
lostSun
/
project-client-server-apps
Обзор
Документация
Войти
/
lostSun
/
project-client-server-apps
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/webpack-dev-middleware/dist/utils/setupOutputFileSystem.js
58 строк
2 KB
1lostsun
initial commit
05 май 2025, 11:35
05 май 2025, 11:35
fe8f535
Код
Авторство
О чём код?
"use strict"; const path = require("path"); const memfs = require("memfs"); /** @typedef {import("webpack").MultiCompiler} MultiCompiler */ /** @typedef {import("../index.js").IncomingMessage} IncomingMessage */ /** @typedef {import("../index.js").ServerResponse} ServerResponse */ /** * @template {IncomingMessage} Request * @template {ServerResponse} Response * @param {import("../index.js").Context<Request, Response>} context */ function setupOutputFileSystem(context) { let outputFileSystem; if (context.options.outputFileSystem) { const { outputFileSystem: outputFileSystemFromOptions } = context.options; // Todo remove when we drop webpack@4 support if (typeof outputFileSystemFromOptions.join !== "function") { throw new Error("Invalid options: options.outputFileSystem.join() method is expected"); } // Todo remove when we drop webpack@4 support // @ts-ignore if (typeof outputFileSystemFromOptions.mkdirp !== "function") { throw new Error("Invalid options: options.outputFileSystem.mkdirp() method is expected"); } outputFileSystem = outputFileSystemFromOptions; } else { outputFileSystem = memfs.createFsFromVolume(new memfs.Volume()); // TODO: remove when we drop webpack@4 support // @ts-ignore outputFileSystem.join = path.join.bind(path); } const compilers = /** @type {MultiCompiler} */ context.compiler.compilers || [context.compiler]; for (const compiler of compilers) { compiler.outputFileSystem = outputFileSystem; } // @ts-ignore // eslint-disable-next-line no-param-reassign context.outputFileSystem = outputFileSystem; } module.exports = setupOutputFileSystem;