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