* Groups child chunk groups by their `*Order` options and sorts each group * by descending order and deterministic chunk-group comparison. * @param {ModuleGraph} moduleGraph the module graph * @param {ChunkGraph} chunkGraph the chunk graph * @returns {Record<string, ChunkGroup[]>} mapping fr
(moduleGraph, chunkGraph)
| 599 | * @returns {Record<string, ChunkGroup[]>} mapping from children type to ordered list of ChunkGroups |
| 600 | */ |
| 601 | getChildrenByOrders(moduleGraph, chunkGraph) { |
| 602 | /** @type {Map<string, { order: number, group: ChunkGroup }[]>} */ |
| 603 | const lists = new Map(); |
| 604 | for (const childGroup of this._children) { |
| 605 | const edgeOptions = this.getChildOrderOptions(childGroup, chunkGraph); |
| 606 | for (const key of Object.keys(edgeOptions)) { |
| 607 | const name = key.slice(0, key.length - "Order".length); |
| 608 | let list = lists.get(name); |
| 609 | if (list === undefined) { |
| 610 | lists.set(name, (list = [])); |
| 611 | } |
| 612 | list.push({ |
| 613 | order: edgeOptions[key], |
| 614 | group: childGroup |
| 615 | }); |
| 616 | } |
| 617 | } |
| 618 | /** @type {Record<string, ChunkGroup[]>} */ |
| 619 | const result = Object.create(null); |
| 620 | for (const [name, list] of lists) { |
| 621 | list.sort((a, b) => { |
| 622 | const cmp = b.order - a.order; |
| 623 | if (cmp !== 0) return cmp; |
| 624 | return a.group.compareTo(chunkGraph, b.group); |
| 625 | }); |
| 626 | result[name] = list.map((i) => i.group); |
| 627 | } |
| 628 | return result; |
| 629 | } |
| 630 | |
| 631 | /** |
| 632 | * Stores the module's top-down traversal index within this group. |
no test coverage detected