thread-loader
thread-loader copied to clipboard
The emitWarning method should retain an attribute that is a reference to the native WARNING
The emitWarning method should retain an attribute that is a reference to the native WARNING, just like WEBPACK thread-loader link
// ...
emitWarning: (warning) => {
writeJson({
type: 'emitWarning',
id,
data: toErrorObj(warning),
});
},
function toErrorObj(err) {
return {
message: err.message,
details: err.details,
stack: err.stack,
hideStack: err.hideStack,
};
}
webpack link
constructor(warning, { from = null } = {}) {
let message = "Module Warning";
if (from) {
message += ` (from ${from}):\n`;
} else {
message += ": ";
}
if (warning && typeof warning === "object" && warning.message) {
message += warning.message;
} else if (warning) {
message += String(warning);
}
super(message);
this.name = "ModuleWarning";
this.warning = warning;
this.details =
warning && typeof warning === "object" && warning.stack
? cleanUp(warning.stack, this.message)
: undefined;
Error.captureStackTrace(this, this.constructor);
}
EmitError method is best like this