Bug 1427077 - Make devtools/client/netmonitor work correctly at browser r=rickychien
authorpd4d10 <pd4d10@gmail.com>
Wed, 03 Jan 2018 21:33:57 +0800
changeset 449482 379d966c93d2f2757ace21ef73c6fa0e635d34be
parent 449481 129681d7f7414f14ed8ec04855fc1a82df067c8f
child 449483 616f63419418e958feaa5a6df524a154905523f4
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrickychien
bugs1427077
milestone59.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 1427077 - Make devtools/client/netmonitor work correctly at browser r=rickychien Replace `loader.lazyGetter` pattern with normal variable assignment MozReview-Commit-ID: I08f8hnQ0nN
devtools/client/netmonitor/src/components/PropertiesView.js
devtools/client/netmonitor/src/components/RequestListItem.js
devtools/client/netmonitor/webpack.config.js
devtools/client/shared/webpack/rewrite-lazy-getter.js
--- a/devtools/client/netmonitor/src/components/PropertiesView.js
+++ b/devtools/client/netmonitor/src/components/PropertiesView.js
@@ -10,17 +10,16 @@ const { Component, createFactory } = req
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 
 const { FILTER_SEARCH_DELAY } = require("../constants");
 
 // Components
 const TreeViewClass = require("devtools/client/shared/components/tree/TreeView");
 const TreeView = createFactory(TreeViewClass);
-const SearchBox = createFactory(require("devtools/client/shared/components/SearchBox"));
 
 loader.lazyGetter(this, "SearchBox", function () {
   return createFactory(require("devtools/client/shared/components/SearchBox"));
 });
 loader.lazyGetter(this, "TreeRow", function () {
   return createFactory(require("devtools/client/shared/components/tree/TreeRow"));
 });
 loader.lazyGetter(this, "SourceEditor", function () {
--- a/devtools/client/netmonitor/src/components/RequestListItem.js
+++ b/devtools/client/netmonitor/src/components/RequestListItem.js
@@ -33,43 +33,76 @@ const { RESPONSE_HEADERS } = require("..
   RequestListColumnSetCookies,
   RequestListColumnStartTime,
   RequestListColumnStatus,
   RequestListColumnTransferredSize,
   RequestListColumnType,
   RequestListColumnWaterfall
 */
 
-const COLUMNS = [
-  "Cause",
-  "ContentSize",
-  "Cookies",
-  "Domain",
-  "Duration",
-  "EndTime",
-  "File",
-  "Latency",
-  "Method",
-  "Protocol",
-  "RemoteIP",
-  "ResponseHeader",
-  "ResponseTime",
-  "Scheme",
-  "SetCookies",
-  "StartTime",
-  "Status",
-  "TransferredSize",
-  "Type",
-  "Waterfall"
-];
-for (let name of COLUMNS) {
-  loader.lazyGetter(this, "RequestListColumn" + name, function () {
-    return createFactory(require("./RequestListColumn" + name));
-  });
-}
+loader.lazyGetter(this, "RequestListColumnCause", function () {
+  return createFactory(require("./RequestListColumnCause"));
+});
+loader.lazyGetter(this, "RequestListColumnContentSize", function () {
+  return createFactory(require("./RequestListColumnContentSize"));
+});
+loader.lazyGetter(this, "RequestListColumnCookies", function () {
+  return createFactory(require("./RequestListColumnCookies"));
+});
+loader.lazyGetter(this, "RequestListColumnDomain", function () {
+  return createFactory(require("./RequestListColumnDomain"));
+});
+loader.lazyGetter(this, "RequestListColumnDuration", function () {
+  return createFactory(require("./RequestListColumnDuration"));
+});
+loader.lazyGetter(this, "RequestListColumnEndTime", function () {
+  return createFactory(require("./RequestListColumnEndTime"));
+});
+loader.lazyGetter(this, "RequestListColumnFile", function () {
+  return createFactory(require("./RequestListColumnFile"));
+});
+loader.lazyGetter(this, "RequestListColumnLatency", function () {
+  return createFactory(require("./RequestListColumnLatency"));
+});
+loader.lazyGetter(this, "RequestListColumnMethod", function () {
+  return createFactory(require("./RequestListColumnMethod"));
+});
+loader.lazyGetter(this, "RequestListColumnProtocol", function () {
+  return createFactory(require("./RequestListColumnProtocol"));
+});
+loader.lazyGetter(this, "RequestListColumnRemoteIP", function () {
+  return createFactory(require("./RequestListColumnRemoteIP"));
+});
+loader.lazyGetter(this, "RequestListColumnResponseHeader", function () {
+  return createFactory(require("./RequestListColumnResponseHeader"));
+});
+loader.lazyGetter(this, "RequestListColumnResponseTime", function () {
+  return createFactory(require("./RequestListColumnResponseTime"));
+});
+loader.lazyGetter(this, "RequestListColumnScheme", function () {
+  return createFactory(require("./RequestListColumnScheme"));
+});
+loader.lazyGetter(this, "RequestListColumnSetCookies", function () {
+  return createFactory(require("./RequestListColumnSetCookies"));
+});
+loader.lazyGetter(this, "RequestListColumnStartTime", function () {
+  return createFactory(require("./RequestListColumnStartTime"));
+});
+loader.lazyGetter(this, "RequestListColumnStatus", function () {
+  return createFactory(require("./RequestListColumnStatus"));
+});
+loader.lazyGetter(this, "RequestListColumnTransferredSize", function () {
+  return createFactory(require("./RequestListColumnTransferredSize"));
+});
+loader.lazyGetter(this, "RequestListColumnType", function () {
+  return createFactory(require("./RequestListColumnType"));
+});
+loader.lazyGetter(this, "RequestListColumnWaterfall", function () {
+  return createFactory(require("./RequestListColumnWaterfall"));
+});
 
 /**
  * Used by shouldComponentUpdate: compare two items, and compare only properties
  * relevant for rendering the RequestListItem. Other properties (like request and
  * response headers, cookies, bodies) are ignored. These are very useful for the
  * network details, but not here.
  */
 const UPDATED_REQ_ITEM_PROPS = [
--- a/devtools/client/netmonitor/webpack.config.js
+++ b/devtools/client/netmonitor/webpack.config.js
@@ -34,16 +34,18 @@ let webpackConfig = {
             * so the raw-loader declared in devtools-launchpad config can load
             * those files.
             */
           "rewrite-raw",
           // Replace all references to this.browserRequire() by require()
           "rewrite-browser-require",
           // Replace all references to loader.lazyRequire() by require()
           "rewrite-lazy-require",
+          // Replace all references to loader.lazyGetter() by require()
+          "rewrite-lazy-getter",
         ],
       }
     ]
   },
 
   resolveLoader: {
     modules: [
       "node_modules",
new file mode 100644
--- /dev/null
+++ b/devtools/client/shared/webpack/rewrite-lazy-getter.js
@@ -0,0 +1,14 @@
+/* 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/. */
+
+ "use strict";
+
+module.exports = function (content) {
+  this.cacheable && this.cacheable();
+
+  return content.replace(
+    /loader.lazyGetter\(this,\s*"([^"]+)"\s*,\s*(function\s*\(\)\s*\{[\s\S]*?\})\);/g,
+    "let $1 = ($2)();"
+  );
+};