Skip to content

fix: resolve dinero.js factory regardless of CJS/ESM resolution - #299

Merged
anttiviljami merged 4 commits into
mainfrom
fix/bundle-dinero-cjs-interop
Oct 21, 2026
Merged

anttiviljami merged 4 commits into
mainfrom
fix/bundle-dinero-cjs-interop

Conversation

@anttiviljami

@anttiviljami anttiviljami commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Keep dinero.js external (unchanged build config).
  • Add src/money/dinero.ts, which unwraps nested default exports to find the dinero factory. formatters.ts and to-dinero.ts use it.
  • Fixes TypeError: (0, x.default) is not a function when a consumer bundles this package's CJS entry with mainFields: ['module','main'] (e.g. esbuild for Lambdas): require('dinero.js') resolves to the ESM build and the default import becomes the module namespace.

Test plan

  • src/bundle-interop.test.ts re-bundles the CJS and ESM entries with mainFields: ['module','main'] and calls formatAmount; it fails without the helper
  • Full suite passes (638 tests), tsc clean

🤖 Generated with Claude Code

…mers

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f5edc13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@epilot/pricing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T07:06:04.813916Z 990308a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 990308a351

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread esbuild.config.js Outdated
// build (`module`). When this package's CJS entry `require('dinero.js')` is itself bundled by a
// consumer using `mainFields: ['module', 'main']` (e.g. esbuild for Lambdas), the ESM build is
// picked and `.default` becomes the module namespace -> "TypeError: (0, x.default) is not a function".
const bundledDeps = new Set(['dinero.js']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add a patch changeset for this fix

This publishable bundle change has no corresponding file under .changeset/ (the commit tree contains only the Changesets README and config). Because .github/workflows/ci-cd.yml releases exclusively through changesets/action, merging this commit leaves the package at version 5.9.0 and does not create a release PR or publish the fix, so affected consumers remain broken until an unrelated changeset eventually triggers a release. Add a patch changeset for @epilot/pricing.

Useful? React with 👍 / 👎.

Keep dinero.js external; unwrap nested default exports so consumers bundling with mainFields module,main no longer hit '(0, x.default) is not a function'.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@anttiviljami anttiviljami changed the title fix: bundle dinero.js to avoid default-export interop error in consumer bundles fix: resolve dinero.js factory regardless of CJS/ESM resolution Oct 21, 2026
anttiviljami and others added 2 commits October 21, 2026 07:11
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@anttiviljami
anttiviljami merged commit e1be1d0 into main Oct 21, 2026
3 checks passed
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.

1 participant