Backed out changeset ec1ebd2666c7 (bug 1309866)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 09 Dec 2016 15:45:49 +0100
changeset 325489 6a75cf810d963de5b83c3aacb4c776604474302f
parent 325488 f74a13482aa727cf0ed3a332b22886f222eeea08
child 325490 8404d26166a35406f46ff237ed132735c98882b2
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
bugs1309866
milestone53.0a1
backs outec1ebd2666c7e7b9379ccc19c01a0764436a0d6b
Backed out changeset ec1ebd2666c7 (bug 1309866)
devtools/client/shared/browser-loader.js
--- a/devtools/client/shared/browser-loader.js
+++ b/devtools/client/shared/browser-loader.js
@@ -13,20 +13,16 @@ const { AppConstants } = devtools.requir
 
 const BROWSER_BASED_DIRS = [
   "resource://devtools/client/inspector/layout",
   "resource://devtools/client/jsonview",
   "resource://devtools/client/shared/vendor",
   "resource://devtools/client/shared/redux",
 ];
 
-const COMMON_LIBRARY_DIRS = [
-  "resource://devtools/client/shared/vendor",
-];
-
 // Any directory that matches the following regular expression
 // is also considered as browser based module directory.
 // ('resource://devtools/client/.*/components/')
 //
 // An example:
 // * `resource://devtools/client/inspector/components`
 // * `resource://devtools/client/inspector/shared/components`
 const browserBasedDirsRegExp =
@@ -80,22 +76,18 @@ function BrowserLoader(options) {
  *
  * @param string baseURI
  *        Base path to load modules from.
  * @param Object window
  *        The window instance to evaluate modules within
  * @param Boolean useOnlyShared
  *        If true, ignores `baseURI` and only loads the shared
  *        BROWSER_BASED_DIRS via BrowserLoader.
- * @param Function commonLibRequire
- *        Require function that should be used to load common libraries, like React.
- *        Allows for sharing common modules between tools, instead of loading a new
- *        instance into each tool. For example, pass "toolbox.browserRequire" here.
  */
-function BrowserLoaderBuilder({ baseURI, window, useOnlyShared, commonLibRequire }) {
+function BrowserLoaderBuilder({ baseURI, window, useOnlyShared }) {
   assert(!!baseURI !== !!useOnlyShared,
     "Cannot use both `baseURI` and `useOnlyShared`.");
 
   const loaderOptions = devtools.require("@loader/options");
   const dynamicPaths = {};
   const componentProxies = new Map();
 
   if (AppConstants.DEBUG || AppConstants.DEBUG_JS_MODULES) {
@@ -112,25 +104,25 @@ function BrowserLoaderBuilder({ baseURI,
     requireHook: (id, require) => {
       // If |id| requires special handling, simply defer to devtools
       // immediately.
       if (devtools.isLoaderPluginId(id)) {
         return devtools.require(id);
       }
 
       const uri = require.resolve(id);
+      let isBrowserDir = BROWSER_BASED_DIRS.filter(dir => {
+        return uri.startsWith(dir);
+      }).length > 0;
 
-      if (commonLibRequire && COMMON_LIBRARY_DIRS.some(dir => uri.startsWith(dir))) {
-        return commonLibRequire(uri);
+      // If the URI doesn't match hardcoded paths try the regexp.
+      if (!isBrowserDir) {
+        isBrowserDir = uri.match(browserBasedDirsRegExp) != null;
       }
 
-      // Check if the URI matches one of hardcoded paths or a regexp.
-      let isBrowserDir = BROWSER_BASED_DIRS.some(dir => uri.startsWith(dir)) ||
-                         uri.match(browserBasedDirsRegExp) != null;
-
       if ((useOnlyShared || !uri.startsWith(baseURI)) && !isBrowserDir) {
         return devtools.require(uri);
       }
 
       return require(uri);
     },
     globals: {
       // Allow modules to use the window's console to ensure logs appear in a