square / square/square-nodejs-sdk
SDK is extremely heavy to import
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 116
- Forks
- 48
- Avg merge
- 2h 13m
- Merged PRs (30d)
- 1
Description
Hi!
I'm using the Square SDK in my application, where the boot time of the application is quite sensitive to latency (because of autoscaling).
When profiling the boot time, I've noticed that requiring the Square SDK takes up 20% of the time, which equates to ~600ms (!) locally on my Macbook Air M3. I can't currently get the numbers from production, but I imagine it's even slower in wall time, especially with slower CPUs than my local machine.
Of that, 7% is square/api/index.js, 12% is square/serialization/index.js (mostly square/serialization/types/index.js) and 1% is square/Client.js:
My code only contains the import: import { SquareClient, SquareEnvironment } from 'square', but I cannot seemingly import from sub-packages. I've also noticed that the README section about sub-package exports was recently removed, which I previously tried but couldn't get it to work: https://github.com/square/square-nodejs-sdk/pull/236/changes#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
What would you recommend here? Or can you allow sub-package exports for lighter imports?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the import profile and the entry points named in square/api/index.js, square/serialization/index.js, square/serialization/types/index.js, and square/Client.js. Read the README history and pull request #236 for the prior sub-package export approach. Done means the SDK supports a documented lighter import path without breaking the main import, with measurable improvement to startup time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- developer-experience, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100