Skip to content

Move AWS deps to optional peer dependencies#280

Open
fern-support wants to merge 4 commits intomainfrom
fern-support/reduce-size-with-peer-deps
Open

Move AWS deps to optional peer dependencies#280
fern-support wants to merge 4 commits intomainfrom
fern-support/reduce-size-with-peer-deps

Conversation

@fern-support
Copy link
Collaborator

@fern-support fern-support commented Feb 19, 2026

Summary

  • Moves AWS SDK packages (@aws-sdk/credential-providers, @aws-crypto/sha256-js, @smithy/protocol-http, @smithy/signature-v4) from dependencies to optional peerDependencies
  • Removes unused @aws-sdk/client-sagemaker dependency
  • Creates cohere-ai/aws subpath entry point for AWS clients (Bedrock, SageMaker)
  • Removes AWS client exports from main cohere-ai entry point
  • Adds lazy loading in aws-utils.ts so missing AWS deps don't crash non-AWS users at import time
  • Documents new AWS usage pattern in README

Install size reduction: ~47MB → ~17MB (64% smaller)

Closes #250

Migration

Users of AWS clients need to update their imports:

// Before
import { BedrockClient } from "cohere-ai";

// After
import { BedrockClient } from "cohere-ai/aws";

And explicitly install the AWS peer dependencies:

npm install @aws-sdk/credential-providers @aws-crypto/sha256-js @smithy/protocol-http @smithy/signature-v4

Test plan

  • require('cohere-ai') works without AWS deps installed
  • require('cohere-ai/aws') exports all AWS clients
  • TypeScript compilation passes
  • Verified install size reduction (47MB → 17MB)

🤖 Generated with Claude Code


Note

Medium Risk
Introduces a breaking import-path change for AWS clients and changes dependency resolution/loading behavior, which could surface runtime/module-resolution issues if packaging or peer deps are misconfigured.

Overview
Moves AWS signing/runtime dependencies out of main dependencies into optional peerDependencies, and drops unused @aws-sdk/client-sagemaker to reduce install weight.

Introduces a dedicated cohere-ai/aws subpath export (src/aws.ts + package.json exports) and removes Bedrock/SageMaker client exports from the root entrypoint, updating tests and README usage accordingly.

Updates aws-utils.ts to lazily require() AWS modules and throw a clear install hint only when AWS functionality is invoked, so importing cohere-ai doesn’t crash when AWS deps aren’t installed.

Written by Cursor Bugbot for commit 999bb21. This will update automatically on new commits. Configure here.

fern-support and others added 2 commits February 18, 2026 20:10
- Remove BedrockClient/SagemakerClient exports from main entry point
- Create src/aws.ts as new subpath entry point for all AWS clients
- Replace static AWS imports with lazy loading in aws-utils.ts so
  missing peer deps don't break non-AWS users at import time
- Add src/aws.ts to .fernignore
- Document new AWS usage pattern in README

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reduces install size from ~47MB to ~17MB (64% reduction) by making AWS
SDK packages optional peer dependencies. Users who need Bedrock/SageMaker
support install them explicitly. Also removes unused @aws-sdk/client-sagemaker
dependency and updates test imports to use the new cohere-ai/aws subpath.

Closes #250

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

fern-support and others added 2 commits February 18, 2026 21:00
Without an exports field, TypeScript's moduleResolution: "nodenext"
cannot resolve the cohere-ai/aws subpath import. Adds minimal exports
for "." and "./aws" entry points.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mariusa
Copy link

mariusa commented Feb 20, 2026

Please:
remove node-fetch - no longer needed since Node 18
remove form-data and formdata-node - no longer needed since Node 21
remove qs - use URLSearchParams

Comment on lines 24 to 26
"form-data": "^4.0.4",
"form-data-encoder": "^4.1.0",
"formdata-node": "^6.0.3"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to mariusa some of these can be removed?

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

Successfully merging this pull request may close these issues.

package is too big

3 participants