MCPcopy
hub / github.com/webpack/webpack / createStatsOptions

Method createStatsOptions

lib/Compilation.js:1414–1440  ·  view source on GitHub ↗

* Creates a stats options. * @param {string | boolean | StatsOptions | undefined} optionsOrPreset stats option value * @param {CreateStatsOptionsContext=} context context * @returns {NormalizedStatsOptions} normalized options

(optionsOrPreset, context = {})

Source from the content-addressed store, hash-verified

1412 * @returns {NormalizedStatsOptions} normalized options
1413 */
1414 createStatsOptions(optionsOrPreset, context = {}) {
1415 if (typeof optionsOrPreset === "boolean") {
1416 optionsOrPreset = {
1417 preset: optionsOrPreset === false ? "none" : "normal"
1418 };
1419 } else if (typeof optionsOrPreset === "string") {
1420 optionsOrPreset = { preset: optionsOrPreset };
1421 }
1422 if (typeof optionsOrPreset === "object" && optionsOrPreset !== null) {
1423 // We use this method of shallow cloning this object to include
1424 // properties in the prototype chain
1425 /** @type {Partial<NormalizedStatsOptions>} */
1426 const options = {};
1427 for (const key in optionsOrPreset) {
1428 options[key] = optionsOrPreset[/** @type {keyof StatsOptions} */ (key)];
1429 }
1430 if (options.preset !== undefined) {
1431 this.hooks.statsPreset.for(options.preset).call(options, context);
1432 }
1433 this.hooks.statsNormalize.call(options, context);
1434 return /** @type {NormalizedStatsOptions} */ (options);
1435 }
1436 /** @type {Partial<NormalizedStatsOptions>} */
1437 const options = {};
1438 this.hooks.statsNormalize.call(options, context);
1439 return /** @type {NormalizedStatsOptions} */ (options);
1440 }
1441
1442 /**
1443 * Creates a stats factory.

Callers 4

_createChildOptionsMethod · 0.80
toJsonMethod · 0.80
toStringMethod · 0.80
applyMethod · 0.80

Calls 1

callMethod · 0.45

Tested by

no test coverage detected