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