This repository was archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 512
/
Copy pathExtractedModule.js
70 lines (58 loc) · 1.55 KB
/
ExtractedModule.js
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
import { SourceMapSource, RawSource } from 'webpack-sources';
class ExtractedModule {
constructor(
identifier,
originalModule,
source,
sourceMap,
addtitionalInformation,
prevModules) {
this._identifier = identifier;
this._originalModule = originalModule;
this._source = source;
this._sourceMap = sourceMap;
this._prevModules = prevModules;
this.addtitionalInformation = addtitionalInformation;
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 SourceMapSource(this._source, null, this._sourceMap); }
return new 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;
}
}
export default ExtractedModule;