MCPcopy Create free account
hub / github.com/btd/rollup-plugin-visualizer / buildReport

Function buildReport

plugin/report.ts:167–198  ·  view source on GitHub ↗
(
  selected: SelectedReport,
  projectRoot: string | RegExp,
  measure: (part: CodeContribution) => Promise<ModuleLengths & { id: string }>,
)

Source from the content-addressed store, hash-verified

165};
166
167export const buildReport = async (
168 selected: SelectedReport,
169 projectRoot: string | RegExp,
170 measure: (part: CodeContribution) => Promise<ModuleLengths & { id: string }>,
171): Promise<Pick<VisualizerData, "tree" | "nodeParts" | "nodeMetas">> => {
172 const mapper = new ModuleMapper(projectRoot);
173 const roots: (ModuleTree | ModuleTreeLeaf)[] = [];
174 for (const chunk of selected.chunks) {
175 if (chunk.kind === "fallback") {
176 const sizes = await measure({ id: chunk.id, code: chunk.part.code });
177 const uid = mapper.setNodePart(chunk.id, chunk.part.id, sizes);
178 roots.push({ name: chunk.id, uid });
179 } else {
180 const parts = await Promise.all(
181 chunk.parts.map((part) =>
182 "code" in part ? measure(part) : { ...part, gzipLength: 0, brotliLength: 0 },
183 ),
184 );
185 roots.push(buildTree(chunk.id, parts, mapper));
186 }
187 }
188 for (const module of selected.modules.values()) mapper.setNodeMeta(module.id, module);
189 for (const link of selected.links) {
190 mapper.addImportedByLink(link.target, link.source);
191 mapper.addImportedLink(link.source, link.target, link.dynamic);
192 }
193 return {
194 tree: mergeTrees(roots),
195 nodeParts: mapper.getNodeParts(),
196 nodeMetas: mapper.getNodeMetas(),
197 };
198};

Callers 2

generateBundleFunction · 0.85
generateBundleFunction · 0.85

Calls 8

setNodePartMethod · 0.95
setNodeMetaMethod · 0.95
addImportedByLinkMethod · 0.95
addImportedLinkMethod · 0.95
getNodePartsMethod · 0.95
getNodeMetasMethod · 0.95
buildTreeFunction · 0.85
mergeTreesFunction · 0.85

Tested by 1

generateBundleFunction · 0.68