Skip to content

fix(cjs): require the ESM entry directly and fail clearly on Node without require(esm) - #39

Merged
Shinrai merged 2 commits into
nextfrom
fix/cjs-require-esm-check
Oct 3, 2026
Merged

Shinrai merged 2 commits into
nextfrom
fix/cjs-require-esm-check

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

No other changes

👥 Contributors

…hout require(esm)

index.cjs used createRequire(__filename) to synchronously load index.mjs. That
idiom predates Node's native require(esm) and breaks bundlers (esbuild,
webpack) that don't follow a createRequire-constructed require the way they
follow a literal require() call.

- index.cjs: a plain require("./index.mjs") instead of createRequire. Where
  Node.js has no require(esm) (before 20.19 / 22.12) it now throws
  ERR_REQUIRE_ESM with a message pointing to import() instead of a bare
  loader error.
- index.mjs already had no top-level await, so no change was needed there.
- tests/cjs: node:test checks run by `npm test` and `npm run coverage` after
  Vitest: require() returns the same objects as import (type/identity only -
  createRemote opens a real ADB connection, so no call is made), and the
  version check fires when require(esm) is off.
@cldmv-bot cldmv-bot Bot added ! fix → next v4 flow: fix contributor PR targeting the next integration branch area: tests Touches test files, fixtures, or test infrastructure type: dependencies Relates to dependency updates, version bumps, or package management labels Oct 3, 2026
index.mjs exports createAndroidTVRemote, but index.cjs only exposed the
default (createRemote), so require() callers could not reach it. The CJS
entry now carries every export the ESM entry has, and the CJS test checks it.
@Shinrai
Shinrai enabled auto-merge October 3, 2026 18:26
@Shinrai
Shinrai merged commit e4cbbcc into next Oct 3, 2026
28 checks passed
@cldmv-bot
cldmv-bot Bot deleted the fix/cjs-require-esm-check branch October 3, 2026 18:26
cldmv-bot Bot added a commit that referenced this pull request Oct 3, 2026
## 🚀 What's Changed

### 💥 Breaking Changes
_No breaking changes_

### ✨ Features
_No new features_

### 🐛 Bug Fixes
- #39
  - fix(cjs): re-export createAndroidTVRemote from the CommonJS entry (26d3356)
  - fix(cjs): require the ESM entry directly and fail clearly on Node without require(esm) (e5b0a75)

### 📦 Dependencies
_No dependency updates_

### 🔧 Other Changes
_No other changes_



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-13.7%25-red?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 12.7% |
| Branches   | 9.1% |
| Functions  | 20.2% |
| Lines      | 13.0% |

*Avg: **13.7%** · `5ae55df` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Shinrai added a commit that referenced this pull request Nov 8, 2026
## 🚀 What's Changed

### 💥 Breaking Changes
_No breaking changes_

### ✨ Features
_No new features_

### 🐛 Bug Fixes
- #39
  - fix(cjs): re-export createAndroidTVRemote from the CommonJS entry (26d3356)
  - fix(cjs): require the ESM entry directly and fail clearly on Node without require(esm) (e5b0a75)

### 📦 Dependencies
_No dependency updates_

### 🔧 Other Changes
_No other changes_



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-13.7%25-red?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 12.7% |
| Branches   | 9.1% |
| Functions  | 20.2% |
| Lines      | 13.0% |

*Avg: **13.7%** · `5ae55df` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Touches test files, fixtures, or test infrastructure ! fix → next v4 flow: fix contributor PR targeting the next integration branch type: dependencies Relates to dependency updates, version bumps, or package management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant