MCPcopy
hub / github.com/webpack/webpack / remove

Method remove

lib/ChunkGroup.js:491–525  ·  view source on GitHub ↗

* Disconnects this group from its parents, children, and chunks. * Child groups are reconnected to this group's parents so the surrounding * graph remains intact after removal. * @returns {void}

()

Source from the content-addressed store, hash-verified

489 * @returns {void}
490 */
491 remove() {
492 // cleanup parents
493 for (const parentChunkGroup of this._parents) {
494 // remove this chunk from its parents
495 parentChunkGroup._children.delete(this);
496
497 // cleanup "sub chunks"
498 for (const chunkGroup of this._children) {
499 /**
500 * remove this chunk as "intermediary" and connect
501 * it "sub chunks" and parents directly
502 */
503 // add parent to each "sub chunk"
504 chunkGroup.addParent(parentChunkGroup);
505 // add "sub chunk" to parent
506 parentChunkGroup.addChild(chunkGroup);
507 }
508 }
509
510 /**
511 * we need to iterate again over the children
512 * to remove this from the child's parents.
513 * This can not be done in the above loop
514 * as it is not guaranteed that `this._parents` contains anything.
515 */
516 for (const chunkGroup of this._children) {
517 // remove this as parent of every "sub chunk"
518 chunkGroup._parents.delete(this);
519 }
520
521 // remove chunks
522 for (const chunk of this.chunks) {
523 chunk.removeGroup(this);
524 }
525 }
526
527 sortItems() {
528 this.origins.sort(sortOrigin);

Callers

nothing calls this directly

Calls 4

addParentMethod · 0.80
removeGroupMethod · 0.80
deleteMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected