1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | const Dependency = require("../Dependency");
|
---|
9 | const makeSerializable = require("../util/makeSerializable");
|
---|
10 | const ModuleDependency = require("./ModuleDependency");
|
---|
11 | const ModuleDependencyAsId = require("./ModuleDependencyTemplateAsId");
|
---|
12 |
|
---|
13 | /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
---|
14 | /** @typedef {import("../ModuleGraph")} ModuleGraph */
|
---|
15 | /** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
---|
16 | /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
---|
17 |
|
---|
18 | class RequireResolveDependency extends ModuleDependency {
|
---|
19 | /**
|
---|
20 | * @param {string} request the request string
|
---|
21 | * @param {Range} range location in source code
|
---|
22 | * @param {string} [context] context
|
---|
23 | */
|
---|
24 | constructor(request, range, context) {
|
---|
25 | super(request);
|
---|
26 |
|
---|
27 | this.range = range;
|
---|
28 | this._context = context;
|
---|
29 | }
|
---|
30 |
|
---|
31 | get type() {
|
---|
32 | return "require.resolve";
|
---|
33 | }
|
---|
34 |
|
---|
35 | get category() {
|
---|
36 | return "commonjs";
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Returns list of exports referenced by this dependency
|
---|
41 | * @param {ModuleGraph} moduleGraph module graph
|
---|
42 | * @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
---|
43 | * @returns {(string[] | ReferencedExport)[]} referenced exports
|
---|
44 | */
|
---|
45 | getReferencedExports(moduleGraph, runtime) {
|
---|
46 | // This doesn't use any export
|
---|
47 | return Dependency.NO_EXPORTS_REFERENCED;
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | makeSerializable(
|
---|
52 | RequireResolveDependency,
|
---|
53 | "webpack/lib/dependencies/RequireResolveDependency"
|
---|
54 | );
|
---|
55 |
|
---|
56 | RequireResolveDependency.Template = ModuleDependencyAsId;
|
---|
57 |
|
---|
58 | module.exports = RequireResolveDependency;
|
---|