This commit is contained in:
Tobias Koppers 2018-12-22 13:39:26 +01:00
parent 7a6a71f1e9
commit bc368c7611
6 changed files with 41 additions and 0 deletions

View File

@ -38,6 +38,8 @@ class IgnorePlugin {
* @returns {TODO|null} returns result or null if result should be ignored
*/
checkIgnore(result) {
if (!result) return result;
if (
"checkResource" in this.options &&
this.options.checkResource &&

View File

@ -0,0 +1 @@
module.exports = "ignored";

View File

@ -0,0 +1 @@
module.exports = "ignored";

View File

@ -0,0 +1 @@
module.exports = "normal";

View File

@ -0,0 +1,18 @@
/* globals it */
"use strict";
it("should ignore ignored resources 1", function() {
expect(function() {
require("./ignored-module1");
}).toThrowError();
});
it("should ignore ignored resources 2", function() {
expect(function() {
require("./ignored-module2");
}).toThrowError();
});
it("should not ignore resources that do not match", function() {
expect(function() {
require("./normal-module");
}).not.toThrowError();
});

View File

@ -0,0 +1,18 @@
"use strict";
const IgnorePlugin = require("../../../../lib/IgnorePlugin");
module.exports = {
entry: "./test.js",
externals: {
"./normal-module": "{}"
},
plugins: [
new IgnorePlugin({
resourceRegExp: /ignored-module1/
}),
new IgnorePlugin({
resourceRegExp: /ignored-module2/
})
]
};