Context
Raised during review of the feat(v0.2): direct upload endpoint and server mode change (commit c3894ef).
src/runtime/server/adapters/s3.ts now top-level-imports three AWS SDK packages, all declared as optional in peerDependenciesMeta:
@aws-sdk/client-s3
@aws-sdk/s3-request-presigner
@aws-sdk/lib-storage (added in this change, only used inside put())
Because all three are imported statically, any consumer of S3Storage needs all three installed — even presigned-only users. This contradicts the "optional" label on the peer dep.
CodeRabbit suggested lazy-loading only lib-storage (since it's used only in put()), but that would be inconsistent with how client-s3 and s3-request-presigner are handled — the same argument applies to them.
What to address
Decide on a single consistent policy, then apply it to all three packages:
- Keep static top-level imports and drop the
optional: true designation for all three in peerDependenciesMeta. Honest: if you import S3Storage, you need all three.
- Lazy-load all three inside
S3Storage() so that merely importing the factory doesn't require the SDK. Each method (presignUpload, put, delete, etc.) await import(...) on first use, with a clear error message if the peer dep is missing.
Option 1 is simpler and matches reality. Option 2 enables tree-shaking for users who import from a barrel file but never construct S3Storage, which is a weak win.
Files
src/runtime/server/adapters/s3.ts
package.json (peerDependenciesMeta)
Context
Raised during review of the
feat(v0.2): direct upload endpoint and server modechange (commit c3894ef).src/runtime/server/adapters/s3.tsnow top-level-imports three AWS SDK packages, all declared as optional inpeerDependenciesMeta:@aws-sdk/client-s3@aws-sdk/s3-request-presigner@aws-sdk/lib-storage(added in this change, only used insideput())Because all three are imported statically, any consumer of
S3Storageneeds all three installed — even presigned-only users. This contradicts the "optional" label on the peer dep.CodeRabbit suggested lazy-loading only
lib-storage(since it's used only input()), but that would be inconsistent with howclient-s3ands3-request-presignerare handled — the same argument applies to them.What to address
Decide on a single consistent policy, then apply it to all three packages:
optional: truedesignation for all three inpeerDependenciesMeta. Honest: if you importS3Storage, you need all three.S3Storage()so that merely importing the factory doesn't require the SDK. Each method (presignUpload,put,delete, etc.)await import(...)on first use, with a clear error message if the peer dep is missing.Option 1 is simpler and matches reality. Option 2 enables tree-shaking for users who import from a barrel file but never construct
S3Storage, which is a weak win.Files
src/runtime/server/adapters/s3.tspackage.json(peerDependenciesMeta)