MCPcopy
hub / github.com/webpack/webpack / _createChildOptions

Method _createChildOptions

lib/MultiStats.js:69–115  ·  view source on GitHub ↗

* Create child options. * @param {undefined | StatsValue} options stats options * @param {CreateStatsOptionsContext} context context * @returns {ChildOptions} context context

(options, context)

Source from the content-addressed store, hash-verified

67 * @returns {ChildOptions} context context
68 */
69 _createChildOptions(options, context) {
70 const getCreateStatsOptions = () => {
71 if (!options) {
72 options = {};
73 }
74
75 const { children: childrenOptions = undefined, ...baseOptions } =
76 typeof options === "string"
77 ? { preset: options }
78 : /** @type {StatsOptions} */ (options);
79
80 return { childrenOptions, baseOptions };
81 };
82
83 const children = this.stats.map((stat, idx) => {
84 if (typeof options === "boolean") {
85 return stat.compilation.createStatsOptions(options, context);
86 }
87 const { childrenOptions, baseOptions } = getCreateStatsOptions();
88 const childOptions = Array.isArray(childrenOptions)
89 ? childrenOptions[idx]
90 : childrenOptions;
91 if (typeof childOptions === "boolean") {
92 return stat.compilation.createStatsOptions(childOptions, context);
93 }
94 return stat.compilation.createStatsOptions(
95 {
96 ...baseOptions,
97 ...(typeof childOptions === "string"
98 ? { preset: childOptions }
99 : childOptions && typeof childOptions === "object"
100 ? childOptions
101 : undefined)
102 },
103 context
104 );
105 });
106 return {
107 version: children.every((o) => o.version),
108 hash: children.every((o) => o.hash),
109 errorsCount: children.every((o) => o.errorsCount),
110 warningsCount: children.every((o) => o.warningsCount),
111 errors: children.every((o) => o.errors),
112 warnings: children.every((o) => o.warnings),
113 children
114 };
115 }
116
117 /**
118 * Returns json output.

Callers 2

toJsonMethod · 0.95
toStringMethod · 0.95

Calls 2

createStatsOptionsMethod · 0.80
isArrayMethod · 0.80

Tested by

no test coverage detected