Skip to content

Maintenance: switch tsconfig to ESM first #3958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 2 tasks
dreamorosi opened this issue May 21, 2025 · 0 comments · May be fixed by #3959
Open
1 of 2 tasks

Maintenance: switch tsconfig to ESM first #3958

dreamorosi opened this issue May 21, 2025 · 0 comments · May be fixed by #3959
Assignees
Labels
confirmed The scope is clear, ready for implementation internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)

Comments

@dreamorosi
Copy link
Contributor

Summary

Despite us shipping both CJS and ESM builds to npmjs, our codebase runs TypeScript primarily as commonjs. This is a relic of the v1 codebase that was never updated.

Some packages in the ecosystem - ironically including us - are starting to leverage sub-path exports to provide granular exports to different parts of the package. This is what Zod is doing to ship v3 alongside v4, respectively under zod/v3 and zod/v4.

While we haven't decided yet when we're going to upgrade to Zod v4, we will probably have to update the imports in our codebase from using zod to use zod/v3 sometime soon. Currently Zod aliases zod to v3, but once that changes things might start breaking. Updating the imports also helps customers immediately understand which version we support.

In order for us to do this, we need to change the module resolution config in the tsconfig.json file, and the option we want to use requires ESM (others are compatible with CJS but since we're switching we might as well switch to the best config).

Because of this, we should update our tsconfig.json files accordingly.

Why is this needed?

So that we can facilitate the migration to newer module schemes (i.e. #3951), and in the future potentially run our unit tests without having a build step.

Which area does this relate to?

No response

Solution

Switch the tsconfig.json (currently CJS) and tsconfig.esm.json to tsconfig.cjs.json and tsconfig.json (to become ESM).

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@dreamorosi dreamorosi self-assigned this May 21, 2025
@dreamorosi dreamorosi added internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) confirmed The scope is clear, ready for implementation labels May 21, 2025
@dreamorosi dreamorosi moved this from Triage to Backlog in Powertools for AWS Lambda (TypeScript) May 21, 2025
@dreamorosi dreamorosi moved this from Backlog to Pending review in Powertools for AWS Lambda (TypeScript) May 21, 2025
@dreamorosi dreamorosi linked a pull request May 21, 2025 that will close this issue
@dreamorosi dreamorosi moved this from Pending review to On hold in Powertools for AWS Lambda (TypeScript) May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed The scope is clear, ready for implementation internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)
Projects
Development

Successfully merging a pull request may close this issue.

1 participant