mirror of https://github.com/webpack/webpack.git
update DllEntryPlugin to es2015
This commit is contained in:
parent
af1b2fc8e2
commit
021d0cc53b
|
|
@ -2,31 +2,37 @@
|
|||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
var DllEntryDependency = require("./dependencies/DllEntryDependency");
|
||||
var SingleEntryDependency = require("./dependencies/SingleEntryDependency");
|
||||
var DllModuleFactory = require("./DllModuleFactory");
|
||||
"use strict";
|
||||
|
||||
function DllEntryPlugin(context, entries, name, type) {
|
||||
this.context = context;
|
||||
this.entries = entries;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
const DllEntryDependency = require("./dependencies/DllEntryDependency");
|
||||
const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
|
||||
const DllModuleFactory = require("./DllModuleFactory");
|
||||
|
||||
class DllEntryPlugin {
|
||||
constructor(context, entries, name, type) {
|
||||
this.context = context;
|
||||
this.entries = entries;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.plugin("compilation", (compilation, params) => {
|
||||
let dllModuleFactory = new DllModuleFactory();
|
||||
let normalModuleFactory = params.normalModuleFactory;
|
||||
|
||||
compilation.dependencyFactories.set(DllEntryDependency, dllModuleFactory);
|
||||
|
||||
compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
|
||||
});
|
||||
compiler.plugin("make", (compilation, callback) => {
|
||||
compilation.addEntry(this.context, new DllEntryDependency(this.entries.map((e, idx) => {
|
||||
let dep = new SingleEntryDependency(e);
|
||||
dep.loc = `${this.name}:${idx}`;
|
||||
return dep;
|
||||
}), this.name, this.type), this.name, callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DllEntryPlugin;
|
||||
DllEntryPlugin.prototype.apply = function(compiler) {
|
||||
compiler.plugin("compilation", function(compilation, params) {
|
||||
var dllModuleFactory = new DllModuleFactory();
|
||||
var normalModuleFactory = params.normalModuleFactory;
|
||||
|
||||
compilation.dependencyFactories.set(DllEntryDependency, dllModuleFactory);
|
||||
|
||||
compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
|
||||
});
|
||||
compiler.plugin("make", function(compilation, callback) {
|
||||
compilation.addEntry(this.context, new DllEntryDependency(this.entries.map(function(e, idx) {
|
||||
var dep = new SingleEntryDependency(e);
|
||||
dep.loc = this.name + ":" + idx;
|
||||
return dep;
|
||||
}, this), this.name, this.type), this.name, callback);
|
||||
}.bind(this));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue