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

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 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 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 * @param {Range} range range
22 */
23 constructor(range) {
24 super();
25 this.range = range;
26 }
27
28 get type() {
29 return "create script url";
30 }
31
32 /**
33 * @param {ObjectSerializerContext} context context
34 */
35 serialize(context) {
36 const { write } = context;
37 write(this.range);
38 super.serialize(context);
39 }
40
41 /**
42 * @param {ObjectDeserializerContext} context context
43 */
44 deserialize(context) {
45 const { read } = context;
46 this.range = read();
47 super.deserialize(context);
48 }
49}
50
51CreateScriptUrlDependency.Template = class CreateScriptUrlDependencyTemplate extends (
52 NullDependency.Template
53) {
54 /**
55 * @param {Dependency} dependency the dependency for which the template should be applied
56 * @param {ReplaceSource} source the current replace source which can be modified
57 * @param {DependencyTemplateContext} templateContext the context object
58 * @returns {void}
59 */
60 apply(dependency, source, { runtimeRequirements }) {
61 const dep = /** @type {CreateScriptUrlDependency} */ (dependency);
62
63 runtimeRequirements.add(RuntimeGlobals.createScriptUrl);
64
65 source.insert(dep.range[0], `${RuntimeGlobals.createScriptUrl}(`);
66 source.insert(dep.range[1], ")");
67 }
68};
69
70makeSerializable(
71 CreateScriptUrlDependency,
72 "webpack/lib/dependencies/CreateScriptUrlDependency"
73);
74
75module.exports = CreateScriptUrlDependency;
Note: See TracBrowser for help on using the repository browser.