source: trip-planner-front/node_modules/webpack/lib/AsyncDependenciesBlock.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const DependenciesBlock = require("./DependenciesBlock");
9const makeSerializable = require("./util/makeSerializable");
10
11/** @typedef {import("./ChunkGraph")} ChunkGraph */
12/** @typedef {import("./ChunkGroup")} ChunkGroup */
13/** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
14/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
15/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
16/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
17/** @typedef {import("./Module")} Module */
18/** @typedef {import("./util/Hash")} Hash */
19
20class AsyncDependenciesBlock extends DependenciesBlock {
21 /**
22 * @param {ChunkGroupOptions & { entryOptions?: EntryOptions }} groupOptions options for the group
23 * @param {DependencyLocation=} loc the line of code
24 * @param {string=} request the request
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 /** @type {DependenciesBlock} */
37 this.parent = undefined;
38 }
39
40 /**
41 * @returns {string} The name of the chunk
42 */
43 get chunkName() {
44 return this.groupOptions.name;
45 }
46
47 /**
48 * @param {string} value The new chunk name
49 * @returns {void}
50 */
51 set chunkName(value) {
52 this.groupOptions.name = value;
53 }
54
55 /**
56 * @param {Hash} hash the hash used to track dependencies
57 * @param {UpdateHashContext} context context
58 * @returns {void}
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
85makeSerializable(AsyncDependenciesBlock, "webpack/lib/AsyncDependenciesBlock");
86
87Object.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
100module.exports = AsyncDependenciesBlock;
Note: See TracBrowser for help on using the repository browser.