ory / sdk

The place where ORY's SDKs are being auto-generated
Apache License 2.0
135 stars 85 forks source link

Ory client side libraries should be Tree Shakeable #362

Closed md-owes closed 3 days ago

md-owes commented 1 week ago

Preflight checklist

Ory Network Project

No response

Describe your problem

All modern library libraries support tree shaking feature in order to reduce bundle size. In case of @ory/client, it is not, (at least not fully) as it produces a runtime bundle of 2.3mb which contributes to longer loading times of my application.

Describe your ideal solution

Instead of one big file api.ts consisting of ~27k lines of code, it should be broken down into several smaller class files that embraces SOLID design principles. Few more optimizations that can be applied to a library to make it tree shakeable is explained in the below articles

https://cube.dev/blog/how-to-build-tree-shakeable-javascript-libraries https://blog.theodo.com/2021/04/library-tree-shaking/

Workarounds or alternatives

no workarounds as we are forced to download entire @ory/client library even if we are consuming few classes, components or functions

Version

1.12.1

Additional Context

No response

aeneasr commented 3 days ago

You can use @ory/client-fetch for this now!

aeneasr commented 3 days ago

https://www.npmjs.com/package/@ory/client-fetch

md-owes commented 1 day ago

will give it a try this week. thanks.