Skip to content

perf: add a lightweight runtime entry point and bundle-size budgets #367

Description

@vamgan

Summary

Add a genuinely lightweight Askable entry point and enforce browser bundle-size budgets in CI.

Why

Askable's runtime benchmarks are healthy, but bundle weight is not currently budgeted. A measured consumer that imports only useAskable from @askable-ui/react/core still bundles approximately 63.5 KB minified / 18.2 KB gzip on main (40a3374). Importing from the normal React entry is approximately 65.0 KB minified / 18.5 KB gzip.

The main reason is structural: createAskableContext() is implemented by a large class in packages/core/src/context.ts, so optional source resolution, packet/protocol, async subscription, viewport, serialization, and related behavior cannot be tree-shaken at the method level. The current /core framework subpaths reduce exports but do not provide a truly small runtime.

Package evidence after build:

  • @askable-ui/core: ~147 KB tarball / ~693 KB unpacked
  • @askable-ui/react: ~77 KB tarball / ~389 KB unpacked
  • core package source maps account for roughly 43% of built dist

Runtime performance itself is currently good: all 9 existing core benchmark budgets pass, including 10k-element observation in ~26 ms. This proposal is about transfer/parse weight and preventing future regressions.

Proposed direction

  1. Add a minimal runtime entry point, for example @askable-ui/core/lite, containing only:
    • annotate/observe/select/push
    • current focus + bounded history
    • sanitization
    • basic prompt serialization
    • lifecycle/events
  2. Keep advanced capabilities opt-in through explicit subpaths/plugins:
    • sources/async resolution
    • context packet protocol
    • inspector
    • region/text capture
    • extended browser sources
  3. Add matching framework entry points such as @askable-ui/react/lite.
  4. Add a deterministic esbuild-based bundle check to CI with committed gzip budgets.
  5. Consider omitting source maps from published tarballs or making that an explicit release tradeoff while retaining declarations.

Acceptance criteria

  • A documented lightweight entry point exists without breaking current imports
  • A minimal React consumer is at or below an agreed target (suggested initial target: 10 KB gzip)
  • CI measures representative core and adapter consumer bundles
  • CI fails on budget regressions with an actionable report
  • Inspector/capture/source features remain available through explicit imports
  • Runtime benchmark budgets remain green

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreCore package and cross-package runtime behaviorenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions