Bug 1403489 - remove special loader rule for devtools/shared/platform draft
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 27 Sep 2017 12:38:23 +0200
changeset 671048 e45e1904818476c053b991b09843798aff330b62
parent 671036 3e196eaaaaa9485c6f3dc3db9e91d13f2b4ef28f
child 733398 c61ec0d6aed5c02f4669f613a85bd9e2f35883a1
push id81807
push userjdescottes@mozilla.com
push dateWed, 27 Sep 2017 10:41:11 +0000
bugs1403489
milestone58.0a1
Bug 1403489 - remove special loader rule for devtools/shared/platform MozReview-Commit-ID: HwhAXHm8ipq
devtools/client/inspector/webpack.config.js
devtools/client/netmonitor/webpack.config.js
devtools/client/shared/moz.build
devtools/client/shared/webpack/moz.build
devtools/client/shared/webpack/shims/.eslintrc.js
devtools/client/shared/webpack/shims/moz.build
devtools/client/shared/webpack/shims/platform-clipboard-stub.js
devtools/client/shared/webpack/shims/platform-stack-stub.js
devtools/client/shared/webpack/shims/test/.eslintrc.js
devtools/client/shared/webpack/shims/test/mochitest.ini
devtools/client/shared/webpack/shims/test/test_clipboard.html
devtools/client/shared/webpack/shims/test/test_stack.js
devtools/client/shared/webpack/shims/test/xpcshell.ini
devtools/client/webconsole/webpack.config.js
devtools/shared/Loader.jsm
devtools/shared/platform/README.md
devtools/shared/platform/chrome/clipboard.js
devtools/shared/platform/chrome/moz.build
devtools/shared/platform/chrome/stack.js
devtools/shared/platform/clipboard.js
devtools/shared/platform/content/.eslintrc.js
devtools/shared/platform/content/clipboard.js
devtools/shared/platform/content/moz.build
devtools/shared/platform/content/stack.js
devtools/shared/platform/content/test/.eslintrc.js
devtools/shared/platform/content/test/mochitest.ini
devtools/shared/platform/content/test/test_clipboard.html
devtools/shared/platform/content/test/test_stack.js
devtools/shared/platform/content/test/xpcshell.ini
devtools/shared/platform/moz.build
devtools/shared/platform/stack.js
devtools/shared/worker/loader.js
npm-shrinkwrap.json
--- a/devtools/client/inspector/webpack.config.js
+++ b/devtools/client/inspector/webpack.config.js
@@ -94,17 +94,20 @@ module.exports = envConfig => {
         "devtools/client/jsonview/main":
           path.join(__dirname, "./webpack/jsonview-sham.js"),
         "devtools/client/sourceeditor/editor":
           path.join(__dirname, "./webpack/editor-sham.js"),
         "devtools/client/locales": path.join(__dirname, "../locales/en-US"),
         "devtools/shared/DevToolsUtils":
           path.join(__dirname, "./webpack/devtools-utils-sham.js"),
         "devtools/shared/locales": path.join(__dirname, "../../shared/locales/en-US"),
-        "devtools/shared/platform": path.join(__dirname, "../../shared/platform/content"),
+        "devtools/shared/platform/clipboard": path.join(__dirname,
+          "../../client/shared/webpack/shims/platform-clipboard-stub"),
+        "devtools/shared/platform/stack": path.join(__dirname,
+          "../../client/shared/webpack/shims/platform-clipboard-stub"),
         "devtools": path.join(__dirname, "../../"),
         "gcli": path.join(__dirname, "../../shared/gcli/source/lib/gcli"),
         "method": path.join(__dirname, "../../../addon-sdk/source/lib/method"),
         "modules/libpref/init/all":
           path.join(__dirname, "../../../modules/libpref/init/all.js"),
         "devtools/shared/generate-uuid":
           path.join(__dirname, "./webpack/uuid-sham.js"),
         "sdk": path.join(__dirname, "../../../addon-sdk/source/lib/sdk"),
--- a/devtools/client/netmonitor/webpack.config.js
+++ b/devtools/client/netmonitor/webpack.config.js
@@ -82,17 +82,17 @@ let webpackConfig = {
       "devtools/client/shared/vendor/redux": "redux",
       "devtools/client/shared/vendor/reselect": "reselect",
       "devtools/client/shared/vendor/jszip": "jszip",
 
       "devtools/client/sourceeditor/editor": "devtools-source-editor/src/source-editor",
 
       "devtools/shared/old-event-emitter": "devtools-modules/src/utils/event-emitter",
       "devtools/shared/fronts/timeline": path.join(__dirname, "../../client/shared/webpack/shims/fronts-timeline-shim"),
-      "devtools/shared/platform/clipboard": path.join(__dirname, "../../shared/platform/content/clipboard"),
+      "devtools/shared/platform/clipboard": path.join(__dirname, "../../client/shared/webpack/shims/platform-clipboard-stub"),
 
       // Locales need to be explicitly mapped to the en-US subfolder
       "devtools/client/locales": path.join(__dirname, "../../client/locales/en-US"),
       "devtools/shared/locales": path.join(__dirname, "../../shared/locales/en-US"),
       "devtools/shim/locales": path.join(__dirname, "../../shared/locales/en-US"),
       "toolkit/locales": path.join(__dirname, "../../../toolkit/locales/en-US"),
 
       // Unless a path explicitly needs to be rewritten or shimmed, all devtools paths can
--- a/devtools/client/shared/moz.build
+++ b/devtools/client/shared/moz.build
@@ -7,16 +7,17 @@
 BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
 XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
 
 DIRS += [
     'components',
     'redux',
     'source-map',
     'vendor',
+    'webpack',
     'widgets',
 ]
 
 DevToolsModules(
     'AppCacheUtils.jsm',
     'autocomplete-popup.js',
     'browser-loader.js',
     'css-angle.js',
new file mode 100644
--- /dev/null
+++ b/devtools/client/shared/webpack/moz.build
@@ -0,0 +1,9 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+DIRS += [
+    'shims',
+]
rename from devtools/shared/platform/content/.eslintrc.js
rename to devtools/client/shared/webpack/shims/.eslintrc.js
--- a/devtools/shared/platform/content/.eslintrc.js
+++ b/devtools/client/shared/webpack/shims/.eslintrc.js
@@ -1,12 +1,12 @@
 "use strict";
 
 module.exports = {
   // Extend from the devtools eslintrc.
-  "extends": "../../../.eslintrc.js",
+  "extends": "../../../../.eslintrc.js",
 
   "rules": {
     /* eslint-disable max-len */
     // All code in this directory must be content-clean.
     "mozilla/reject-some-requires": ["error", "^(chrome|chrome:.*|resource:.*|devtools/server/.*|.*\\.jsm|devtools/shared/platform/(chome|content)/.*)$"],
   },
 };
rename from devtools/shared/platform/content/moz.build
rename to devtools/client/shared/webpack/shims/moz.build
--- a/devtools/shared/platform/content/moz.build
+++ b/devtools/client/shared/webpack/shims/moz.build
@@ -1,16 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 DevToolsModules(
-    'clipboard.js',
-    'stack.js',
+    'platform-clipboard-stub.js',
+    'platform-stack-stub.js',
 )
 
 XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += [
     'test/mochitest.ini',
 ]
rename from devtools/shared/platform/content/clipboard.js
rename to devtools/client/shared/webpack/shims/platform-clipboard-stub.js
rename from devtools/shared/platform/content/stack.js
rename to devtools/client/shared/webpack/shims/platform-stack-stub.js
rename from devtools/shared/platform/content/test/.eslintrc.js
rename to devtools/client/shared/webpack/shims/test/.eslintrc.js
--- a/devtools/shared/platform/content/test/.eslintrc.js
+++ b/devtools/client/shared/webpack/shims/test/.eslintrc.js
@@ -1,6 +1,6 @@
 "use strict";
 
 module.exports = {
   // Extend from the common devtools xpcshell eslintrc config.
-  "extends": "../../../../.eslintrc.xpcshell.js"
+  "extends": "../../../../../.eslintrc.xpcshell.js"
 };
rename from devtools/shared/platform/content/test/mochitest.ini
rename to devtools/client/shared/webpack/shims/test/mochitest.ini
rename from devtools/shared/platform/content/test/test_clipboard.html
rename to devtools/client/shared/webpack/shims/test/test_clipboard.html
--- a/devtools/shared/platform/content/test/test_clipboard.html
+++ b/devtools/client/shared/webpack/shims/test/test_clipboard.html
@@ -34,17 +34,17 @@ async function pre_do_tests() {
       ["security.all_resource_uri_content_accessible", true]
     ]
   });
 
   // Load script.
   await (() => new Promise((resolve) => {
     var script = document.createElement("script");
     script.onload = resolve;
-    script.src = "resource://devtools/shared/platform/content/clipboard.js";
+    script.src = "resource://devtools/client/shared/webpack/shims/platform-stack-stub";
     document.head.appendChild(script);
   }))();
 
   do_tests();
 }
 
 function do_tests() {
   let elt = document.querySelector("#key");
rename from devtools/shared/platform/content/test/test_stack.js
rename to devtools/client/shared/webpack/shims/test/test_stack.js
--- a/devtools/shared/platform/content/test/test_stack.js
+++ b/devtools/client/shared/webpack/shims/test/test_stack.js
@@ -4,24 +4,21 @@
 // There isn't really very much about the content stack.js that we can
 // test, but we'll do what we can.
 
 "use strict";
 
 var Cu = Components.utils;
 const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
 
-// Make sure to explicitly require the content version of this module.
-// We have to use the ".." trick due to the way the loader remaps
-// devtools/shared/platform.
 const {
   callFunctionWithAsyncStack,
   getStack,
   describeNthCaller
-} = require("devtools/shared/platform/../content/stack");
+} = require("devtools/client/shared/webpack/shims/platform-stack-stub");
 
 function f3() {
   return describeNthCaller(2);
 }
 
 function f2() {
   return f3();
 }
