GraphHelpers.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
  7. /** @typedef {import("./Chunk")} Chunk */
  8. /** @typedef {import("./ChunkGroup")} ChunkGroup */
  9. /** @typedef {import("./DependenciesBlock")} DependenciesBlock */
  10. /** @typedef {import("./Module")} Module */
  11. /** @typedef {import(".").Entrypoint} Entrypoint */
  12. /**
  13. * @param {ChunkGroup} chunkGroup the ChunkGroup to connect
  14. * @param {Chunk} chunk chunk to tie to ChunkGroup
  15. * @returns {void}
  16. */
  17. const connectChunkGroupAndChunk = (chunkGroup, chunk) => {
  18. if (chunkGroup.pushChunk(chunk)) {
  19. chunk.addGroup(chunkGroup);
  20. }
  21. };
  22. /**
  23. * @param {ChunkGroup} parent parent ChunkGroup to connect
  24. * @param {ChunkGroup} child child ChunkGroup to connect
  25. * @returns {void}
  26. */
  27. const connectChunkGroupParentAndChild = (parent, child) => {
  28. if (parent.addChild(child)) {
  29. child.addParent(parent);
  30. }
  31. };
  32. /**
  33. * @param {Entrypoint} entrypoint the entrypoint
  34. * @param {Entrypoint} dependOnEntrypoint the dependOnEntrypoint
  35. * @returns {void}
  36. */
  37. const connectEntrypointAndDependOn = (entrypoint, dependOnEntrypoint) => {
  38. entrypoint.addDependOn(dependOnEntrypoint);
  39. };
  40. module.exports.connectChunkGroupAndChunk = connectChunkGroupAndChunk;
  41. module.exports.connectChunkGroupParentAndChild =
  42. connectChunkGroupParentAndChild;
  43. module.exports.connectEntrypointAndDependOn = connectEntrypointAndDependOn;