source: frontend/node_modules/webpack/lib/dependencies/UnsupportedDependency.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.4 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 * Creates an instance of UnsupportedDependency.
21 * @param {string} request the request string
22 * @param {Range} range location in source code
23 */
24 constructor(request, range) {
25 super();
26
27 this.request = request;
28 this.range = range;
29 }
30
31 /**
32 * Serializes this instance into the provided serializer context.
33 * @param {ObjectSerializerContext} context context
34 */
35 serialize(context) {
36 const { write } = context;
37
38 write(this.request);
39 write(this.range);
40
41 super.serialize(context);
42 }
43
44 /**
45 * Restores this instance from the provided deserializer context.
46 * @param {ObjectDeserializerContext} context context
47 */
48 deserialize(context) {
49 const { read } = context;
50
51 this.request = read();
52 this.range = read();
53
54 super.deserialize(context);
55 }
56}
57
58makeSerializable(
59 UnsupportedDependency,
60 "webpack/lib/dependencies/UnsupportedDependency"
61);
62
63UnsupportedDependency.Template = class UnsupportedDependencyTemplate extends (
64 NullDependency.Template
65) {
66 /**
67 * Applies the plugin by registering its hooks on the compiler.
68 * @param {Dependency} dependency the dependency for which the template should be applied
69 * @param {ReplaceSource} source the current replace source which can be modified
70 * @param {DependencyTemplateContext} templateContext the context object
71 * @returns {void}
72 */
73 apply(dependency, source, { runtimeTemplate }) {
74 const dep = /** @type {UnsupportedDependency} */ (dependency);
75
76 source.replace(
77 dep.range[0],
78 dep.range[1],
79 runtimeTemplate.missingModule({
80 request: dep.request
81 })
82 );
83 }
84};
85
86module.exports = UnsupportedDependency;
Note: See TracBrowser for help on using the repository browser.