source: frontend/node_modules/webpack/lib/dependencies/CreateScriptUrlDependency.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 RuntimeGlobals = require("../RuntimeGlobals");
9const makeSerializable = require("../util/makeSerializable");
10const NullDependency = require("./NullDependency");
11
12/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
13/** @typedef {import("../Dependency")} Dependency */
14/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
15/** @typedef {import("../javascript/JavascriptParser").Range} Range */
16/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
17/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
18
19class CreateScriptUrlDependency extends NullDependency {
20 /**
21 * Creates an instance of CreateScriptUrlDependency.
22 * @param {Range} range range
23 */
24 constructor(range) {
25 super();
26 this.range = range;
27 }
28
29 get type() {
30 return "create script url";
31 }
32
33 /**
34 * Serializes this instance into the provided serializer context.
35 * @param {ObjectSerializerContext} context context
36 */
37 serialize(context) {
38 const { write } = context;
39 write(this.range);
40 super.serialize(context);
41 }
42
43 /**
44 * Restores this instance from the provided deserializer context.
45 * @param {ObjectDeserializerContext} context context
46 */
47 deserialize(context) {
48 const { read } = context;
49 this.range = read();
50 super.deserialize(context);
51 }
52}
53
54CreateScriptUrlDependency.Template = class CreateScriptUrlDependencyTemplate extends (
55 NullDependency.Template
56) {
57 /**
58 * Applies the plugin by registering its hooks on the compiler.
59 * @param {Dependency} dependency the dependency for which the template should be applied
60 * @param {ReplaceSource} source the current replace source which can be modified
61 * @param {DependencyTemplateContext} templateContext the context object
62 * @returns {void}
63 */
64 apply(dependency, source, { runtimeRequirements }) {
65 const dep = /** @type {CreateScriptUrlDependency} */ (dependency);
66
67 runtimeRequirements.add(RuntimeGlobals.createScriptUrl);
68
69 source.insert(dep.range[0], `${RuntimeGlobals.createScriptUrl}(`);
70 source.insert(dep.range[1], ")");
71 }
72};
73
74makeSerializable(
75 CreateScriptUrlDependency,
76 "webpack/lib/dependencies/CreateScriptUrlDependency"
77);
78
79module.exports = CreateScriptUrlDependency;
Note: See TracBrowser for help on using the repository browser.