source: imaps-frontend/node_modules/webpack/lib/dependencies/ModuleDependency.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[79a0317]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 RawModule = require("../RawModule");
11
12/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
13/** @typedef {import("../Module")} Module */
14/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
15/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
16/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
17
18class ModuleDependency extends Dependency {
19 /**
20 * @param {string} request request path which needs resolving
21 */
22 constructor(request) {
23 super();
24 this.request = request;
25 this.userRequest = request;
26 this.range = undefined;
27 // TODO move it to subclasses and rename
28 // assertions must be serialized by subclasses that use it
29 /** @type {ImportAttributes | undefined} */
30 this.assertions = undefined;
31 this._context = undefined;
32 }
33
34 /**
35 * @returns {string | undefined} a request context
36 */
37 getContext() {
38 return this._context;
39 }
40
41 /**
42 * @returns {string | null} an identifier to merge equal requests
43 */
44 getResourceIdentifier() {
45 let str = `context${this._context || ""}|module${this.request}`;
46 if (this.assertions !== undefined) {
47 str += JSON.stringify(this.assertions);
48 }
49 return str;
50 }
51
52 /**
53 * @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
54 */
55 couldAffectReferencingModule() {
56 return true;
57 }
58
59 /**
60 * @param {string} context context directory
61 * @returns {Module | null} a module
62 */
63 createIgnoredModule(context) {
64 return new RawModule(
65 "/* (ignored) */",
66 `ignored|${context}|${this.request}`,
67 `${this.request} (ignored)`
68 );
69 }
70
71 /**
72 * @param {ObjectSerializerContext} context context
73 */
74 serialize(context) {
75 const { write } = context;
76 write(this.request);
77 write(this.userRequest);
78 write(this._context);
79 write(this.range);
80 super.serialize(context);
81 }
82
83 /**
84 * @param {ObjectDeserializerContext} context context
85 */
86 deserialize(context) {
87 const { read } = context;
88 this.request = read();
89 this.userRequest = read();
90 this._context = read();
91 this.range = read();
92 super.deserialize(context);
93 }
94}
95
96ModuleDependency.Template = DependencyTemplate;
97
98module.exports = ModuleDependency;
Note: See TracBrowser for help on using the repository browser.