FallbackDependency.js 955 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. class FallbackDependency extends Dependency {
  9. constructor(requests) {
  10. super();
  11. this.requests = requests;
  12. }
  13. /**
  14. * @returns {string | null} an identifier to merge equal requests
  15. */
  16. getResourceIdentifier() {
  17. return `fallback ${this.requests.join(" ")}`;
  18. }
  19. get type() {
  20. return "fallback";
  21. }
  22. get category() {
  23. return "esm";
  24. }
  25. serialize(context) {
  26. const { write } = context;
  27. write(this.requests);
  28. super.serialize(context);
  29. }
  30. static deserialize(context) {
  31. const { read } = context;
  32. const obj = new FallbackDependency(read());
  33. obj.deserialize(context);
  34. return obj;
  35. }
  36. }
  37. makeSerializable(
  38. FallbackDependency,
  39. "webpack/lib/container/FallbackDependency"
  40. );
  41. module.exports = FallbackDependency;