mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1881819 - Remove now redundant inject-loader from asrouter/aboutwelcome/newtab code. r=aminomancer,omc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D202621
This commit is contained in:
parent
25ccfc2279
commit
fb52e933e4
@ -161,12 +161,6 @@ module.exports = function (config) {
|
||||
webpack: {
|
||||
mode: "none",
|
||||
devtool: "inline-source-map",
|
||||
// This loader allows us to override required files in tests
|
||||
resolveLoader: {
|
||||
alias: {
|
||||
inject: path.join(__dirname, "../newtab/loaders/inject-loader"),
|
||||
},
|
||||
},
|
||||
// This resolve config allows us to import with paths relative to the root directory
|
||||
resolve: {
|
||||
extensions: [".js", ".jsx"],
|
||||
|
@ -122,12 +122,6 @@ module.exports = function (config) {
|
||||
webpack: {
|
||||
mode: "none",
|
||||
devtool: "inline-source-map",
|
||||
// This loader allows us to override required files in tests
|
||||
resolveLoader: {
|
||||
alias: {
|
||||
inject: path.join(__dirname, "../newtab/loaders/inject-loader"),
|
||||
},
|
||||
},
|
||||
// This resolve config allows us to import with paths relative to the root directory
|
||||
resolve: {
|
||||
extensions: [".js", ".jsx"],
|
||||
|
@ -209,10 +209,6 @@ module.exports = function (config) {
|
||||
webpack: {
|
||||
mode: "none",
|
||||
devtool: "inline-source-map",
|
||||
// This loader allows us to override required files in tests
|
||||
resolveLoader: {
|
||||
alias: { inject: path.join(__dirname, "loaders/inject-loader") },
|
||||
},
|
||||
// This resolve config allows us to import with paths relative to the root directory, e.g. "lib/ActivityStream.sys.mjs"
|
||||
resolve: {
|
||||
extensions: [".js", ".jsx"],
|
||||
|
@ -1,59 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// Note: this is based on https://github.com/plasticine/inject-loader,
|
||||
// patched to make istanbul work properly
|
||||
|
||||
const loaderUtils = require("loader-utils");
|
||||
const QUOTE_REGEX_STRING = "['|\"]{1}";
|
||||
|
||||
const hasOnlyExcludeFlags = query =>
|
||||
Object.keys(query).filter(key => query[key] === true).length === 0;
|
||||
const escapePath = path => path.replace("/", "\\/");
|
||||
|
||||
function createRequireStringRegex(query) {
|
||||
const regexArray = [];
|
||||
|
||||
// if there is no query then replace everything
|
||||
if (Object.keys(query).length === 0) {
|
||||
regexArray.push("([^\\)]+)");
|
||||
} else if (hasOnlyExcludeFlags(query)) {
|
||||
// if there are only negation matches in the query then replace everything
|
||||
// except them
|
||||
Object.keys(query).forEach(key =>
|
||||
regexArray.push(`(?!${QUOTE_REGEX_STRING}${escapePath(key)})`)
|
||||
);
|
||||
regexArray.push("([^\\)]+)");
|
||||
} else {
|
||||
regexArray.push(`(${QUOTE_REGEX_STRING}(`);
|
||||
regexArray.push(
|
||||
Object.keys(query)
|
||||
.map(key => escapePath(key))
|
||||
.join("|")
|
||||
);
|
||||
regexArray.push(`)${QUOTE_REGEX_STRING})`);
|
||||
}
|
||||
|
||||
// Wrap the regex to match `require()`
|
||||
regexArray.unshift("require\\(");
|
||||
regexArray.push("\\)");
|
||||
|
||||
return new RegExp(regexArray.join(""), "g");
|
||||
}
|
||||
|
||||
module.exports = function inject(src) {
|
||||
if (this.cacheable) {
|
||||
this.cacheable();
|
||||
}
|
||||
const regex = createRequireStringRegex(
|
||||
loaderUtils.urlToRequest(this.resourcePath) || {}
|
||||
);
|
||||
|
||||
return `module.exports = function inject(injections) {
|
||||
var module = {exports: {}};
|
||||
var exports = module.exports;
|
||||
${src.replace(regex, "(injections[$1] || /* istanbul ignore next */ $&)")}
|
||||
return module.exports;
|
||||
}\n`;
|
||||
};
|
16
browser/components/newtab/package-lock.json
generated
16
browser/components/newtab/package-lock.json
generated
@ -36,7 +36,6 @@
|
||||
"karma-sinon": "1.0.5",
|
||||
"karma-sourcemap-loader": "0.3.8",
|
||||
"karma-webpack": "5.0.0",
|
||||
"loader-utils": "3.2.1",
|
||||
"lodash": "4.17.21",
|
||||
"mocha": "9.2.2",
|
||||
"mock-raf": "1.0.1",
|
||||
@ -4066,15 +4065,6 @@
|
||||
"node": ">=6.11.5"
|
||||
}
|
||||
},
|
||||
"node_modules/loader-utils": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-3.2.1.tgz",
|
||||
"integrity": "sha512-ZvFw1KWS3GVyYBYb7qkmRM/WwL2TQQBxgCK62rlvm4WpVQ23Nb4tYjApUlfjrEGvOs7KHEsmyUn75OHZrJMWPw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 12.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/locate-path": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
||||
@ -10090,12 +10080,6 @@
|
||||
"integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==",
|
||||
"dev": true
|
||||
},
|
||||
"loader-utils": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-3.2.1.tgz",
|
||||
"integrity": "sha512-ZvFw1KWS3GVyYBYb7qkmRM/WwL2TQQBxgCK62rlvm4WpVQ23Nb4tYjApUlfjrEGvOs7KHEsmyUn75OHZrJMWPw==",
|
||||
"dev": true
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
||||
|
@ -34,7 +34,6 @@
|
||||
"karma-sinon": "1.0.5",
|
||||
"karma-sourcemap-loader": "0.3.8",
|
||||
"karma-webpack": "5.0.0",
|
||||
"loader-utils": "3.2.1",
|
||||
"lodash": "4.17.21",
|
||||
"mocha": "9.2.2",
|
||||
"mock-raf": "1.0.1",
|
||||
|
Loading…
Reference in New Issue
Block a user