Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (messages.errors.length > 0) {
if (tscCompileOnError) {
devSocket.warnings(messages.errors)
} else {
devSocket.errors(messages.errors)
}
} else if (messages.warnings.length > 0) {
devSocket.warnings(messages.warnings)
}
if (isInteractive) {
clearConsole()
}
}
const messages = formatWebpackMessages(statsData)
const isSuccessful = !messages.errors.length && !messages.warnings.length
if (isSuccessful) {
console.log(chalk.green('WP Compiled successfully!'))
}
if (isSuccessful && (isInteractive || isFirstCompile)) {
printInstructions(appName, urls, useYarn)
}
isFirstCompile = false
// If errors exist, only show errors.
if (messages.errors.length) {
// Only keep the first error. Others are often indicative
// of the same problem, but confuse the reader with noise.
if (messages.errors.length > 1) {
messages.errors.length = 1
}
compiler.plugin('done', function(stats) {
clearConsole();
// We have switched off the default Webpack output in WebpackDevServer
// options so we are going to "massage" the warnings and errors and present
// them in a readable focused way.
var messages = formatWebpackMessages(stats.toJson({}, true));
var isSuccessful = !messages.errors.length && !messages.warnings.length;
var showInstructions = isSuccessful && isFirstCompile;
if (isSuccessful) {
console.log(chalk.green('Compiled successfully!'));
}
if (showInstructions) {
console.log();
console.log(`The app is listening at ${devServerPublicPath}, but develop on Rails server at ${chalk.cyan(('http://localhost:3000'))}.`)
console.log();
console.log('Note that the development build is not optimized.');
console.log('To create a production build, use ' + chalk.cyan('yarn run build') + '.');
console.log();
isFirstCompile = false;
}
multiCompiler.plugin('done', stats => {
const rawMessages = stats.toJson({}, true);
const messages = formatWebpackMessages(rawMessages);
if (!messages.errors.length && !messages.warnings.length) {
logger.end('Compiled successfully!');
}
// If errors exist, only show errors.
if (messages.errors.length) {
logger.error('Failed to compile.\n');
messages.errors.forEach(e => logger.error(e));
return;
}
// Show warnings if no errors were found.
if (messages.warnings.length) {
logger.warn('Compiled with warnings.\n');
messages.warnings.forEach(w => logger.warn(w));
compiler.run((err, stats) => {
const raw = stats.toJson('verbose');
const messages = formatWebpackMessages(raw);
const outputLog = stats.toString({
colors: true,
assets: true,
chunks: false,
entrypoints: false,
hash: false,
version: false,
modules: false,
builtAt: false,
timings: false,
warnings: false,
errors: false,
});
if (!messages.errors.length && !messages.warnings.length) {
// All good
showProblems(type, errors) {
reportBuildError(formatWebpackMessages({ errors, warnings: [] }).errors[0]);
},
clear() {
showProblems(type, errors) {
const formatted = formatWebpackMessages({
errors,
warnings: [],
});
reportBuildError(formatted.errors[0]);
},
clear() {
env.CI &&
(!_.isString(env.CI) || env.CI.toLowerCase() !== 'false') &&
webMessages.warnings.length
) {
log.info(
chalk.yellow(
'\ntreating warnings as errors because `CI = true`\n' +
'most CI servers set it automatically\n'
)
);
throw new Error(webMessages.warnings.join('\n\n'));
}
log.info(chalk.green('compiled web'));
log.info('compiling server . . .');
const nodeStats = await compile(webpackNodeConfig);
const nodeMessages = formatWebpackMessages(nodeStats.toJson({}, true));
if (nodeMessages.errors.length) {
throw new Error(nodeMessages.errors.join('\n\n'));
}
if (
env.CI &&
(!_.isString(env.CI) || env.CI.toLowerCase() !== 'false') &&
nodeMessages.warnings.length
) {
log.info(
chalk.yellow(
'\ntreating warnings as errors because `CI = true`\n' +
'most CI servers set it automatically\n'
)
);
throw new Error(nodeMessages.warnings.join('\n\n'));
}
async function handleErrors(errors) {
clearErrors();
const formatted = formatWebpackMessages({ errors, warnings: [] });
reportBuildError(formatted.errors[0]);
_.each(formatted.errors, (error, index) => {
if (index < formatted.errors.length) {
if (index === 5) {
log.error(
'There were more errors in other files.\n' +
'You can find a complete log in the terminal.'
);
}
log.error(stripAnsi(error));
return true;
}
return false;
});
hadServerError = true;
hadError = true;
public format(): FormattedStats {
return formatWebpackMessages(this.stats.toJson(this.level));
}
}
reporter: (middlewareOptions, reporterOptions) => {
if (
reporterOptions.state &&
reporterOptions.stats &&
middlewareOptions.logLevel !== "silent"
) {
const stats = formatWebpackMessages(
reporterOptions.stats.toJson("verbose"),
);
if (stats) {
if (reporterOptions.stats.hasErrors()) {
logger.error(stats.errors);
logger.error("Failed to compile.");
} else if (reporterOptions.stats.hasWarnings()) {
logger.warn(stats.warnings);
logger.warn("Compiled with warnings.");
} else {
logger.info("Compiled successfully.");
}
} else {
logger.error(
"Unexpected Error: Failed to retrieve webpack stats.",
);