Skip to content

fix: register tsx's ESM loader only so mocha 12.0.1 can load find-up@8 - #157

Merged
finalerock44 merged 1 commit into
devfrom
fix/mocha-tsx-esm-loader
Sep 14, 2026
Merged

finalerock44 merged 1 commit into
devfrom
fix/mocha-tsx-esm-loader

Conversation

@finalerock44

@finalerock44 finalerock44 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Bare tsx also patches the CJS resolver, which turns an ESM dependency's import into a require. Mocha 12.0.1 bumped find-up 5 -> 8 (ESM-only), whose unicorn-magic dependency exports nothing under the require condition, so the suite died with ERR_PACKAGE_PATH_NOT_EXPORTED before running a test. tsx/esm registers just the ESM loader and leaves the require(esm) path to Node.

What & why

Type of change

  • fix — bug fix
  • feat — new feature
  • perf — performance improvement
  • refactor — code change that's neither a fix nor a feature
  • docs — documentation only
  • chore / ci / build / test — tooling, no user-facing change
  • Breaking change (title has ! or PR notes a BREAKING CHANGE:)

Checklist

  • PR title follows the Conventional Commits format (see comment above)
  • pnpm lint passes
  • pnpm typecheck passes
  • pnpm build passes
  • I have not bumped the version or edited CHANGELOG.md (release-please handles this)
  • I have signed the CLA (the bot will prompt on first contribution)
  • Docs / README.md / STYLE_GUIDE.md updated if behaviour or output changed

How to test

Bare `tsx` also patches the CJS resolver, which turns an ESM dependency's
`import` into a `require`. Mocha 12.0.1 bumped find-up 5 -> 8 (ESM-only),
whose unicorn-magic dependency exports nothing under the `require`
condition, so the suite died with ERR_PACKAGE_PATH_NOT_EXPORTED before
running a test. `tsx/esm` registers just the ESM loader and leaves the
require(esm) path to Node.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@finalerock44 finalerock44 self-assigned this Sep 14, 2026
@claude

claude Bot commented Sep 14, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@finalerock44
finalerock44 merged commit 004b478 into dev Sep 14, 2026
15 checks passed
@finalerock44
finalerock44 deleted the fix/mocha-tsx-esm-loader branch September 14, 2026 16:42
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