Skip to content

Export all library subpaths with dual ESM/CJS support#924

Merged
chuckdries merged 5 commits into
mainfrom
rory-export-all-subpaths
Jun 26, 2026
Merged

Export all library subpaths with dual ESM/CJS support#924
chuckdries merged 5 commits into
mainfrom
rory-export-all-subpaths

Conversation

@roryabraham

Copy link
Copy Markdown
Contributor

Export every compiled module through package.json exports with dual ESM/CJS support. Consumers can import expensify-common/Device, expensify-common/utils, etc. without the dist/ prefix, while existing expensify-common/dist/* paths keep working. The barrel also re-exports utils helpers for top-level imports.

Fixed Issues

For Expensify/App#93222

Tests

  1. What unit/integration tests cover your change? What autoQA tests cover your change?
    • Expanded __tests__/package-exports-test.js covers barrel, CLI, Device, utils, nested components, and verifies every compiled entry has canonical + dist/-prefixed exports.
  2. What tests did you perform that validates your changed worked?
    1. Run npm run build and confirm it generates dist/esm/* plus the updated package.json exports map.
    2. Run npm test -- __tests__/package-exports-test.js and confirm all export-resolution tests pass.
    3. Run npm test and confirm the full suite passes.
    4. Verify require('expensify-common/Device'), require('expensify-common/dist/Device'), import('expensify-common/utils'), and import('expensify-common') all resolve in Node.

QA

  1. What does QA need to do to validate your changes?
    • N/A — package build/export change only.
  2. What areas to they need to test for regressions?
    • N/A

Compile the full lib tree to dist/esm, generate package.json exports for
every module (canonical and dist-prefixed paths), and export utils from the
barrel so consumers can import subpaths without bundler aliases.

Co-authored-by: Cursor <cursoragent@cursor.com>
roryabraham and others added 4 commits June 26, 2026 11:26
Only expose canonical subpaths like expensify-common/API; consumers
should not rely on expensify-common/dist/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
No current consumer loads dist/esm via native Node resolution in a way
that needs extension patching; bundlers and CJS paths cover App and
GitHub-Actions usage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add required JSDoc @param tags and include scripts/ in npm run lint.

Co-authored-by: Cursor <cursoragent@cursor.com>
@roryabraham roryabraham requested a review from chuckdries June 26, 2026 18:42
@roryabraham roryabraham marked this pull request as ready for review June 26, 2026 18:42
@roryabraham roryabraham requested a review from a team as a code owner June 26, 2026 18:42
@melvin-bot melvin-bot Bot removed the request for review from a team June 26, 2026 18:42
@chuckdries chuckdries merged commit 0956849 into main Jun 26, 2026
8 checks passed
@chuckdries chuckdries deleted the rory-export-all-subpaths branch June 26, 2026 21:35
@os-botify

os-botify Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🚀 Published to npm in 2.0.189 🎉

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