Skip to content

fix: remove bun export condition#29

Merged
cnbailian merged 4 commits intomainfrom
cnbailian/fix-loader-node-modules
Mar 6, 2026
Merged

fix: remove bun export condition#29
cnbailian merged 4 commits intomainfrom
cnbailian/fix-loader-node-modules

Conversation

@cnbailian
Copy link
Collaborator

Problem

When repterm is installed as an npm dependency and users run bun run repterm --record . with a setup.ts file containing beforeAll(), the CLI fails with: beforeAll must be called inside a describe() block

This is caused by the dual-module-instance hazard: the "bun": "./src/index.ts" export condition causes the CLI (running from dist/cli/index.js) and user code imports to resolve to different module instances, each with their own TestRegistry singleton.

Solution

Remove the "bun" export condition from all packages, ensuring both CLI and user code always resolve to the same dist/ module. This follows the proven pattern used by Playwright and other major test frameworks, eliminating the problem at its source.

Changes

  • Remove "bun": "./src/index.ts" from exports in packages/repterm, packages/plugin-api, and packages/plugin-kubectl
  • Remove "src" from files array (no longer needed since bun condition is gone)

All 290 tests pass without modification.

cnbailian and others added 4 commits March 6, 2026 11:29
When repterm is installed as an npm dependency, the "bun" export condition
causes CLI (from dist/) and user test code (from src/) to use different
TestRegistry instances, resulting in "beforeAll must be called inside a
describe() block" errors. Removing the "bun" condition ensures both resolve
to the same dist/ module. This follows the Playwright pattern and is the
standard approach for CLI tools.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Without the "bun" export condition, workspace packages resolve to dist/
instead of src/. The test job needs to build packages first so dist/
exists when tests import from workspace dependencies like repterm-api.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cnbailian cnbailian merged commit 2764ddb into main Mar 6, 2026
14 checks passed
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

🎉 This PR is included in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant