Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,32 @@ await client.payments.create({
});
```

### Subpath imports

For applications where startup latency matters (serverless cold starts, autoscaling
boots, etc.), the SDK exposes its internal modules as package subpaths so consumers
can avoid loading the full surface — including the ~1,300 runtime serialization
schemas — when they only need a slice of it.

```typescript
// Just the type definitions for a single resource — no runtime schemas loaded.
import type { Payment, Money } from "square/api/types/Payment";

// Just one resource client.
import { PaymentsClient } from "square/api/resources/payments";

// Just the runtime serialization for a single model, e.g. for a custom worker
// that needs to (de)serialize Square payloads without booting the client.
import { Payment as PaymentSchema } from "square/serialization/types/Payment";

// Just the SDK entry-point class and constants.
import { SquareClient } from "square/Client";
import { SquareEnvironment } from "square/environments";
```

The default `import { SquareClient } from "square"` entry continues to re-export the
full surface and remains the recommended import for typical usage.

## Legacy SDK

## Legacy SDK
Expand Down
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,51 @@
},
"exports": {
".": "./index.js",
"./api": {
"types": "./api/index.d.ts",
"default": "./api/index.js"
},
"./api/resources/*": {
"types": "./api/resources/*/index.d.ts",
"default": "./api/resources/*/index.js"
},
"./api/types/*": {
"types": "./api/types/*.d.ts",
"default": "./api/types/*.js"
},
"./serialization": {
"types": "./serialization/index.d.ts",
"default": "./serialization/index.js"
},
"./serialization/resources/*": {
"types": "./serialization/resources/*/index.d.ts",
"default": "./serialization/resources/*/index.js"
},
"./serialization/types/*": {
"types": "./serialization/types/*.d.ts",
"default": "./serialization/types/*.js"
},
"./Client": {
"types": "./Client.d.ts",
"default": "./Client.js"
},
"./BaseClient": {
"types": "./BaseClient.d.ts",
"default": "./BaseClient.js"
},
"./environments": {
"types": "./environments.d.ts",
"default": "./environments.js"
},
"./errors": {
"types": "./errors/index.d.ts",
"default": "./errors/index.js"
},
"./version": {
"types": "./version.d.ts",
"default": "./version.js"
},
"./package.json": "./package.json",
"./legacy": {
"types": "./legacy/exports/index.d.ts",
"require": {
Expand Down