Skip to content

Commit 6ba220d

Browse files
authored
Merge pull request webpack#4992 from ssuman/master
Adding function support to noParse
2 parents ce74935 + 419961e commit 6ba220d

6 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎lib/NormalModule.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ class NormalModule extends Module {
224224
if(typeof rule === "string") {
225225
return content.indexOf(rule) === 0;
226226
}
227+
228+
if(typeof rule === "function") {
229+
return rule(content);
230+
}
227231
// we assume rule is a regexp
228232
return rule.test(content);
229233
}

‎schemas/webpackOptionsSchema.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@
159159
{
160160
"instanceof": "RegExp"
161161
},
162+
{
163+
"instanceof": "Function"
164+
},
162165
{
163166
"items": {
164167
"type": "string",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
it("should correctly export stuff from not parsed modules", function() {
2+
require("./not-parsed-a").should.be.eql("ok");
3+
require("./not-parsed-b").should.be.eql("ok");
4+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "ok";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Object.defineProperty(module, "exports", {
2+
get: function() {
3+
return "ok";
4+
}
5+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
module: {
3+
noParse: function(content) {
4+
return /not-parsed/.test(content);
5+
}
6+
}
7+
};

0 commit comments

Comments
 (0)