Bug 1333717 - devtools-html: better webpack error messages;r=pbro draft
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 25 Jan 2017 11:16:28 +0100
changeset 466119 3495eef3666bd0e872247b2ce18a4f03a838204d
parent 466118 5af8b586cd4e0ec1db1a976b3a1addef0386a6dc
child 543336 7124de330e0f5286e8388ac278de8e044004014b
push id42806
push userjdescottes@mozilla.com
push dateWed, 25 Jan 2017 10:29:06 +0000
reviewerspbro
bugs1333717
milestone54.0a1
Bug 1333717 - devtools-html: better webpack error messages;r=pbro Added a custom plugin that will log information extracted from the compilation stats provided by webpack. MozReview-Commit-ID: FqRotgjShtD
devtools/client/inspector/webpack.config.js
--- a/devtools/client/inspector/webpack.config.js
+++ b/devtools/client/inspector/webpack.config.js
@@ -8,17 +8,17 @@
 
 const {toolboxConfig} = require("devtools-launchpad/index");
 
 const path = require("path");
 const webpack = require("webpack");
 
 module.exports = envConfig => {
   let webpackConfig = {
-    bail: true,
+    bail: false,
     entry: [
       path.join(__dirname, "local-toolbox.js")
     ],
     output: {
       path: path.join(__dirname, "assets/build"),
       filename: "inspector.js",
       publicPath: "/"
     },
@@ -91,16 +91,32 @@ module.exports = envConfig => {
         "reportError": "console.error",
         "AppConstants": "{ DEBUG: true, DEBUG_JS_MODULES: true }",
         "loader": `{
                       lazyRequireGetter: () => {},
                       lazyGetter: () => {}
                     }`,
         "dump": "console.log",
       }),
+      function () {
+        this.plugin("done", function (stats) {
+          // Log a verbose error message if the bundle creation failed.
+          if (stats.compilation.errors && stats.compilation.errors.length) {
+            console.error("\nError: Failed to create inspector bundle. Details below.\n");
+            stats.compilation.errors.forEach(e => {
+              console.error(`Error in [${e.module.userRequest}]`);
+              console.error(`Loaders: ${e.module.loaders.join(", ")}`);
+              console.error(e.error);
+            });
+
+            // Exit after failure.
+            process.exit(-1);
+          }
+        });
+      }
     ]
   };
 
   webpackConfig.externals = [
     /codemirror\//,
     {
       "promise": "var Promise",
       "devtools/server/main": "{}",