Skip to content

Commit 5aa5ca6

Browse files
committed
added test case for DllPlugin and chunks in dlls
webpack#1948
1 parent 131bc08 commit 5aa5ca6

8 files changed

Lines changed: 50 additions & 2 deletions

File tree

test/ConfigTestCases.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("ConfigTestCases", function() {
1515
name: cat,
1616
tests: fs.readdirSync(path.join(casesPath, cat)).filter(function(folder) {
1717
return folder.indexOf("_") < 0;
18-
})
18+
}).sort()
1919
};
2020
});
2121
categories.forEach(function(category) {
@@ -58,7 +58,7 @@ describe("ConfigTestCases", function() {
5858
}
5959

6060
function _require(module) {
61-
if(module.substr(0, 2) === "./") {
61+
if(/^\.\.?\//.test(module)) {
6262
var p = path.join(outputDirectory, module);
6363
var fn;
6464
if(options.target === "web") {
@@ -85,6 +85,8 @@ describe("ConfigTestCases", function() {
8585
// try to load a test file
8686
testConfig = require(path.join(testDirectory, "test.config.js"));
8787
} catch(e) {}
88+
89+
if(testConfig.noTests) return process.nextTick(done);
8890
for(var i = 0; i < optionsArr.length; i++) {
8991
var bundlePath = testConfig.findBundle(i, optionsArr[i]);
9092
if(bundlePath) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "a";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function() {
2+
return System.import("./c");
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default "c";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports.noTests = true;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var path = require("path");
2+
var webpack = require("../../../../");
3+
4+
module.exports = {
5+
entry: ["./a", "./b"],
6+
output: {
7+
filename: "dll.js",
8+
chunkFilename: "[id].dll.js",
9+
libraryTarget: "commonjs2"
10+
},
11+
plugins: [
12+
new webpack.DllPlugin({
13+
path: path.resolve(__dirname, "../../../js/config/dll-plugin/manifest0.json")
14+
})
15+
]
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var should = require("should");
2+
3+
it("should load a module from dll", function() {
4+
require("dll/a").should.be.eql("a");
5+
});
6+
7+
it("should load an async module from dll", function() {
8+
require("dll/b")().then(function(c) {
9+
c.should.be.eql({ default: "c" });
10+
});
11+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var path = require("path");
2+
var webpack = require("../../../../");
3+
4+
module.exports = {
5+
plugins: [
6+
new webpack.DllReferencePlugin({
7+
manifest: require("../../../js/config/dll-plugin/manifest0.json"),
8+
name: "../0-create-dll/dll.js",
9+
scope: "dll",
10+
sourceType: "commonjs2"
11+
})
12+
]
13+
}

0 commit comments

Comments
 (0)