function allFields(stats, field, fields = [], name = null) {
	const info = stats.toJson({
		errors: true,
		warnings: true,
		errorDetails: false,
	});

	const addCompilerPrefix = msg =>
		name ? bold(magenta(name + ': ')) + msg : msg;

	if (field === 'errors') {
		fields = fields.concat(info.errors.map(addCompilerPrefix));
	} else {
		fields = fields.concat(info.warnings.map(addCompilerPrefix));
	}

	if (stats.compilation.children) {
		stats.compilation.children.forEach((child, index) => {
			const name = child.name || `Child Compiler ${index + 1}`;
			const stats = child.getStats();
			if (field === 'errors' ? stats.hasErrors() : stats.hasWarnings()) {
				fields = allFields(stats, field, fields, name);
			}
		});
	}

	return fields;
}
Recursively retrieve all errors or warnings from compilation

@param {import('webpack').Stats} stats
@param {'warnings' | 'errors'} field
@returns {import('webpack').StatsError[]}