source: imaps-frontend/node_modules/webpack/lib/dependencies/RequireIncludeDependency.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.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 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("../javascript/JavascriptParser").Range} Range */
18/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
19
20class RequireIncludeDependency extends ModuleDependency {
21 /**
22 * @param {string} request the request string
23 * @param {Range} range location in source code
24 */
25 constructor(request, range) {
26 super(request);
27
28 this.range = range;
29 }
30
31 /**
32 * Returns list of exports referenced by this dependency
33 * @param {ModuleGraph} moduleGraph module graph
34 * @param {RuntimeSpec} runtime the runtime for which the module is analysed
35 * @returns {(string[] | ReferencedExport)[]} referenced exports
36 */
37 getReferencedExports(moduleGraph, runtime) {
38 // This doesn't use any export
39 return Dependency.NO_EXPORTS_REFERENCED;
40 }
41
42 get type() {
43 return "require.include";
44 }
45
46 get category() {
47 return "commonjs";
48 }
49}
50
51makeSerializable(
52 RequireIncludeDependency,
53 "webpack/lib/dependencies/RequireIncludeDependency"
54);
55
56RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate extends (
57 ModuleDependency.Template
58) {
59 /**
60 * @param {Dependency} dependency the dependency for which the template should be applied
61 * @param {ReplaceSource} source the current replace source which can be modified
62 * @param {DependencyTemplateContext} templateContext the context object
63 * @returns {void}
64 */
65 apply(dependency, source, { runtimeTemplate }) {
66 const dep = /** @type {RequireIncludeDependency} */ (dependency);
67 const comment = runtimeTemplate.outputOptions.pathinfo
68 ? Template.toComment(
69 `require.include ${runtimeTemplate.requestShortener.shorten(
70 dep.request
71 )}`
72 )
73 : "";
74
75 source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
76 }
77};
78
79module.exports = RequireIncludeDependency;
Note: See TracBrowser for help on using the repository browser.