Skip to content

Speed up public SDK declaration generation with the installed native compiler - #6259

Merged
ymichael merged 2 commits into
mainfrom
bb/ci-native-public-sdk-dts
Oct 25, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/ci-native-public-sdk-dts

Conversation

@ymichael

@ymichael ymichael commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Public SDK declaration generation ran the JavaScript TypeScript emitter inside Rollup over roughly 200 reachable workspace sources. This serial stage sits inside the bb-app build used by packaging CI. Paired CI measurements put it at 13.9 seconds on Linux and 9.0 seconds on macOS on average.

What changed

On supported Linux and Apple Silicon platforms, use the already installed native TypeScript compiler (tsrs) to emit the reachable workspace declarations into a temporary directory, then bundle those declarations with the existing Rollup declaration bundler. Preserve workspace package resolution and external dependencies. Compiler errors fail the build and temporary files are removed on success or failure.

Windows, Intel macOS, and unsupported architectures retain the existing JavaScript emitter. No dependencies, caches, shards, runtime behavior, or public SDK API are intentionally changed. This does change how the published SDK declaration artifact is generated; its textual declaration ordering can differ.

How you verified

  • Paired Linux/macOS CI benchmark: two runners per platform, alternating ABBA/BAAB order, four fresh baseline and candidate generations per platform. Linux averages 13.94→3.46s (75% faster, 10.48s saved); macOS 9.04→1.99s (78% faster, 7.05s saved). All four jobs also pass real tarball installation, packaged SDK consumer checks, and runtime smoke for both declaration versions. These are declaration-stage savings, not whole-workflow percentages.
  • Exhaustive one-off TypeScript 6 compatibility checks cover all 512 type-only exports (including six universally parameterized generic exports) and public runtime contracts in both assignability directions. All 549 export names remain. The class with private nominal members has identical complete declaration syntax. Route intersections retain all 185 branches and 220 unique endpoint/method signatures; there are no duplicate endpoint/method overloads whose precedence could change.
  • The candidate declaration SHA-256 is identical between local compatibility proofs, installed consumer checks, and all eight Linux/macOS CI emissions (49a82607fcc1b9fc5b81f48d7c1fca2b05477efd678044bc7a790e8139c0be77).
  • One-off platform-routing checks cover Darwin ARM64/x64, Linux ARM64/x64/RISC-V, Windows x64, and FreeBSD x64. Only supported combinations enter native emission; each fallback output matches the original generator after order normalization. These are simulated routing checks, not claims of execution on all seven platforms.
  • A real source type-error mutation fails with TS2322, preserves the existing output, and leaves no temporary directories. Source restored byte-for-byte afterward.
  • Final-head CI passed on 433773655484fb6a54994b25f74b88e89a05b999, including Linux/macOS tarball packaging, Linux AppImage lifecycle, Windows app tarball and desktop smoke checks, and all selected package tests.
  • pnpm exec turbo run typecheck test --filter=bb-app: all 216 tests in 23 files passed. Formatting, lint, and diff checks passed. Independent review covered declaration compatibility, workspace resolution, cleanup and platform routing.

AGENT GENERATED

@ymichael
ymichael marked this pull request as ready for review October 25, 2026 03:48
@ymichael
ymichael merged commit a6fff60 into main Oct 25, 2026
28 checks passed
@ymichael
ymichael deleted the bb/ci-native-public-sdk-dts branch October 25, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant