1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | class ModuleReason {
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 | constructor(module, dependency, explanation) {
|
17 | this.module = module;
|
18 | this.dependency = dependency;
|
19 | this.explanation = explanation;
|
20 | this._chunks = null;
|
21 | }
|
22 |
|
23 | hasChunk(chunk) {
|
24 | if (this._chunks) {
|
25 | if (this._chunks.has(chunk)) return true;
|
26 | } else if (this.module && this.module._chunks.has(chunk)) return true;
|
27 | return false;
|
28 | }
|
29 |
|
30 | rewriteChunks(oldChunk, newChunks) {
|
31 | if (!this._chunks) {
|
32 | if (this.module) {
|
33 | if (!this.module._chunks.has(oldChunk)) return;
|
34 | this._chunks = new Set(this.module._chunks);
|
35 | } else {
|
36 | this._chunks = new Set();
|
37 | }
|
38 | }
|
39 | if (this._chunks.has(oldChunk)) {
|
40 | this._chunks.delete(oldChunk);
|
41 | for (let i = 0; i < newChunks.length; i++) {
|
42 | this._chunks.add(newChunks[i]);
|
43 | }
|
44 | }
|
45 | }
|
46 | }
|
47 |
|
48 | module.exports = ModuleReason;
|