Skip to content

feat(build): dual CJS/ESM output for all packages#517

Merged
Rubilmax merged 2 commits intomainfrom
Rubilmax/cjs-esm-compat
Mar 3, 2026
Merged

feat(build): dual CJS/ESM output for all packages#517
Rubilmax merged 2 commits intomainfrom
Rubilmax/cjs-esm-compat

Conversation

@Rubilmax
Copy link
Collaborator

@Rubilmax Rubilmax commented Feb 25, 2026

Summary

  • Each package now emits both CommonJS (lib/cjs/) and ESM (lib/esm/) builds via separate tsconfig.build.cjs.json and tsconfig.build.esm.json configs
  • publishConfig uses conditional exports with types/import/require conditions
  • Nested package.json files ({"type":"commonjs"} / {"type":"module"}) are generated in each output dir for proper Node.js resolution
  • Added typesVersions to @morpho-org/test for subpath export resolution under node10 module resolution

Test plan

  • pnpm -r build passes for all 13 packages
  • CJS output verified ("use strict"; var __createBinding = ...)
  • ESM output verified (export * from ...)
  • Nested package.json files generated correctly
  • pnpm -r test passes

Fixes SDK-91

🤖 Generated with Claude Code

Each package now emits both CommonJS and ESM builds via separate
tsconfig configs, with conditional exports in publishConfig so
consumers can require() or import any package.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Rubilmax Rubilmax self-assigned this Feb 25, 2026
@Rubilmax Rubilmax marked this pull request as ready for review February 25, 2026 15:51
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e1b88a3acf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link
Contributor

@cashd cashd left a comment

Choose a reason for hiding this comment

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

thank you! I would also explore using sideEffects: false in the package.json files. This will help inform bundlers to tree-shake more effectively.

@linear
Copy link

linear bot commented Mar 3, 2026

Switch ESM build configs from module "ESNext" + moduleResolution
"bundler" to module "NodeNext" + moduleResolution "NodeNext" to
ensure relative imports require .js extensions (required by Node's
ESM loader). Add "type": "module" to all packages, fix ~240
extensionless relative imports, fix graphql-tag default import to
named import, and add JSON import attributes where needed.

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

Rubilmax commented Mar 3, 2026

@codex

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@Rubilmax
Copy link
Collaborator Author

Rubilmax commented Mar 3, 2026

@codex

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Rubilmax Rubilmax merged commit 8ddffc0 into main Mar 3, 2026
16 checks passed
@Rubilmax Rubilmax deleted the Rubilmax/cjs-esm-compat branch March 3, 2026 13:23
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.

4 participants