提交学习笔记专用
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.

46 lines
1.3 KiB

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