source: trip-planner-front/node_modules/webpack/lib/dependencies/ModuleDependency.js

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

initial commit

  • Property mode set to 100644
File size: 1.6 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 Dependency = require("../Dependency");
9const DependencyTemplate = require("../DependencyTemplate");
10const memoize = require("../util/memoize");
11
12/** @typedef {import("../Module")} Module */
13
14const getRawModule = memoize(() => require("../RawModule"));
15
16class ModuleDependency extends Dependency {
17 /**
18 * @param {string} request request path which needs resolving
19 */
20 constructor(request) {
21 super();
22 this.request = request;
23 this.userRequest = request;
24 this.range = undefined;
25 // assertions must be serialized by subclasses that use it
26 /** @type {Record<string, any> | undefined} */
27 this.assertions = undefined;
28 }
29
30 /**
31 * @returns {string | null} an identifier to merge equal requests
32 */
33 getResourceIdentifier() {
34 let str = `module${this.request}`;
35 if (this.assertions !== undefined) {
36 str += JSON.stringify(this.assertions);
37 }
38 return str;
39 }
40
41 /**
42 * @param {string} context context directory
43 * @returns {Module} a module
44 */
45 createIgnoredModule(context) {
46 const RawModule = getRawModule();
47 return new RawModule(
48 "/* (ignored) */",
49 `ignored|${context}|${this.request}`,
50 `${this.request} (ignored)`
51 );
52 }
53
54 serialize(context) {
55 const { write } = context;
56 write(this.request);
57 write(this.userRequest);
58 write(this.range);
59 super.serialize(context);
60 }
61
62 deserialize(context) {
63 const { read } = context;
64 this.request = read();
65 this.userRequest = read();
66 this.range = read();
67 super.deserialize(context);
68 }
69}
70
71ModuleDependency.Template = DependencyTemplate;
72
73module.exports = ModuleDependency;
Note: See TracBrowser for help on using the repository browser.