1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const DependenciesBlock = require("./DependenciesBlock");
|
9 | const makeSerializable = require("./util/makeSerializable");
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | class AsyncDependenciesBlock extends DependenciesBlock {
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 | constructor(groupOptions, loc, request) {
|
27 | super();
|
28 | if (typeof groupOptions === "string") {
|
29 | groupOptions = { name: groupOptions };
|
30 | } else if (!groupOptions) {
|
31 | groupOptions = { name: undefined };
|
32 | }
|
33 | this.groupOptions = groupOptions;
|
34 | this.loc = loc;
|
35 | this.request = request;
|
36 | this._stringifiedGroupOptions = 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 | if (this.groupOptions.name !== value) {
|
52 | this.groupOptions.name = value;
|
53 | this._stringifiedGroupOptions = undefined;
|
54 | }
|
55 | }
|
56 |
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 | updateHash(hash, context) {
|
63 | const { chunkGraph } = context;
|
64 | if (this._stringifiedGroupOptions === undefined) {
|
65 | this._stringifiedGroupOptions = JSON.stringify(this.groupOptions);
|
66 | }
|
67 | const chunkGroup = chunkGraph.getBlockChunkGroup(this);
|
68 | hash.update(
|
69 | `${this._stringifiedGroupOptions}${chunkGroup ? chunkGroup.id : ""}`
|
70 | );
|
71 | super.updateHash(hash, context);
|
72 | }
|
73 |
|
74 | serialize(context) {
|
75 | const { write } = context;
|
76 | write(this.groupOptions);
|
77 | write(this.loc);
|
78 | write(this.request);
|
79 | super.serialize(context);
|
80 | }
|
81 |
|
82 | deserialize(context) {
|
83 | const { read } = context;
|
84 | this.groupOptions = read();
|
85 | this.loc = read();
|
86 | this.request = read();
|
87 | super.deserialize(context);
|
88 | }
|
89 | }
|
90 |
|
91 | makeSerializable(AsyncDependenciesBlock, "webpack/lib/AsyncDependenciesBlock");
|
92 |
|
93 | Object.defineProperty(AsyncDependenciesBlock.prototype, "module", {
|
94 | get() {
|
95 | throw new Error(
|
96 | "module property was removed from AsyncDependenciesBlock (it's not needed)"
|
97 | );
|
98 | },
|
99 | set() {
|
100 | throw new Error(
|
101 | "module property was removed from AsyncDependenciesBlock (it's not needed)"
|
102 | );
|
103 | }
|
104 | });
|
105 |
|
106 | module.exports = AsyncDependenciesBlock;
|