/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v5.109.1
lib/runtime/CommonJsWrapRuntimeModule.js
37 строк
1 KB
hai-x
refactor: wrapped CommonJS concatenated modules (#21464)
21 июл 2026, 14:17
Не верифицирован
21 июл 2026, 14:17
da5cb09
Код
Авторство
О чём код?
/* MIT License http://www.opensource.org/licenses/mit-license.php */ "use strict"; const RuntimeGlobals = require("../RuntimeGlobals"); const Template = require("../Template"); const HelperRuntimeModule = require("./HelperRuntimeModule"); /** @typedef {import("../Compilation")} Compilation */ class CommonJsWrapRuntimeModule extends HelperRuntimeModule { constructor() { super("wrap commonjs module"); } /** * Generates runtime code for this runtime module. * @returns {string | null} runtime code */ generate() { const compilation = /** @type {Compilation} */ (this.compilation); const { runtimeTemplate } = compilation; const fn = RuntimeGlobals.commonJsWrap; return Template.asString([ "// execute a CommonJS module body with real module/exports objects, returning the final exports", `${fn} = ${runtimeTemplate.basicFunction("body", [ `${runtimeTemplate.renderConst()} mod = { exports: {} };`, "body.call(mod.exports, mod, mod.exports);", "return mod.exports;" ])};` ]); } } module.exports = CommonJsWrapRuntimeModule;