source: trip-planner-front/node_modules/webpack/lib/dependencies/RequireHeaderDependency.js@ fa375fe

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

initial commit

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