Supplying extensions when constructing DllReferencePlugin

This commit is contained in:
Moorthy Venkatraman 2016-09-07 08:57:53 -04:00 committed by Tobias Koppers
parent c948c81f3e
commit be39508aa2
8 changed files with 19 additions and 4 deletions

View File

@ -3,5 +3,6 @@ console.log(require("../dll/a"));
console.log(require("beta/beta")); console.log(require("beta/beta"));
console.log(require("beta/b")); console.log(require("beta/b"));
console.log(require("beta/c"));
console.log(require("module")); console.log(require("module"));

1
examples/dll/c.jsx Normal file
View File

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

View File

@ -1,9 +1,12 @@
var path = require("path"); var path = require("path");
var webpack = require("../../"); var webpack = require("../../");
module.exports = { module.exports = {
resolve: {
extensions: ['.js', '.jsx']
},
entry: { entry: {
alpha: ["./alpha", "./a", "module"], alpha: ["./alpha", "./a", "module"],
beta: ["./beta", "./b"] beta: ["./beta", "./b", "./c"]
}, },
output: { output: {
path: path.join(__dirname, "js"), path: path.join(__dirname, "js"),

View File

@ -45,7 +45,8 @@ DllReferencePlugin.prototype.apply = function(compiler) {
type: this.options.type, type: this.options.type,
scope: this.options.scope, scope: this.options.scope,
context: this.options.context || compiler.options.context, context: this.options.context || compiler.options.context,
content: this.options.content || manifest.content content: this.options.content || manifest.content,
extensions: this.options.extensions
})); }));
}.bind(this)); }.bind(this));
}; };

View File

@ -0,0 +1 @@
module.exports = 'f';

View File

@ -2,7 +2,10 @@ var path = require("path");
var webpack = require("../../../../"); var webpack = require("../../../../");
module.exports = { module.exports = {
entry: ["./a", "./b", "./_d", "./_e"], entry: ["./a", "./b", "./_d", "./_e", "./f"],
resolve: {
extensions: ['', '.js', '.jsx']
},
output: { output: {
filename: "dll.js", filename: "dll.js",
chunkFilename: "[id].dll.js", chunkFilename: "[id].dll.js",

View File

@ -7,6 +7,10 @@ it("should load a module from dll", function() {
require("dll/a").should.be.eql("a"); require("dll/a").should.be.eql("a");
}); });
it("should load a module of non-default type without extension from dll", function() {
require("dll/f").should.be.eql("f");
});
it("should load an async module from dll", function() { it("should load an async module from dll", function() {
require("dll/b")().then(function(c) { require("dll/b")().then(function(c) {
c.should.be.eql({ default: "c" }); c.should.be.eql({ default: "c" });

View File

@ -7,7 +7,8 @@ module.exports = {
manifest: require("../../../js/config/dll-plugin/manifest0.json"), manifest: require("../../../js/config/dll-plugin/manifest0.json"),
name: "../0-create-dll/dll.js", name: "../0-create-dll/dll.js",
scope: "dll", scope: "dll",
sourceType: "commonjs2" sourceType: "commonjs2",
extensions: ['.js', '.jsx']
}) })
] ]
} }