GraphHelpers.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. /**
  12. * @param {ChunkGroup} chunkGroup the ChunkGroup to connect
  13. * @param {Chunk} chunk chunk to tie to ChunkGroup
  14. * @returns {void}
  15. */
  16. const connectChunkGroupAndChunk = (chunkGroup, chunk) => {
  17. if (chunkGroup.pushChunk(chunk)) {
  18. chunk.addGroup(chunkGroup);
  19. }
  20. };
  21. /**
  22. * @param {ChunkGroup} parent parent ChunkGroup to connect
  23. * @param {ChunkGroup} child child ChunkGroup to connect
  24. * @returns {void}
  25. */
  26. const connectChunkGroupParentAndChild = (parent, child) => {
  27. if (parent.addChild(child)) {
  28. child.addParent(parent);
  29. }
  30. };
  31. exports.connectChunkGroupAndChunk = connectChunkGroupAndChunk;
  32. exports.connectChunkGroupParentAndChild = connectChunkGroupParentAndChild;