ContainerExposedDependency.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
  4. */
  5. "use strict";
  6. const ModuleDependency = require("../dependencies/ModuleDependency");
  7. const makeSerializable = require("../util/makeSerializable");
  8. class ContainerExposedDependency extends ModuleDependency {
  9. /**
  10. * @param {string} exposedName public name
  11. * @param {string} request request to module
  12. */
  13. constructor(exposedName, request) {
  14. super(request);
  15. this.exposedName = exposedName;
  16. }
  17. get type() {
  18. return "container exposed";
  19. }
  20. get category() {
  21. return "esm";
  22. }
  23. /**
  24. * @returns {string | null} an identifier to merge equal requests
  25. */
  26. getResourceIdentifier() {
  27. return `exposed dependency ${this.exposedName}=${this.request}`;
  28. }
  29. serialize(context) {
  30. context.write(this.exposedName);
  31. super.serialize(context);
  32. }
  33. deserialize(context) {
  34. this.exposedName = context.read();
  35. super.deserialize(context);
  36. }
  37. }
  38. makeSerializable(
  39. ContainerExposedDependency,
  40. "webpack/lib/container/ContainerExposedDependency"
  41. );
  42. module.exports = ContainerExposedDependency;