mirror of https://github.com/webpack/webpack.git
Merge pull request #3942 from carloscuatin/refactor-eval-source-map-dev-tool-plugin
refactor(es6) upgrade EvalSourceMapDevToolPlugin to ES6 class
This commit is contained in:
commit
c4be4564af
|
|
@ -2,25 +2,31 @@
|
||||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||||
Author Tobias Koppers @sokra
|
Author Tobias Koppers @sokra
|
||||||
*/
|
*/
|
||||||
var EvalSourceMapDevToolModuleTemplatePlugin = require("./EvalSourceMapDevToolModuleTemplatePlugin");
|
"use strict";
|
||||||
var SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
|
||||||
|
|
||||||
function EvalSourceMapDevToolPlugin(options) {
|
const EvalSourceMapDevToolModuleTemplatePlugin = require("./EvalSourceMapDevToolModuleTemplatePlugin");
|
||||||
if(arguments.length > 1)
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
||||||
throw new Error("EvalSourceMapDevToolPlugin only takes one argument (pass an options object)");
|
|
||||||
if(typeof options === "string") {
|
class EvalSourceMapDevToolPlugin {
|
||||||
options = {
|
constructor(options) {
|
||||||
append: options
|
if(arguments.length > 1)
|
||||||
};
|
throw new Error("EvalSourceMapDevToolPlugin only takes one argument (pass an options object)");
|
||||||
|
if(typeof options === "string") {
|
||||||
|
options = {
|
||||||
|
append: options
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if(!options) options = {};
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(compiler) {
|
||||||
|
let options = this.options;
|
||||||
|
compiler.plugin("compilation", (compilation) => {
|
||||||
|
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
|
||||||
|
compilation.moduleTemplate.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if(!options) options = {};
|
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = EvalSourceMapDevToolPlugin;
|
module.exports = EvalSourceMapDevToolPlugin;
|
||||||
EvalSourceMapDevToolPlugin.prototype.apply = function(compiler) {
|
|
||||||
var options = this.options;
|
|
||||||
compiler.plugin("compilation", function(compilation) {
|
|
||||||
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
|
|
||||||
compilation.moduleTemplate.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue