1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 | const DependenciesBlock = require("./DependenciesBlock");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | constructor(groupOptions, module, loc, request) {
|
23 | super();
|
24 | if (typeof groupOptions === "string") {
|
25 | groupOptions = { name: groupOptions };
|
26 | } else if (!groupOptions) {
|
27 | groupOptions = { name: undefined };
|
28 | }
|
29 | this.groupOptions = groupOptions;
|
30 |
|
31 | this.chunkGroup = undefined;
|
32 | this.module = module;
|
33 | this.loc = loc;
|
34 | this.request = request;
|
35 |
|
36 | this.parent = undefined;
|
37 | }
|
38 |
|
39 | |
40 |
|
41 |
|
42 | get chunkName() {
|
43 | return this.groupOptions.name;
|
44 | }
|
45 |
|
46 | |
47 |
|
48 |
|
49 |
|
50 | set chunkName(value) {
|
51 | this.groupOptions.name = value;
|
52 | }
|
53 |
|
54 | |
55 |
|
56 |
|
57 | get chunks() {
|
58 | throw new Error("Moved to AsyncDependenciesBlock.chunkGroup");
|
59 | }
|
60 |
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 | set chunks(value) {
|
67 | throw new Error("Moved to AsyncDependenciesBlock.chunkGroup");
|
68 | }
|
69 |
|
70 | |
71 |
|
72 |
|
73 |
|
74 | updateHash(hash) {
|
75 | hash.update(JSON.stringify(this.groupOptions));
|
76 | hash.update(
|
77 | (this.chunkGroup &&
|
78 | this.chunkGroup.chunks
|
79 | .map(chunk => {
|
80 | return chunk.id !== null ? chunk.id : "";
|
81 | })
|
82 | .join(",")) ||
|
83 | ""
|
84 | );
|
85 | super.updateHash(hash);
|
86 | }
|
87 |
|
88 | |
89 |
|
90 |
|
91 | disconnect() {
|
92 | this.chunkGroup = undefined;
|
93 | super.disconnect();
|
94 | }
|
95 |
|
96 | |
97 |
|
98 |
|
99 | unseal() {
|
100 | this.chunkGroup = undefined;
|
101 | super.unseal();
|
102 | }
|
103 |
|
104 | |
105 |
|
106 |
|
107 | sortItems() {
|
108 | super.sortItems();
|
109 | }
|
110 | };
|