This guide is for coding agents working in this monorepo.
Focus on packages/sonda, packages/html-report, and packages/load-source-map.
Ignore packages/unplugin-sourcemaps unless a task explicitly asks for it.
sondais a source-map-based analyzer for JS/CSS build outputs.- It generates HTML reports (interactive) and/or JSON reports (automation).
- It stays bundler-agnostic by analyzing final source maps.
- It supports major bundlers and frameworks through integration wrappers.
- Main value: accurate size attribution after tree-shaking and minification.
- Integrations collect resources/connections and emitted asset paths.
- The
Reportmodel stores normalized state and drives report generation. - Processors analyze outputs, source maps, and dependencies.
- Formatters serialize final reports to HTML and JSON.
Key areas:
src/config.ts: option defaults and normalized runtime config.src/report/*: report model, processors, and formatters.src/integrations/*: bundler adapters.src/entrypoints/*: framework/bundler public entrypoints.
Important invariants:
- Keep report paths normalized (
normalizePath). - Preserve stable schema keys (
resources,connections,dependencies,issues,sourcemaps). - Handle missing sourcemaps gracefully (asset-only fallback).
- Vue 3 app shipped as a single static HTML file.
- Sonda injects compressed report data into
__REPORT_DATA__. - Runtime code decompresses payload and exposes typed selectors.
- Uses a custom hash router and a treemap-based UI.
- Loads code and source-map metadata from file or inline comments.
- Resolves map file, normalizes
sources, and backfillssourcesContentwhen possible.
- Monorepo uses
pnpmworkspaces (packages/**,playground/**). sondabuild depends onload-source-mapandhtml-reportbuilds.- Main tests are in
packages/sonda/tests(Vitest). - Deterministic output matters because tests compare full report objects.
deepandsourcesoptions can significantly increase runtime/report size.- If report schema changes, update both producer (
sonda) and consumer (html-report).
From repository root:
pnpm installpnpm buildpnpm testpnpm formatpnpm docs:dev,pnpm docs:build,pnpm docs:preview
Package builds:
pnpm --filter sonda buildpnpm --filter html-report buildpnpm --filter load-source-map build
Sonda tests:
- All:
pnpm --filter sonda test - Single file:
pnpm --filter sonda run test -- tests/vite.test.ts - Single test name:
pnpm --filter sonda exec vitest run tests/vite.test.ts -t "<test name>"
Linting reality:
- No dedicated
lintscript currently. - Formatting is enforced via
oxfmt(.oxfmtrc.jsonc).
Formatting and imports:
- Use tabs, semicolons, and single quotes.
- Avoid trailing commas; keep lines near 120 chars.
- Group imports as: Node built-ins, third-party, internal.
- Use
import typefor type-only imports. - Keep local
.jsextensions in TS imports where existing code does.
Types, naming, and errors:
- Keep strict typing; avoid
anyunless unavoidable. - Prefer interfaces/discriminated unions for shared report models.
- Use
PascalCase(types/classes/components),camelCase(variables/functions),UPPER_SNAKE_CASE(constants). - Prefer guard clauses and explicit early returns.
- Return
null/fallbacks for optional map/file paths; throw only for unsupported states.
Implementation guardrails:
- Keep changes focused and avoid unrelated refactors.
- Preserve deterministic output and schema contracts.
- Preserve the
__REPORT_DATA__producer/consumer contract.