Back to blog
Other

Lean TypeScript SDKs for the browser

Nolan Sullivan

Nolan Sullivan

August 28, 2024 ยท 3 min read

Lean TypeScript SDKs for the browser

What's better than an ergonomic, type-safe TypeScript SDK? A lean, ergonomic, type-safe TypeScript SDK that's optimized for the browser! We've made some major improvements to our TypeScript generation so that you can better serve your users who are building web applications.

And best of all, no breaking changes are required on your end. Just rerun your TypeScript generation and get the latest and greatest ๐ŸŽ‰

Lean TypeScript SDKs with standalone functions

When SDKs are large, they can bloat the bundle size of your user's app, even if they're only using a small portion of your SDK's functionality. That matters because the smaller the bundle, the faster the app loads, the better the user experience. If your SDK is too large, it may be a non-starter for your users.

To address this, we've introduced a new feature for TypeScript SDKs called Standalone Functions to make your SDKs tree-shakable. That will allow your users to import only the functions they need, resulting in a smaller bundle size and a more performant application.

Here's an example of standalone functions in action via Dub's SDK:

import { DubCore } from "dub/core.js";
import { linksCount } from "dub/funcs/linksCount.js";
async function run() {
const dub = new DubCore();
const result = await linksCount(dub);
if (!result.ok) {
throw result.error;
}
// Use the result
console.log("Link count:", result.value);
}
run();

The performance benefits are enormous. In a benchmark test using a single function from the Dub SDK, bundle-size reduced from 324.4 kb -> 82.1 kb. That's a 75% reduction in bundle size!

If you want the juicy technical details, check out the full blog post.


Regenerate Github SDKs from the CLI

Speakeasy run github

You can now remotely generate your SDKs on GitHub directly from your terminal! Just use the --github flag with speakeasy run to kick off a remote generation.

If you haven't installed the GitHub app yet, don't worry. Follow the prompts in your workspace to complete the setup. This will ensure the Speakeasy Github app has access to your managed repositories within your organization.

Ready to streamline your workflow? Give it a try!

๐Ÿ New features and bug fixes ๐Ÿ›

Note

Based on the most recent CLI version: Speakeasy v1.388.0

Generation platform

๐Ÿ Feat: Add Summary and ToC sections to Readme generation

TypeScript

๐Ÿ Feat: support added for custom compile commands
๐Ÿ Feat: support for streaming file uploads in test generation
๐Ÿ› Fix: pagination when used alongside error handling

Python

๐Ÿ› Fix: pagination when used alongside error handling
๐Ÿ› Fix: correct implementation of unions of arrays
๐Ÿ› Fix: add errorUnions handling to usage snippets

Go

๐Ÿ Feat: Support added for streaming uploads

C#

๐Ÿ› Fix: prevent conflicts with System namespace

PHP

๐Ÿ› Fix: handle empty global parameters array

Last updated on

AI everywhere.

Control here.