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 |
|
37 | this.parent = undefined;
|
38 | }
|
39 |
|
40 | |
41 |
|
42 |
|
43 | get chunkName() {
|
44 | return this.groupOptions.name;
|
45 | }
|
46 |
|
47 | |
48 |
|
49 |
|
50 |
|
51 | set chunkName(value) {
|
52 | this.groupOptions.name = value;
|
53 | }
|
54 |
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 | updateHash(hash, context) {
|
61 | const { chunkGraph } = context;
|
62 | hash.update(JSON.stringify(this.groupOptions));
|
63 | const chunkGroup = chunkGraph.getBlockChunkGroup(this);
|
64 | hash.update(chunkGroup ? chunkGroup.id : "");
|
65 | super.updateHash(hash, context);
|
66 | }
|
67 |
|
68 | serialize(context) {
|
69 | const { write } = context;
|
70 | write(this.groupOptions);
|
71 | write(this.loc);
|
72 | write(this.request);
|
73 | super.serialize(context);
|
74 | }
|
75 |
|
76 | deserialize(context) {
|
77 | const { read } = context;
|
78 | this.groupOptions = read();
|
79 | this.loc = read();
|
80 | this.request = read();
|
81 | super.deserialize(context);
|
82 | }
|
83 | }
|
84 |
|
85 | makeSerializable(AsyncDependenciesBlock, "webpack/lib/AsyncDependenciesBlock");
|
86 |
|
87 | Object.defineProperty(AsyncDependenciesBlock.prototype, "module", {
|
88 | get() {
|
89 | throw new Error(
|
90 | "module property was removed from AsyncDependenciesBlock (it's not needed)"
|
91 | );
|
92 | },
|
93 | set() {
|
94 | throw new Error(
|
95 | "module property was removed from AsyncDependenciesBlock (it's not needed)"
|
96 | );
|
97 | }
|
98 | });
|
99 |
|
100 | module.exports = AsyncDependenciesBlock;
|