您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Dependency.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const util = require("util");
  7. const compareLocations = require("./compareLocations");
  8. const DependencyReference = require("./dependencies/DependencyReference");
  9. /** @typedef {import("./Module")} Module */
  10. /** @typedef {import("webpack-sources").Source} Source */
  11. /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
  12. /**
  13. * @typedef {Object} DependencyTemplate
  14. * @property {function(Dependency, Source, RuntimeTemplate, Map<Function, DependencyTemplate>): void} apply
  15. */
  16. /** @typedef {Object} SourcePosition
  17. * @property {number} line
  18. * @property {number=} column
  19. */
  20. /** @typedef {Object} RealDependencyLocation
  21. * @property {SourcePosition} start
  22. * @property {SourcePosition=} end
  23. * @property {number=} index
  24. */
  25. /** @typedef {Object} SynteticDependencyLocation
  26. * @property {string} name
  27. * @property {number=} index
  28. */
  29. /** @typedef {SynteticDependencyLocation|RealDependencyLocation} DependencyLocation */
  30. class Dependency {
  31. constructor() {
  32. /** @type {Module|null} */
  33. this.module = null;
  34. // TODO remove in webpack 5
  35. /** @type {boolean} */
  36. this.weak = false;
  37. /** @type {boolean} */
  38. this.optional = false;
  39. /** @type {DependencyLocation} */
  40. this.loc = undefined;
  41. }
  42. getResourceIdentifier() {
  43. return null;
  44. }
  45. // Returns the referenced module and export
  46. getReference() {
  47. if (!this.module) return null;
  48. return new DependencyReference(this.module, true, this.weak);
  49. }
  50. // Returns the exported names
  51. getExports() {
  52. return null;
  53. }
  54. getWarnings() {
  55. return null;
  56. }
  57. getErrors() {
  58. return null;
  59. }
  60. updateHash(hash) {
  61. hash.update((this.module && this.module.id) + "");
  62. }
  63. disconnect() {
  64. this.module = null;
  65. }
  66. }
  67. // TODO remove in webpack 5
  68. Dependency.compare = util.deprecate(
  69. (a, b) => compareLocations(a.loc, b.loc),
  70. "Dependency.compare is deprecated and will be removed in the next major version"
  71. );
  72. module.exports = Dependency;