Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
spaceemotion opened this issue Jan 26, 2025 · 1 comment
Open

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

spaceemotion opened this issue Jan 26, 2025 · 1 comment
Assignees

Comments

@spaceemotion
Copy link

spaceemotion commented Jan 26, 2025

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

@vijayasingam-paddle vijayasingam-paddle self-assigned this Jan 27, 2025
@vijayasingam-paddle
Copy link
Contributor

Hi @spaceemotion,
Thank you for raising this feature request.

Given that V8 engines are pretty fast at parsing code, we are not sure how much benefit we might get out of tree-shaking our library, as it is all application code without any dependencies. With that said, I guess any benefit is good when it comes to lambdas.

I will give it some more thought and will make some tweaks to help with tree shaking without sacrificing the developer experience of the package.

In the meantime, please feel free to reach out to us if you need any other help.

Thank you.

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

No branches or pull requests

2 participants