source: trip-planner-front/node_modules/webpack/lib/dependencies/RequireResolveHeaderDependency.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 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
15class RequireResolveHeaderDependency extends NullDependency {
16 constructor(range) {
17 super();
18
19 if (!Array.isArray(range)) throw new Error("range must be valid");
20
21 this.range = range;
22 }
23
24 serialize(context) {
25 const { write } = context;
26
27 write(this.range);
28
29 super.serialize(context);
30 }
31
32 static deserialize(context) {
33 const obj = new RequireResolveHeaderDependency(context.read());
34 obj.deserialize(context);
35 return obj;
36 }
37}
38
39makeSerializable(
40 RequireResolveHeaderDependency,
41 "webpack/lib/dependencies/RequireResolveHeaderDependency"
42);
43
44RequireResolveHeaderDependency.Template = class RequireResolveHeaderDependencyTemplate extends (
45 NullDependency.Template
46) {
47 /**
48 * @param {Dependency} dependency the dependency for which the template should be applied
49 * @param {ReplaceSource} source the current replace source which can be modified
50 * @param {DependencyTemplateContext} templateContext the context object
51 * @returns {void}
52 */
53 apply(dependency, source, templateContext) {
54 const dep = /** @type {RequireResolveHeaderDependency} */ (dependency);
55 source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
56 }
57
58 applyAsTemplateArgument(name, dep, source) {
59 source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
60 }
61};
62
63module.exports = RequireResolveHeaderDependency;
Note: See TracBrowser for help on using the repository browser.