RequireResolveDependency.js 1.4 KB

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