(compilation)
| 21 | * @returns {void} |
| 22 | */ |
| 23 | const handler = (compilation) => { |
| 24 | compilation.hooks.afterSeal.tap("testcase", () => { |
| 25 | /** @type {Record<string, string>} */ |
| 26 | const data = {}; |
| 27 | for (const [name, group] of compilation.namedChunkGroups) { |
| 28 | /** @type {Map<Module, number>} */ |
| 29 | const modules = new Map(); |
| 30 | for (const chunk of group.chunks) { |
| 31 | for (const module of compilation.chunkGraph.getChunkModulesIterable( |
| 32 | chunk |
| 33 | )) { |
| 34 | const preOrder = group.getModulePreOrderIndex(module); |
| 35 | if (typeof preOrder === "number") { |
| 36 | modules.set(module, preOrder); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | const sortedModules = [...modules].sort((a, b) => a[1] - b[1]); |
| 41 | const text = sortedModules |
| 42 | .map( |
| 43 | ([m, index]) => |
| 44 | `${index}: ${m.readableIdentifier( |
| 45 | compilation.requestShortener |
| 46 | )}` |
| 47 | ) |
| 48 | .join(", "); |
| 49 | data[`${name}Index`] = text; |
| 50 | } |
| 51 | expect(data).toEqual({ |
| 52 | AIndex: "0: ./A.js, 1: css ./m.css", |
| 53 | "B-2Index": "0: ./B-2.js", |
| 54 | BIndex: "0: ./B.js", |
| 55 | mainIndex: "0: ./main.js", |
| 56 | sharedIndex: "1: css ./m.css, 2: css ./n.css" |
| 57 | }); |
| 58 | }); |
| 59 | }; |
| 60 | this.hooks.compilation.tap("testcase", handler); |
| 61 | } |
| 62 | ], |
nothing calls this directly
no test coverage detected