Treat Rollup "warnings" as errors (#12868)
Dan Abramov committed
May 21, 2018 at 15:38 UTC
dc3b144f4162087665f62f4fdac69549181ce310
1 file changed
+14
-5
scripts/rollup/build.js
+14
-5
@@ -420,10 +420,6 @@ async function createBundle(bundle, bundleType) {
420
}
421
422
function handleRollupWarning(warning) {
423
- if (warning.code === 'UNRESOLVED_IMPORT') {
424
- console.error(warning.message);
425
- process.exit(1);
426
- }
423
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
424
const match = warning.message.match(/external module '([^']+)'/);
425
if (!match || typeof match[1] !== 'string') {
@@ -445,7 +441,20 @@ function handleRollupWarning(warning) {
441
// Don't warn. We will remove side effectless require() in a later pass.
442
return;
443
}
448
- console.warn(warning.message || warning);
444
+
445
+ if (typeof warning.code === 'string') {
446
+ // This is a warning coming from Rollup itself.
447
+ // These tend to be important (e.g. clashes in namespaced exports)
448
+ // so we'll fail the build on any of them.
449
+ console.error();
450
+ console.error(warning.message || warning);
451
+ console.error();
452
+ process.exit(1);
453
+ } else {
454
+ // The warning is from one of the plugins.
455
+ // Maybe it's not important, so just print it.
456
+ console.warn(warning.message || warning);
457
+ }
458
}
459
460
function handleRollupError(error) {