Skip to content

Conversation

@ntucker
Copy link
Collaborator

@ntucker ntucker commented Jan 6, 2026

Motivation

Jest (and other CommonJS consumers) fail when importing @data-client/test because the /mock subpath exports in @data-client/react and @data-client/core only had ESM builds. When Jest tries to require('@data-client/react/mock'), it resolves to the ESM file which uses export * syntax, causing:

SyntaxError: Unexpected token 'export'

Solution

Add CommonJS builds for the /mock subpath exports in both packages:

  1. @data-client/core: Added src/mock/index.ts to rollup CJS build, outputs dist/mock.js
  2. @data-client/react: Added src/mock/index.ts to rollup CJS build, outputs dist/mock.js
  3. Updated package.json exports in both packages to include "require" condition pointing to the new CJS bundles

Changes

Package File Change
@data-client/core rollup.config.mjs Added mock entry to CJS build
@data-client/core package.json Added require condition to ./mock export
@data-client/react rollup.config.mjs Added mock entry to CJS build
@data-client/react package.json Added require condition to ./mock export

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2026

🦋 Changeset detected

Latest commit: 2713177

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

This PR includes changesets to release 6 packages
Name Type
@data-client/core Patch
@data-client/react Patch
@data-client/vue Patch
example-benchmark Patch
test-bundlesize Patch
coinbase-lite 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

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.12%. Comparing base (4296d32) to head (2713177).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3691   +/-   ##
=======================================
  Coverage   98.12%   98.12%           
=======================================
  Files         150      150           
  Lines        2715     2715           
  Branches      536      536           
=======================================
  Hits         2664     2664           
  Misses         11       11           
  Partials       40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ntucker ntucker marked this pull request as ready for review January 6, 2026 04:54
@ntucker ntucker merged commit bf3ac79 into master Jan 6, 2026
22 checks passed
@ntucker ntucker deleted the fix-jest-mocks branch January 6, 2026 04:54
@github-actions github-actions bot mentioned this pull request Jan 6, 2026
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.

2 participants