Skip to content

Tree-shaking audit + per-chain bundle size budget #17

@truthixify

Description

@truthixify

Labels: Stellar Wave, stellar, perf, audit, drips, help-wanted
Tier: M (2–4 days)
Type: perf / audit

Context

The SDK ships subpath exports per chain so consumers can import only what they need. In theory, a consumer who only uses @wraith-protocol/sdk/chains/stellar should not pay the bundle cost of EVM, Solana, or CKB code. In practice, we've never verified this. Shared utility files, accidental cross-imports between chains, and noble-curves' multi-curve bundles could be silently leaking unused code into every consumer's bundle.

Scope

  1. Measure per-entry bundle sizes — for each of index, chains/evm, chains/stellar, chains/solana, chains/ckb, build a minimal consumer (one import { something } from '@wraith-protocol/sdk/chains/X') and measure the resulting bundle with both Vite and esbuild.
  2. Visualize the dependency graph — run rollup-plugin-visualizer or esbuild-analyzer and identify any non-obvious crossover (e.g., Stellar code being pulled into a CKB-only consumer).
  3. Set per-entry budgets in package.json:
    {
      "size-limit": [
        { "path": "dist/chains/stellar/*", "limit": "40 KB" },
        { "path": "dist/chains/evm/*", "limit": "35 KB" },
        ...
      ]
    }
  4. CI gate — fail the PR if any entry exceeds budget.
  5. Optimization pass — fix any unintended crossovers; document the ones that are necessary (e.g., Solana legitimately re-exports Stellar's scalar math).

Where crossover is expected

  • chains/solana re-uses chains/stellar crypto. That's intentional and should be measured + budgeted accordingly.
  • chains/ckb re-uses chains/evm keys. Same story.

Crossover that is NOT expected:

  • chains/evm accidentally importing from chains/stellar.
  • A shared utils/ module that pulls in chain-specific code via import * as.

Acceptance criteria

  • Bundle sizes per entry measured and committed in BUNDLE_SIZE.md.
  • Per-entry budgets in CI via size-limit or equivalent.
  • Visualizer output committed (PNG or HTML) so future contributors can see the breakdown.
  • At least one identified optimization landed.
  • PR description includes a before/after table.

Why this matters

Frontend consumers (the demo, the console, any third-party integrator's web app) directly feel SDK bundle size. A 50 KB savings on the Stellar entry is a measurable LCP improvement for every user of every Wraith-powered site.

Resources

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programauditProduces a written report as primary deliverabledripsFunded via Drips Networkhelp wantedExtra attention is neededperfPerformance / optimizationstellarTouches Stellar / Soroban code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions