source: imaps-frontend/node_modules/webpack/lib/dependencies/UnsupportedDependency.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.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("../Dependency")} Dependency */
13/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
14/** @typedef {import("../javascript/JavascriptParser").Range} Range */
15/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
16/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
17
18class UnsupportedDependency extends NullDependency {
19 /**
20 * @param {string} request the request string
21 * @param {Range} range location in source code
22 */
23 constructor(request, range) {
24 super();
25
26 this.request = request;
27 this.range = range;
28 }
29
30 /**
31 * @param {ObjectSerializerContext} context context
32 */
33 serialize(context) {
34 const { write } = context;
35
36 write(this.request);
37 write(this.range);
38
39 super.serialize(context);
40 }
41
42 /**
43 * @param {ObjectDeserializerContext} context context
44 */
45 deserialize(context) {
46 const { read } = context;
47
48 this.request = read();
49 this.range = read();
50
51 super.deserialize(context);
52 }
53}
54
55makeSerializable(
56 UnsupportedDependency,
57 "webpack/lib/dependencies/UnsupportedDependency"
58);
59
60UnsupportedDependency.Template = class UnsupportedDependencyTemplate extends (
61 NullDependency.Template
62) {
63 /**
64 * @param {Dependency} dependency the dependency for which the template should be applied
65 * @param {ReplaceSource} source the current replace source which can be modified
66 * @param {DependencyTemplateContext} templateContext the context object
67 * @returns {void}
68 */
69 apply(dependency, source, { runtimeTemplate }) {
70 const dep = /** @type {UnsupportedDependency} */ (dependency);
71
72 source.replace(
73 dep.range[0],
74 dep.range[1],
75 runtimeTemplate.missingModule({
76 request: dep.request
77 })
78 );
79 }
80};
81
82module.exports = UnsupportedDependency;
Note: See TracBrowser for help on using the repository browser.