Skip to content

[Feature]: Make the SDK more modular/tree-shakable #104

@spaceemotion

Description

@spaceemotion

Tell us about your feature request

We are using the Paddle SDK on our AWS Lambdas, and only need a couple endpoints. We don't deal with reports, looking up addresses and the like, but pulling in this package makes any kind of tree-shaking impossible.

Moving to a more composable SDK, where each endpoint or resource can be instantiated when needed, would reduce our bundle size.

What problem are you looking to solve?

The main Paddle SDK is using a class-based approach, that creates all nested resources internally. This means that all resources will be bundled, whether they're needed or not.

I would prefer if each resource could be created with a reference to the main Paddle instance itself. That way one can pick and choose which bits to keep.

We also do event processing on our end (via webhooks), but only care about specific events. However, the event handling requires all event types to be bundled in our final output - even the ones we don't care or listen to.

Additional context

Some suggestions:

import { Paddle, Products } from '@paddle/paddle-node-sdk'

const paddle = new Paddle('API_KEY');

const products = new Products(paddle);
const list = products.list();
import { Webhooks, subscriptionCreatedEvent, subscriptionUpdatedEvent } from '@paddle/paddle-node-sdk'

const webhooks = new Webhooks(paddle, {
  events: [
    subscriptionCreatedEvent,
    subscriptionUpdatedEvent,
  ],
});

const data = webhooks.unsmarshal(...);

Adding hints for certain methods being pure or without side-effects might also help.

How important is this suggestion to you?

Important

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions