MCPcopy
hub / github.com/webpack/webpack / replacer

Function replacer

lib/TemplatedPathPlugin.js:268–288  ·  view source on GitHub ↗
(value, allowEmpty)

Source from the content-addressed store, hash-verified

266 * @returns {Replacer} replacer
267 */
268const replacer = (value, allowEmpty) => {
269 /** @type {Replacer} */
270 const fn = (match, arg, input) => {
271 if (typeof value === "function") {
272 value = value();
273 }
274 if (value === null || value === undefined) {
275 if (!allowEmpty) {
276 throw new Error(
277 `Path variable ${match} not implemented in this context: ${input}`
278 );
279 }
280
281 return "";
282 }
283
284 return `${value}`;
285 };
286
287 return fn;
288};
289
290/** @type {Map<string, (...args: EXPECTED_ANY[]) => EXPECTED_ANY>} */
291const deprecationCache = new Map();

Callers 2

fnFunction · 0.85
interpolateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected