Dependency.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const compareLocations = require("./compareLocations");
  7. class Dependency {
  8. constructor() {
  9. this.module = null;
  10. }
  11. isEqualResource() {
  12. return false;
  13. }
  14. // Returns the referenced module and export
  15. getReference() {
  16. if(!this.module) return null;
  17. return {
  18. module: this.module,
  19. importedNames: true, // true: full object, false: only sideeffects/no export, array of strings: the exports with this names
  20. };
  21. }
  22. // Returns the exported names
  23. getExports() {
  24. return null;
  25. }
  26. getWarnings() {
  27. return null;
  28. }
  29. getErrors() {
  30. return null;
  31. }
  32. updateHash(hash) {
  33. hash.update((this.module && this.module.id) + "");
  34. }
  35. disconnect() {
  36. this.module = null;
  37. }
  38. // TODO: remove in webpack 3
  39. compare(a, b) {
  40. return compareLocations(a.loc, b.loc);
  41. }
  42. }
  43. Dependency.compare = (a, b) => compareLocations(a.loc, b.loc);
  44. module.exports = Dependency;