Skip to content

1.10: split the SDK bundle, so a server doesn't set up subsystems it doesn't use #950

Closed

Description

@frontegg-david

Follow-up to the 1.10.9 performance work: #914, #919 to #925, #932, and #934 to #943.

What's left

@frontmcp/sdk's CommonJS bundle is 2 MB of source. Compiling it takes about 16 ms at startup, and its root re-exports force about 10 to 15 ms of module setup for every subsystem, whether the server uses it or not.

Upper bounds we measured against 1.10.9-rc.4, using hacks that break public behavior:

Skipped at startup HTTP stdio
Setup of jobs, workflows, channels, remote MCP and the ESM loader −1.9 ms −1.8 ms
Loading and registering the 8 OAuth flows in a public-mode server −3.1 ms −3.6 ms
Task setup 0 0

Doing this while keeping the root exports and flow registration as they are would need a different bundle layout. A post-build rewrite of esbuild's output would be too fragile.

Proposal

Make the CommonJS root exports lazy, as getters for the subsystems a server may never use, or split the SDK into subsystem chunks that load on first use. Expected: about 5 ms and 1 to 2 MB.

Acceptance

  • The public exports are the same.
  • Hooks and plugins that target any flow behave as before, including OAuth flows in public mode.
  • Worker and browser builds keep working: the bundle-size and worker-export-condition tests pass.
  • Cold start and RSS are measured before and after with the benchmark harness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions