source: trip-planner-front/node_modules/webpack/lib/dependencies/RuntimeRequirementsDependency.js@ 84d0fbb

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

initial commit

  • Property mode set to 100644
File size: 2.1 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 makeSerializable = require("../util/makeSerializable");
9const NullDependency = require("./NullDependency");
10
11/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12/** @typedef {import("../ChunkGraph")} ChunkGraph */
13/** @typedef {import("../Dependency")} Dependency */
14/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
15/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
16/** @typedef {import("../ModuleGraph")} ModuleGraph */
17/** @typedef {import("../util/Hash")} Hash */
18
19class RuntimeRequirementsDependency extends NullDependency {
20 /**
21 * @param {string[]} runtimeRequirements runtime requirements
22 */
23 constructor(runtimeRequirements) {
24 super();
25 this.runtimeRequirements = new Set(runtimeRequirements);
26 }
27
28 /**
29 * Update the hash
30 * @param {Hash} hash hash to be updated
31 * @param {UpdateHashContext} context context
32 * @returns {void}
33 */
34 updateHash(hash, context) {
35 hash.update(Array.from(this.runtimeRequirements).join() + "");
36 }
37
38 serialize(context) {
39 const { write } = context;
40 write(this.runtimeRequirements);
41 super.serialize(context);
42 }
43
44 deserialize(context) {
45 const { read } = context;
46 this.runtimeRequirements = read();
47 super.deserialize(context);
48 }
49}
50
51makeSerializable(
52 RuntimeRequirementsDependency,
53 "webpack/lib/dependencies/RuntimeRequirementsDependency"
54);
55
56RuntimeRequirementsDependency.Template = class RuntimeRequirementsDependencyTemplate extends (
57 NullDependency.Template
58) {
59 /**
60 * @param {Dependency} dependency the dependency for which the template should be applied
61 * @param {ReplaceSource} source the current replace source which can be modified
62 * @param {DependencyTemplateContext} templateContext the context object
63 * @returns {void}
64 */
65 apply(dependency, source, { runtimeRequirements }) {
66 const dep = /** @type {RuntimeRequirementsDependency} */ (dependency);
67 for (const req of dep.runtimeRequirements) {
68 runtimeRequirements.add(req);
69 }
70 }
71};
72
73module.exports = RuntimeRequirementsDependency;
Note: See TracBrowser for help on using the repository browser.