aws / aws/bedrock-agentcore-sdk-typescript

Add dual module support (ESM + CommonJS)

Open
#61 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
91
Forks
31
Avg merge
1d 11h
Merged PRs (30d)
5

Description

## Summary

Add support for both ESM and CommonJS module systems to improve compatibility with projects using CommonJS resolution (e.g., tsx with CommonJS projects).

## Background

Currently, this package is ESM-only (`"type": "module"`). Users with CommonJS projects encounter module resolution errors when trying to import this package.

Related: #42, PR #43

## Proposed Solution

Implement dual module support following the AWS SDK pattern:

1. **Separate build outputs**: `dist-cjs/` (CommonJS) and `dist-es/` (ESM)
2. **Update package.json exports**:
```json
"exports": {
".": {
"require": "./dist-cjs/index.js",
"import": "./dist-es/index.js",
"types": "./dist-types/index.d.ts"
}
}
```
3. **Add separate TypeScript configs** for each module format

## Alternatives Considered

- **Bundler approach (tsup/esbuild)**: Single config generates both formats
- **Keep ESM-only**: Document requirement for users to configure their projects for ESM

## Current Workaround

Users can add `"type": "module"` to their project's `package.json` to enable ESM resolution.

Contributor guide

Open the contributing guide

Research direction

Start by inspecting package.json and the current TypeScript build configuration, then review related issue #42 and PR #43 for prior decisions. Done means producing the proposed dist-cjs, dist-es, and dist-types outputs and making both require and import resolution work through the package exports.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.