Bug 1390815 - Fix console launchpad. r=bgrins,Honza,jdescottes
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 29 Aug 2017 09:46:49 +0200
changeset 378010 79c33fb4ac95e9d9fe99d90d2c0ee22bd76d32c2
parent 378009 7ee88ddf08f4a01bcb233bca1b5fcab8feaa92b4
child 378011 2a69de9c73c65db3a24f2e1fe5e5ab3bd807ca4c
push id50148
push usernchevobbe@mozilla.com
push dateThu, 31 Aug 2017 16:24:44 +0000
treeherderautoland@79c33fb4ac95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins, Honza, jdescottes
bugs1390815
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1390815 - Fix console launchpad. r=bgrins,Honza,jdescottes This updates devtools-launchpad to 0.0.96, and thus makes the console launchpad uses Webpack 3. Because of this version bump, the console launchpad config needed some adjustments to keep working: - Replace loaders with rules - Pass the babelExclude property in the option argument for launchpad config - Change the name of the svg filter to exclude - Add a workaround "raw!" required-files (remove the "raw!" prefix in a loader). An alias needed to be added as well for devtools/shim/locales. MozReview-Commit-ID: 3cWXYw6gNc7
devtools/client/webconsole/package.json
devtools/client/webconsole/webpack.config.js
devtools/client/webconsole/webpack/rewrite-raw.js
--- a/devtools/client/webconsole/package.json
+++ b/devtools/client/webconsole/package.json
@@ -11,18 +11,18 @@
   },
   "dependencies": {
     "amd-loader": "0.0.5",
     "babel-preset-es2015": "^6.6.0",
     "babel-preset-es2017": "^6.24.1",
     "babel-register": "^6.24.0",
     "cross-env": "^3.1.3",
     "devtools-config": "0.0.12",
-    "devtools-launchpad": "0.0.67",
-    "devtools-modules": "0.0.28",
+    "devtools-launchpad": "0.0.96",
+    "devtools-modules": "0.0.31",
     "enzyme": "^2.4.1",
     "expect": "^1.16.0",
     "file-loader": "^0.10.1",
     "immutable": "^3.8.1",
     "jsdom": "^9.4.1",
     "jsdom-global": "^2.0.0",
     "json-loader": "^0.5.4",
     "mocha": "^2.5.3",
--- a/devtools/client/webconsole/webpack.config.js
+++ b/devtools/client/webconsole/webpack.config.js
@@ -15,21 +15,40 @@ const path = require("path");
 const projectPath = path.join(__dirname, "local-dev");
 
 let webpackConfig = {
   entry: {
     console: [path.join(projectPath, "index.js")],
   },
 
   module: {
-    loaders: [
+    rules: [
       {
         test: /\.(png|svg)$/,
         loader: "file-loader?name=[path][name].[ext]",
       },
+      {
+        /*
+         * The version of webpack used in the launchpad seems to have trouble
+         * with the require("raw!${file}") that we use for the properties
+         * file in l10.js.
+         * This loader goes through the whole code and remove the "raw!" prefix
+         * so the raw-loader declared in devtools-launchpad config can load
+         * those files.
+         */
+        test: /\.js/,
+        loader: "rewrite-raw",
+      },
+    ]
+  },
+
+  resolveLoader: {
+    modules: [
+      path.resolve("./node_modules"),
+      path.resolve("./webpack"),
     ]
   },
 
   output: {
     path: path.join(__dirname, "assets/build"),
     filename: "[name].js",
     publicPath: "/assets/build",
   },
@@ -56,16 +75,17 @@ webpackConfig.resolve = {
     "devtools/client/shared/vendor/react": "react",
     "devtools/client/shared/vendor/react-dom": "react-dom",
     "devtools/client/shared/vendor/react-redux": "react-redux",
     "devtools/client/shared/vendor/redux": "redux",
 
     "devtools/client/locales": path.join(__dirname, "../../client/locales/en-US"),
     "toolkit/locales": path.join(__dirname, "../../../toolkit/locales/en-US"),
     "devtools/shared/locales": path.join(__dirname, "../../shared/locales/en-US"),
+    "devtools/shim/locales": path.join(__dirname, "../../shared/locales/en-US"),
     "devtools/shared/plural-form": path.join(__dirname, "../../shared/plural-form"),
     "devtools/shared/l10n": path.join(__dirname, "../../shared/l10n"),
     "devtools/shared/system": path.join(projectPath, "system-stub"),
 
     "devtools/client/framework/devtools": path.join(__dirname, "../../client/shims/devtools"),
     "devtools/client/framework/menu": "devtools-modules/src/menu",
     "devtools/client/framework/menu-item": path.join(__dirname, "../../client/framework/menu-item"),
 
@@ -111,24 +131,23 @@ const mappings = [
         .replace("./resource://devtools/client", path.join(__dirname, ".."));
     }
   ],
 ];
 
 webpackConfig.plugins = mappings.map(([regex, res]) =>
   new NormalModuleReplacementPlugin(regex, res));
 
-// Exclude to transpile all scripts in devtools/ but not for this folder
 const basePath = path.join(__dirname, "../../").replace(/\\/g, "\\\\");
 const baseName = path.basename(__dirname);
-webpackConfig.babelExcludes = new RegExp(`^${basePath}(.(?!${baseName}))*$`);
 
-let config = toolboxConfig(webpackConfig, getConfig());
+let config = toolboxConfig(webpackConfig, getConfig(), {
+  // Exclude to transpile all scripts in devtools/ but not for this folder
+  babelExcludes: new RegExp(`^${basePath}(.(?!${baseName}))*$`)
+});
 
 // Remove loaders from devtools-launchpad's webpack.config.js
 // * For svg-inline loader:
-//   Webconsole uses file loader to bundle image assets instead of svg-inline loader
-// * For raw loader:
-//   devtools/shared/l10n has preloaded raw loader in require.context
-config.module.loaders = config.module.loaders
-  .filter((loader) => !["svg-inline", "raw"].includes(loader.loader));
+//   Webconsole uses file loader to bundle image assets instead of svg-inline-loader
+config.module.rules = config.module.rules
+  .filter((rule) => !["svg-inline-loader"].includes(rule.loader));
 
 module.exports = config;
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/webpack/rewrite-raw.js
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Remove the "raw!" prefix used in some require which confuses webpack.
+
+"use strict";
+
+module.exports = function (content) {
+  this.cacheable && this.cacheable();
+  return content.replace(/raw\!/g, "");
+};