rename from devtools/shared/platform/content/test/xpcshell.ini
rename to devtools/client/shared/webpack/shims/test/xpcshell.ini
--- a/devtools/client/webconsole/webpack.config.js
+++ b/devtools/client/webconsole/webpack.config.js
@@ -85,18 +85,18 @@ webpackConfig.resolve = {
     "devtools/client/framework/menu": "devtools-modules/src/menu",
     "devtools/client/sourceeditor/editor": "devtools-source-editor/src/source-editor",
 
     "devtools/client/shared/zoom-keys": "devtools-modules/src/zoom-keys",
 
     "devtools/shared/fronts/timeline": path.join(__dirname, "../../client/shared/webpack/shims/fronts-timeline-shim"),
     "devtools/shared/old-event-emitter": "devtools-modules/src/utils/event-emitter",
     "devtools/shared/client/main": path.join(__dirname, "new-console-output/test/fixtures/ObjectClient"),
-    "devtools/shared/platform/clipboard": path.join(__dirname, "../../shared/platform/content/clipboard"),
-    "devtools/shared/platform/stack": path.join(__dirname, "../../shared/platform/content/stack"),
+    "devtools/shared/platform/clipboard": path.join(__dirname, "../../client/shared/webpack/shims/platform-clipboard-stub"),
+    "devtools/shared/platform/stack": path.join(__dirname, "../../client/shared/webpack/shims/platform-stack-stub"),
 
     // Locales need to be explicitly mapped to the en-US subfolder
     "toolkit/locales": path.join(__dirname, "../../../toolkit/locales/en-US"),
     "devtools/client/locales": path.join(__dirname, "../../client/locales/en-US"),
     "devtools/shared/locales": path.join(__dirname, "../../shared/locales/en-US"),
     "devtools/shim/locales": path.join(__dirname, "../../shared/locales/en-US"),
 
     // Unless a path explicitly needs to be rewritten or shimmed, all devtools paths can
--- a/devtools/shared/Loader.jsm
+++ b/devtools/shared/Loader.jsm
@@ -25,23 +25,16 @@ this.EXPORTED_SYMBOLS = ["DevToolsLoader
  * Used when the tools should be loaded from the Firefox package itself.
  * This is the default case.
  */
 function BuiltinProvider() {}
 BuiltinProvider.prototype = {
   load: function () {
     const paths = {
       // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
-      // Modules here are intended to have one implementation for
-      // chrome, and a separate implementation for content.  Here we
-      // map the directory to the chrome subdirectory, but the content
-      // loader will map to the content subdirectory.  See the
-      // README.md in devtools/shared/platform.
-      "devtools/shared/platform": "resource://devtools/shared/platform/chrome",
-      // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
       "devtools": "resource://devtools",
       // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
       "gcli": "resource://devtools/shared/gcli/source/lib/gcli",
       // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
       "acorn": "resource://devtools/shared/acorn",
       // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
       "acorn/util/walk": "resource://devtools/shared/acorn/walk.js",
       // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
deleted file mode 100644
--- a/devtools/shared/platform/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-This directory is treated specially by the loaders.
-
-In particular, when running in chrome, a resource like
-"devtools/shared/platform/mumble" will be found in the chrome
-subdirectory; and when running in content, it will be found in the
-content subdirectory.
-
-Outside of tests, it's not ok to require a specific version of a file;
-and there is an eslint test to check for that.  That is,
-require("devtools/shared/platform/client/mumble") is an error.
-
-When adding a new file, you must add two copies, one to chrome and one
-to content.  Otherwise, one case or the other will fail to work.
deleted file mode 100644
--- a/devtools/shared/platform/chrome/moz.build
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-DevToolsModules(
-    'clipboard.js',
-    'stack.js',
-)
rename from devtools/shared/platform/chrome/clipboard.js
rename to devtools/shared/platform/clipboard.js
--- a/devtools/shared/platform/moz.build
+++ b/devtools/shared/platform/moz.build
@@ -1,10 +1,10 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
-DIRS += [
-    'chrome',
-    'content',
-]
+DevToolsModules(
+    'clipboard.js',
+    'stack.js',
+)
rename from devtools/shared/platform/chrome/stack.js
rename to devtools/shared/platform/stack.js
--- a/devtools/shared/worker/loader.js
+++ b/devtools/shared/worker/loader.js
@@ -573,23 +573,16 @@ this.worker = new WorkerDebuggerLoader({
   modules: {
     "Debugger": Debugger,
     "Services": Object.create(null),
     "chrome": chrome,
     "xpcInspector": xpcInspector
   },
   paths: {
     // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
-    // Modules here are intended to have one implementation for
-    // chrome, and a separate implementation for content.  Here we
-    // map the directory to the chrome subdirectory, but the content
-    // loader will map to the content subdirectory.  See the
-    // README.md in devtools/shared/platform.
-    "devtools/shared/platform": "resource://devtools/shared/platform/chrome",
-    // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
     "devtools": "resource://devtools",
     // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
     "promise": "resource://gre/modules/Promise-backend.js",
     // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
     "source-map": "resource://devtools/shared/sourcemap/source-map.js",
     // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
     "xpcshell-test": "resource://test"
     // ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
--- a/npm-shrinkwrap.json
+++ b/npm-shrinkwrap.json
@@ -530,30 +530,30 @@
       "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=",
       "requires": {
         "is-property": "1.0.2"
       }
     },
     "glob": {
       "version": "7.1.2",
       "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
-      "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+      "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
       "requires": {
         "fs.realpath": "1.0.0",
         "inflight": "1.0.6",
         "inherits": "2.0.3",
         "minimatch": "3.0.4",
         "once": "1.4.0",
         "path-is-absolute": "1.0.1"
       }
     },
     "globals": {
       "version": "9.18.0",
       "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz",
-      "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ=="
+      "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo="
     },
     "globby": {
       "version": "5.0.0",
       "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
       "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=",
       "requires": {
         "array-union": "1.0.2",
         "arrify": "1.0.1",
@@ -758,17 +758,17 @@
     "lodash": {
       "version": "4.17.4",
       "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
       "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
     },
     "minimatch": {
       "version": "3.0.4",
       "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
-      "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+      "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
       "requires": {
         "brace-expansion": "1.1.8"
       }
     },
     "minimist": {
       "version": "0.0.8",
       "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
       "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
@@ -888,17 +888,17 @@
     "progress": {
       "version": "1.1.8",
       "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz",
       "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74="
     },
     "readable-stream": {
       "version": "2.3.3",
       "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
-      "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
+      "integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=",
       "requires": {
         "core-util-is": "1.0.2",
         "inherits": "2.0.3",
         "isarray": "1.0.0",
         "process-nextick-args": "1.0.7",
         "safe-buffer": "5.1.1",
         "string_decoder": "1.0.3",
         "util-deprecate": "1.0.2"
@@ -972,17 +972,17 @@
     "rx-lite": {
       "version": "3.1.2",
       "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz",
       "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI="
     },
     "safe-buffer": {
       "version": "5.1.1",
       "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
-      "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
+      "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM="
     },
     "sax": {
       "version": "1.2.4",
       "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
       "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
     },
     "shelljs": {
       "version": "0.7.8",
@@ -1012,17 +1012,17 @@
         "code-point-at": "1.1.0",
         "is-fullwidth-code-point": "1.0.0",
         "strip-ansi": "3.0.1"
       }
     },
     "string_decoder": {
       "version": "1.0.3",
       "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
-      "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+      "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
       "requires": {
         "safe-buffer": "5.1.1"
       }
     },
     "strip-ansi": {
       "version": "3.0.1",
       "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
       "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",