Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent calling stats.toJson() #1910

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/razzle-dev-utils/FriendlyErrorsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class WebpackErrorsPlugin {

apply(compiler) {
compiler.plugin('done', stats => {
const rawMessages = stats.toJson({}, true);
const rawMessages = stats.toJson('errors-warnings');
const messages = formatWebpackMessages(rawMessages);
WEBPACK_COMPILING = false;
if (!messages.errors.length && !messages.warnings.length) {
Expand Down
26 changes: 14 additions & 12 deletions packages/razzle/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,31 @@ loadRazzleConfig(webpack).then(
if (err) {
return reject(err);
}
const clientMessages = clientStats.toJson({}, true);
if (clientMessages.errors.length) {
return reject(clientMessages.errors);
if (clientStats.hasErrors()) {
return reject(clientStats.toJson('errors-only').errors);
}
if (
!process.env.WARNINGS_ERRORS_DISABLE &&
process.env.CI &&
(typeof process.env.CI !== 'string' ||
process.env.CI.toLowerCase() !== 'false') &&
clientMessages.warnings.length
clientStats.hasWarnings()
) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(clientMessages.warnings);
return reject(clientStats.toJson('errors-warnings').warnings);
}

return resolve({
stats: clientStats,
previousFileSizes,
warnings: clientMessages.warnings,
warnings: clientStats.hasWarnings()
? clientStats.toJson('errors-warnings').warnings
: [],
});
}, (err) => {
return reject(err);
Expand Down Expand Up @@ -225,29 +226,30 @@ loadRazzleConfig(webpack).then(
if (err) {
return reject(err);
}
const serverMessages = serverStats.toJson({}, true);
if (serverMessages.errors.length) {
return reject(serverMessages.errors);
if (serverStats.hasErrors()) {
return reject(serverStats.toJson('errors-only').errors);
}
if (
!process.env.WARNINGS_ERRORS_DISABLE &&
process.env.CI &&
(typeof process.env.CI !== 'string' ||
process.env.CI.toLowerCase() !== 'false') &&
serverMessages.warnings.length
serverStats.hasWarnings()
) {
console.log(
chalk.yellow(
'\nTreating warnings as errors because process.env.CI = true.\n' +
'Most CI servers set it automatically.\n'
)
);
return reject(serverMessages.warnings);
return reject(serverStats.toJson('errors-warnings').warnings);
}

return resolve({
stats: serverStats,
warnings: serverMessages.warnings,
warnings: serverStats.hasWarnings()
? serverStats.toJson('errors-warnings').warnings
: [],
});
}, (err) => {
return reject(err);
Expand Down