Bug 1365014 - inspector.html add shims for sdk, uuid, lazy requires;r=gl

MozReview-Commit-ID: CtYnDV4V0HU

--HG--
extra : rebase_source : 5def350faa8202a6c5f1c81af420ba3c7cb4256e
This commit is contained in:
Julian Descottes 2017-05-11 23:43:01 +02:00
Родитель 9954280035
Коммит a4c27f4a89
7 изменённых файлов: 123 добавлений и 6 удалений

Просмотреть файл

@ -23,7 +23,10 @@ module.exports = envConfig => {
publicPath: "/"
},
module: {
noParse: /(debugger\/new)|netmonitor\/panel\.js/i,
noParse: [
/netmonitor\/panel\.js/i,
/debugger\/new\/panel\.js/i
],
// Disable handling of unknown requires
unknownContextRegExp: /$^/,
@ -42,10 +45,30 @@ module.exports = envConfig => {
exclude: /node_modules/,
loaders: [path.join(__dirname, "./webpack/rewrite-event-emitter")],
}, {
// Replace all references to this.browserRequire() by require() in
// client/inspector/*.js files
test: /client(\/|\\)inspector(\/|\\).*\.js$/,
loaders: [path.join(__dirname, "./webpack/rewrite-browser-require")],
loaders: [
// Replace all references to this.browserRequire() by require()
path.join(__dirname, "./webpack/rewrite-browser-require"),
// Replace all references to loader.lazyRequire() by require()
path.join(__dirname, "./webpack/rewrite-lazy-require"),
],
}, {
test: /shared(\/|\\)inspector(\/|\\)css-logic\.js$/,
loaders: [
// Replace a very specific lazy importer, which should really be moved to
// /server ...
path.join(__dirname, "./webpack/rewrite-css-logic-importer"),
],
}, {
test: /react-redux\.js$/,
loaders: [
// Replace dynamic paths in react-redux file
path.join(__dirname, "./webpack/rewrite-react-redux"),
],
}, {
// Replace all references sdk's lazyRequire by require()
test: /sdk(\/|\\).*\.js$/,
loaders: [path.join(__dirname, "./webpack/rewrite-sdk-lazy-require")],
}
]
},
@ -57,6 +80,9 @@ module.exports = envConfig => {
},
resolve: {
alias: {
"react": "devtools/client/shared/vendor/react",
"redux": "devtools/client/shared/vendor/redux",
"react-dom": "devtools/client/shared/vendor/react-dom",
"acorn/util/walk": path.join(__dirname, "../../shared/acorn/walk"),
"acorn": path.join(__dirname, "../../shared/acorn"),
"devtools/client/framework/about-devtools-toolbox":
@ -79,12 +105,12 @@ module.exports = envConfig => {
"method": path.join(__dirname, "../../../addon-sdk/source/lib/method"),
"modules/libpref/init/all":
path.join(__dirname, "../../../modules/libpref/init/all.js"),
"sdk/util/uuid":
path.join(__dirname, "./webpack/uuid-sham.js"),
"sdk": path.join(__dirname, "../../../addon-sdk/source/lib/sdk"),
"Services": path.join(__dirname, "../shared/shim/Services.js"),
"toolkit/locales":
path.join(__dirname, "../../../toolkit/locales/en-US/chrome/global"),
"react": "devtools/client/shared/vendor/react",
"react-dom": "devtools/client/shared/vendor/react-dom",
},
},

Просмотреть файл

@ -10,4 +10,18 @@
module.exports = {
executeSoon: setImmediate,
isGenerator: function (fn) {
if (typeof fn !== "function") {
return false;
}
let proto = Object.getPrototypeOf(fn);
if (!proto) {
return false;
}
let ctor = proto.constructor;
if (!ctor) {
return false;
}
return ctor.name == "GeneratorFunction";
}
};

Просмотреть файл

@ -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.lazyImporter(this, \"findCssSelector\", \"resource://gre/modules/css-selector.js\");",
"let findCssSelector = function () {};"
);
};

Просмотреть файл

@ -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.lazyRequireGetter\(this,\s*"([^"]+)",[^"]*"([^"]+)", true\);/g,
"let { $1 } = require(\"$2\")"
);
};

Просмотреть файл

@ -0,0 +1,17 @@
/* 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(
"require(REACT_PATH)",
"require(\"devtools/client/shared/vendor/react\")"
).replace(
"require(REDUX_PATH)",
"require(\"devtools/client/shared/vendor/redux\")"
);
};

Просмотреть файл

@ -0,0 +1,13 @@
/* 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(
/lazyRequire\(this,\s*([^,]+),\s*"([^"]+)"\);/g,
"let { $2 } = require($1)"
);
};

Просмотреть файл

@ -0,0 +1,19 @@
/* 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";
const s4 = function () {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
};
let uuid = function () {
return "ss-s-s-s-sss".replace(/s/g, function () {
return s4();
});
};
module.exports = { uuid };