|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
5 | | -var ReplaceSource = require("webpack-sources").ReplaceSource; |
6 | | -var RawSource = require("webpack-sources").RawSource; |
| 5 | +"use strict"; |
7 | 6 |
|
8 | | -function DependenciesBlockVariable(name, expression, dependencies) { |
9 | | - this.name = name; |
10 | | - this.expression = expression; |
11 | | - this.dependencies = dependencies || []; |
12 | | -} |
13 | | -module.exports = DependenciesBlockVariable; |
| 7 | +const ReplaceSource = require("webpack-sources").ReplaceSource; |
| 8 | +const RawSource = require("webpack-sources").RawSource; |
| 9 | + |
| 10 | +class DependenciesBlockVariable { |
| 11 | + constructor(name, expression, dependencies) { |
| 12 | + this.name = name; |
| 13 | + this.expression = expression; |
| 14 | + this.dependencies = dependencies || []; |
| 15 | + } |
14 | 16 |
|
15 | | -DependenciesBlockVariable.prototype.updateHash = function(hash) { |
16 | | - hash.update(this.name); |
17 | | - hash.update(this.expression); |
18 | | - this.dependencies.forEach(function(d) { |
19 | | - d.updateHash(hash); |
20 | | - }); |
21 | | -}; |
| 17 | + updateHash(hash) { |
| 18 | + hash.update(this.name); |
| 19 | + hash.update(this.expression); |
| 20 | + this.dependencies.forEach(d => { |
| 21 | + d.updateHash(hash); |
| 22 | + }); |
| 23 | + } |
22 | 24 |
|
23 | | -DependenciesBlockVariable.prototype.expressionSource = function(dependencyTemplates, outputOptions, requestShortener) { |
24 | | - var source = new ReplaceSource(new RawSource(this.expression)); |
25 | | - this.dependencies.forEach(function(dep) { |
26 | | - var template = dependencyTemplates.get(dep.constructor); |
27 | | - if(!template) throw new Error("No template for dependency: " + dep.constructor.name); |
28 | | - template.apply(dep, source, outputOptions, requestShortener, dependencyTemplates); |
29 | | - }); |
30 | | - return source; |
31 | | -}; |
| 25 | + expressionSource(dependencyTemplates, outputOptions, requestShortener) { |
| 26 | + const source = new ReplaceSource(new RawSource(this.expression)); |
| 27 | + this.dependencies.forEach(dep => { |
| 28 | + const template = dependencyTemplates.get(dep.constructor); |
| 29 | + if(!template) throw new Error(`No template for dependency: ${dep.constructor.name}`); |
| 30 | + template.apply(dep, source, outputOptions, requestShortener, dependencyTemplates); |
| 31 | + }); |
| 32 | + return source; |
| 33 | + } |
32 | 34 |
|
33 | | -DependenciesBlockVariable.prototype.disconnect = function() { |
34 | | - this.dependencies.forEach(function(d) { |
35 | | - d.disconnect(); |
36 | | - }); |
37 | | -}; |
| 35 | + disconnect() { |
| 36 | + this.dependencies.forEach(d => { |
| 37 | + d.disconnect(); |
| 38 | + }); |
| 39 | + } |
38 | 40 |
|
39 | | -DependenciesBlockVariable.prototype.hasDependencies = function() { |
40 | | - return this.dependencies.length > 0; |
41 | | -}; |
| 41 | + hasDependencies() { |
| 42 | + return this.dependencies.length > 0; |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +module.exports = DependenciesBlockVariable; |
0 commit comments