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

Function countSpan

plugin/sourcemap.ts:32–49  ·  view source on GitHub ↗
(next?: GeneratedMapping)

Source from the content-addressed store, hash-verified

30 let previous: GeneratedMapping | undefined;
31
32 const countSpan = (next?: GeneratedMapping): void => {
33 if (previous?.source == null) return;
34 // Columns and string offsets both use UTF-16; only the size uses UTF-8.
35 const start = Math.min(lineStart + previous.generatedColumn, lineEnd);
36 const end =
37 next?.generatedLine === previous.generatedLine
38 ? Math.min(lineStart + next.generatedColumn, lineEnd)
39 : lineEnd;
40 if (end <= start) return;
41
42 let module = modulesBySource.get(previous.source);
43 if (module == null) {
44 const id = path.resolve(bundleDir, previous.source);
45 module = modules[id] ??= { id, renderedLength: 0 };
46 modulesBySource.set(previous.source, module);
47 }
48 module.renderedLength += Buffer.byteLength(code.slice(start, end));
49 };
50
51 // Rollup and Rolldown emit flat maps. Stream their generated mappings without
52 // materializing characters or retaining the generated code for each module.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected