Skip to content

Commit a02d172

Browse files
committed
add tests for issue-2991
1 parent 8165522 commit a02d172

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
try {
2+
require("foo");
3+
} catch(e){}
4+
5+
it("should write relative paths to records", function() {
6+
var fs = require("fs");
7+
var path = require("path");
8+
var content = fs.readFileSync(path.join(__dirname, "records.json"), "utf-8");
9+
content.should.eql(`{
10+
"modules": {
11+
"byIdentifier": {
12+
"../../../../external \\"fs\\"": 0,
13+
"../../../../external \\"path\\"": 1,
14+
"../../../../ignored ../test/configCases/records/issue-2991 foo": 2,
15+
"test.js": 3
16+
},
17+
"usedIds": {
18+
"0": 0,
19+
"1": 1,
20+
"2": 2,
21+
"3": 3
22+
}
23+
},
24+
"chunks": {
25+
"byName": {
26+
"main": 0
27+
},
28+
"byBlocks": {},
29+
"usedIds": {
30+
"0": 0
31+
}
32+
}
33+
}`);
34+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var path = require("path");
2+
3+
module.exports = {
4+
entry: "./test",
5+
recordsPath: path.resolve(__dirname, "../../../js/config/records/issue-2991/records.json"),
6+
target: "node",
7+
node: {
8+
__dirname: false
9+
},
10+
plugins: [
11+
{
12+
apply(compiler) {
13+
compiler.plugin("normal-module-factory", (nmf) => {
14+
var oldResolve = nmf.resolvers.normal.resolve;
15+
nmf.resolvers.normal.resolve = function(_, __, resource, callback) {
16+
if(resource === "foo") {
17+
callback(null, false, false);
18+
return;
19+
}
20+
return oldResolve.apply(this, arguments);
21+
};
22+
});
23+
}
24+
}
25+
]
26+
};

0 commit comments

Comments
 (0)