source: trip-planner-front/node_modules/webpack/lib/dependencies/RequireIncludeDependency.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: 2.2 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 Dependency = require("../Dependency");
9const Template = require("../Template");
10const makeSerializable = require("../util/makeSerializable");
11const ModuleDependency = require("./ModuleDependency");
12
13/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
14/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
15/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
16/** @typedef {import("../ModuleGraph")} ModuleGraph */
17/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
18
19class RequireIncludeDependency extends ModuleDependency {
20 constructor(request, range) {
21 super(request);
22
23 this.range = range;
24 }
25
26 /**
27 * Returns list of exports referenced by this dependency
28 * @param {ModuleGraph} moduleGraph module graph
29 * @param {RuntimeSpec} runtime the runtime for which the module is analysed
30 * @returns {(string[] | ReferencedExport)[]} referenced exports
31 */
32 getReferencedExports(moduleGraph, runtime) {
33 // This doesn't use any export
34 return Dependency.NO_EXPORTS_REFERENCED;
35 }
36
37 get type() {
38 return "require.include";
39 }
40
41 get category() {
42 return "commonjs";
43 }
44}
45
46makeSerializable(
47 RequireIncludeDependency,
48 "webpack/lib/dependencies/RequireIncludeDependency"
49);
50
51RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate extends (
52 ModuleDependency.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, { runtimeTemplate }) {
61 const dep = /** @type {RequireIncludeDependency} */ (dependency);
62 const comment = runtimeTemplate.outputOptions.pathinfo
63 ? Template.toComment(
64 `require.include ${runtimeTemplate.requestShortener.shorten(
65 dep.request
66 )}`
67 )
68 : "";
69
70 source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
71 }
72};
73
74module.exports = RequireIncludeDependency;
Note: See TracBrowser for help on using the repository browser.