|
1 |
| -/* eslint-disable */ |
2 |
| -var SourceMapSource = require("webpack-sources").SourceMapSource; |
3 |
| -var RawSource = require("webpack-sources").RawSource; |
| 1 | +import { SourceMapSource, RawSource } from 'webpack-sources'; |
4 | 2 |
|
5 |
| -function ExtractedModule(identifier, originalModule, source, sourceMap, addtitionalInformation, prevModules) { |
6 |
| - this._identifier = identifier; |
7 |
| - this._originalModule = originalModule; |
8 |
| - this._source = source; |
9 |
| - this._sourceMap = sourceMap; |
10 |
| - this._prevModules = prevModules; |
11 |
| - this.addtitionalInformation = addtitionalInformation; |
12 |
| - this.chunks = []; |
13 |
| -} |
14 |
| -module.exports = ExtractedModule; |
| 3 | +class ExtractedModule { |
| 4 | + constructor( |
| 5 | + identifier, |
| 6 | + originalModule, |
| 7 | + source, |
| 8 | + sourceMap, |
| 9 | + addtitionalInformation, |
| 10 | + prevModules) { |
| 11 | + this._identifier = identifier; |
| 12 | + this._originalModule = originalModule; |
| 13 | + this._source = source; |
| 14 | + this._sourceMap = sourceMap; |
| 15 | + this._prevModules = prevModules; |
| 16 | + this.addtitionalInformation = addtitionalInformation; |
| 17 | + this.chunks = []; |
| 18 | + } |
| 19 | + |
| 20 | + getOrder() { |
| 21 | + // http://stackoverflow.com/a/14676665/1458162 |
| 22 | + return /^@import url/.test(this._source) ? 0 : 1; |
| 23 | + } |
15 | 24 |
|
16 |
| -ExtractedModule.prototype.getOrder = function() { |
17 |
| - // http://stackoverflow.com/a/14676665/1458162 |
18 |
| - return /^@import url/.test(this._source) ? 0 : 1; |
19 |
| -}; |
| 25 | + addChunk(chunk) { |
| 26 | + const idx = this.chunks.indexOf(chunk); |
| 27 | + if (idx < 0) { this.chunks.push(chunk); } |
| 28 | + } |
20 | 29 |
|
21 |
| -ExtractedModule.prototype.addChunk = function(chunk) { |
22 |
| - var idx = this.chunks.indexOf(chunk); |
23 |
| - if(idx < 0) |
24 |
| - this.chunks.push(chunk); |
25 |
| -}; |
| 30 | + removeChunk(chunk) { |
| 31 | + const idx = this.chunks.indexOf(chunk); |
| 32 | + if (idx >= 0) { |
| 33 | + this.chunks.splice(idx, 1); |
| 34 | + chunk.removeModule(this); |
| 35 | + return true; |
| 36 | + } |
| 37 | + return false; |
| 38 | + } |
26 | 39 |
|
27 |
| -ExtractedModule.prototype.removeChunk = function(chunk) { |
28 |
| - var idx = this.chunks.indexOf(chunk); |
29 |
| - if(idx >= 0) { |
30 |
| - this.chunks.splice(idx, 1); |
31 |
| - chunk.removeModule(this); |
32 |
| - return true; |
33 |
| - } |
34 |
| - return false; |
35 |
| -}; |
| 40 | + rewriteChunkInReasons(oldChunk, newChunks) { } // eslint-disable-line |
36 | 41 |
|
37 |
| -ExtractedModule.prototype.rewriteChunkInReasons = function(oldChunk, newChunks) { }; |
| 42 | + identifier() { |
| 43 | + return this._identifier; |
| 44 | + } |
38 | 45 |
|
39 |
| -ExtractedModule.prototype.identifier = function() { |
40 |
| - return this._identifier; |
41 |
| -}; |
| 46 | + source() { |
| 47 | + if (this._sourceMap) { return new SourceMapSource(this._source, null, this._sourceMap); } |
| 48 | + return new RawSource(this._source); |
| 49 | + } |
42 | 50 |
|
43 |
| -ExtractedModule.prototype.source = function() { |
44 |
| - if(this._sourceMap) |
45 |
| - return new SourceMapSource(this._source, null, this._sourceMap); |
46 |
| - else |
47 |
| - return new RawSource(this._source); |
48 |
| -}; |
| 51 | + getOriginalModule() { |
| 52 | + return this._originalModule; |
| 53 | + } |
49 | 54 |
|
50 |
| -ExtractedModule.prototype.getOriginalModule = function() { |
51 |
| - return this._originalModule; |
52 |
| -}; |
| 55 | + getPrevModules() { |
| 56 | + return this._prevModules; |
| 57 | + } |
53 | 58 |
|
54 |
| -ExtractedModule.prototype.getPrevModules = function() { |
55 |
| - return this._prevModules; |
56 |
| -}; |
| 59 | + addPrevModules(prevModules) { |
| 60 | + prevModules.forEach((m) => { |
| 61 | + if (this._prevModules.indexOf(m) < 0) { this._prevModules.push(m); } |
| 62 | + }, this); |
| 63 | + } |
57 | 64 |
|
58 |
| -ExtractedModule.prototype.addPrevModules = function(prevModules) { |
59 |
| - prevModules.forEach(function(m) { |
60 |
| - if(this._prevModules.indexOf(m) < 0) |
61 |
| - this._prevModules.push(m); |
62 |
| - }, this); |
63 |
| -}; |
| 65 | + setOriginalModule(originalModule) { |
| 66 | + this._originalModule = originalModule; |
| 67 | + } |
| 68 | +} |
64 | 69 |
|
65 |
| -ExtractedModule.prototype.setOriginalModule = function(originalModule) { |
66 |
| - this._originalModule = originalModule; |
67 |
| -}; |
| 70 | +export default ExtractedModule; |
0 commit comments