You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /** @typedef {import("./Chunk")} Chunk */
  2. /** @typedef {import("./ChunkGroup")} ChunkGroup */
  3. /** @typedef {import("./Module")} Module */
  4. /** @typedef {import("./DependenciesBlock")} DependenciesBlock */
  5. /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
  6. /**
  7. * @param {ChunkGroup} chunkGroup the ChunkGroup to connect
  8. * @param {Chunk} chunk chunk to tie to ChunkGroup
  9. * @returns {void}
  10. */
  11. const connectChunkGroupAndChunk = (chunkGroup, chunk) => {
  12. if (chunkGroup.pushChunk(chunk)) {
  13. chunk.addGroup(chunkGroup);
  14. }
  15. };
  16. /**
  17. * @param {ChunkGroup} parent parent ChunkGroup to connect
  18. * @param {ChunkGroup} child child ChunkGroup to connect
  19. * @returns {void}
  20. */
  21. const connectChunkGroupParentAndChild = (parent, child) => {
  22. if (parent.addChild(child)) {
  23. child.addParent(parent);
  24. }
  25. };
  26. /**
  27. * @param {Chunk} chunk Chunk to connect to Module
  28. * @param {Module} module Module to connect to Chunk
  29. * @returns {void}
  30. */
  31. const connectChunkAndModule = (chunk, module) => {
  32. if (module.addChunk(chunk)) {
  33. chunk.addModule(module);
  34. }
  35. };
  36. /**
  37. * @param {Chunk} chunk Chunk being disconnected
  38. * @param {Module} module Module being disconnected
  39. * @returns {void}
  40. */
  41. const disconnectChunkAndModule = (chunk, module) => {
  42. chunk.removeModule(module);
  43. module.removeChunk(chunk);
  44. };
  45. /**
  46. * @param {AsyncDependenciesBlock} depBlock DepBlock being tied to ChunkGroup
  47. * @param {ChunkGroup} chunkGroup ChunkGroup being tied to DepBlock
  48. * @returns {void}
  49. */
  50. const connectDependenciesBlockAndChunkGroup = (depBlock, chunkGroup) => {
  51. if (chunkGroup.addBlock(depBlock)) {
  52. depBlock.chunkGroup = chunkGroup;
  53. }
  54. };
  55. exports.connectChunkGroupAndChunk = connectChunkGroupAndChunk;
  56. exports.connectChunkGroupParentAndChild = connectChunkGroupParentAndChild;
  57. exports.connectChunkAndModule = connectChunkAndModule;
  58. exports.disconnectChunkAndModule = disconnectChunkAndModule;
  59. exports.connectDependenciesBlockAndChunkGroup = connectDependenciesBlockAndChunkGroup;