MCPcopy
hub / github.com/webpack/webpack / printGeneratedCodeForStack

Function printGeneratedCodeForStack

lib/javascript/JavascriptModulesPlugin.js:230–248  ·  view source on GitHub ↗
(module, code)

Source from the content-addressed store, hash-verified

228 * @returns {string} generated code for the stack
229 */
230const printGeneratedCodeForStack = (module, code) => {
231 const lines = code.split("\n");
232 const n = `${lines.length}`.length;
233 return `\n\nGenerated code for ${module.identifier()}\n${lines
234 .map(
235 /**
236 * Handles the callback logic for this hook.
237 * @param {string} line the line
238 * @param {number} i the index
239 * @param {string[]} _lines the lines
240 * @returns {string} the line with line number
241 */
242 (line, i, _lines) => {
243 const iStr = `${i + 1}`;
244 return `${" ".repeat(n - iStr.length)}${iStr} | ${line}`;
245 }
246 )
247 .join("\n")}`;
248};
249
250/**
251 * Defines the render context type used by this module.

Callers 1

applyMethod · 0.85

Calls 2

splitMethod · 0.80
identifierMethod · 0.45

Tested by

no test coverage detected