Skip to content

feat!: switch the CJS entry to the generic shim - #121

Merged
Shinrai merged 1 commit into
nextfrom
feat/generic-cjs-shim
Nov 28, 2026
Merged

Shinrai merged 1 commit into
nextfrom
feat/generic-cjs-shim

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

src/index.cjs is now the generic CLDMV shim. The ESM entry exports two distinct values, so require("@cldmv/node-android-tv-remote") returns the module object instead of the createRemote function, and the CommonJS-only create alias is gone. That's a breaking change for CommonJS callers.

Migration:

  • require(x)(…) becomes require(x).createRemote(…)
  • require(x).create(…) becomes require(x).createRemote(…)
  • .createRemote, .createAndroidTVRemote, .default and destructuring of them keep working

Resolves #120

src/index.cjs is now the generic CLDMV shim: after the Node version guard it returns the single exported value, or the module object when the ESM entry exports more than one distinct value. Here that is the module object. The CJS tests and the README CommonJS usage match the new shape.

Migration:
- require("@cldmv/node-android-tv-remote") now returns the module object, not the createRemote function.
- require(x)(…) becomes require(x).createRemote(…).
- require(x).create(…) becomes require(x).createRemote(…) (the CJS-only create alias is gone).
- .createRemote, .createAndroidTVRemote, .default and destructuring of them keep working.

BREAKING CHANGE: require("@cldmv/node-android-tv-remote") returns the module object instead of the createRemote function, and the CJS-only create alias is removed.

Resolves #120
@cldmv-bot cldmv-bot Bot added ! feature → next v4 flow: contributor PR targeting the next integration branch area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure type: documentation Relates to docs, README updates, guides, or inline code comments labels Nov 28, 2026
@Shinrai
Shinrai merged commit 7bf6a84 into next Nov 28, 2026
37 checks passed
@cldmv-bot
cldmv-bot Bot deleted the feat/generic-cjs-shim branch November 28, 2026 05:56
cldmv-bot Bot added a commit that referenced this pull request Nov 29, 2026
# `@cldmv/node-android-tv-remote` v3.0.0 Changelog

**Release Date**: November 2026
**Release Type**: Major
**Branch**: `release/3.0.0`

---

## Overview

v3.0.0 switches the CommonJS entry to the generic `index.cjs` shim used across the CLDMV libraries. `require("@cldmv/node-android-tv-remote")` now returns the module object, the same exports `import` gives, instead of the `createRemote` function with properties attached.

This is the only breaking change, and it only affects code that uses `require()` and calls the result directly. ESM `import` is unchanged, and so is every remote method. The release also moves the build from a single tsup bundle to one minified file per module in `dist/`, and bumps the CLDMV dev tools; neither changes what `import` or `require()` return.

---

## 💥 Breaking Changes

### `require("@cldmv/node-android-tv-remote")` returns the module object ([#121](#121), fixes [#120](#120))

The ESM entry exports two distinct values, `createRemote` (also exported as `default`) and `createAndroidTVRemote`, so the shim hands back the module object:

```javascript
const remote = require("@cldmv/node-android-tv-remote");
// => { __esModule, default: createRemote, createRemote, createAndroidTVRemote }

const { createRemote } = require("@cldmv/node-android-tv-remote");
const device = await createRemote({ ip: "192.168.1.100" });
```

- `require(x)({ ip })` becomes `require(x).createRemote({ ip })`, or `const { createRemote } = require(x)`.
- `require(x).createRemote`, `require(x).createAndroidTVRemote`, `require(x).default` and destructuring keep working.
- `__esModule` is newly present on the result, and the result is no longer callable.

`src/index.cjs` is now the same small file as in other CLDMV libraries (Node version guard, then `require("./index.mjs")`), and the build still copies it unchanged to `dist/index.cjs`. The CJS test expects the module object and checks its keys. The README CommonJS example uses the destructured form.

---

## 🔧 CI & tooling

- `dist/` now mirrors `src/`, one minified file per module with `keepNames` and source maps, built with esbuild (`bundle: false`) instead of a single tsup bundle ([#124](#124), fixes [#118](#118)). The `import` and `require()` shapes and the exported subpaths are unchanged, and `src/index.cjs` is still copied verbatim to `dist/index.cjs`. The published tarball now holds several files under `dist/` instead of one, source maps are still left out, and `tsup` is replaced by `esbuild` in the dev dependencies.
- `ci.yml` is synced with the CLDMV/.github v4.43.0 template ([#112](#112)).
- `ci.yml` adopts the v4.46.0 concurrency block, so superseded runs on `next`, `hotfixes` and feature branches are cancelled and only pushes to the release branch keep a unique group per run ([#122](#122), fixes [#119](#119)).

## 📚 Documentation

- **NEW:** [docs/changelog/v3/v3.0.0.md](https://github.com/CLDMV/node-android-tv-remote/blob/v3.0.0/docs/changelog/v3/v3.0.0.md): this changelog.
- README: the CommonJS example uses `const { createRemote } = require(...)`.
- README: the build note describes the per-module esbuild output.
- README What's New promoted to v3.0.0.

## 🔧 Dependencies

- `vitest` 5.1.0 → 5.1.1 ([#114](#114))
- `@vitest/coverage-v8` 5.1.0 → 5.1.1 ([#115](#115))
- `@cldmv/vitest-runner` 1.6.1 → 1.8.0 ([#116](#116))

- The CLDMV dev tools: `@cldmv/vitest-runner` 1.8.0 → 1.11.4, `@cldmv/configs` 1.4.0 → 1.5.0 and `@cldmv/fix-headers` 2.2.7 → 2.6.1, plus `npm update` for the rest, with file headers restamped and `.github/dependabot.yml` synced to the CLDMV/.github v4.47.0 groups ([#123](#123))
- `tsup` removed and `esbuild` added for the per-module build ([#124](#124))

All of these are dev dependencies; no runtime dependencies changed.

---

## Upgrade notes

- `require("@cldmv/node-android-tv-remote")` is no longer callable. Use `const { createRemote } = require("@cldmv/node-android-tv-remote")`.
- `.createRemote`, `.createAndroidTVRemote`, `.default` and destructuring work as before.
- ESM `import` is unchanged.



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

- @Shinrai

</details>

---

<!-- coverage-start -->

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

| Metric | Coverage |
|--------|----------|
| Statements | 95.3% |
| Branches   | 85.3% |
| Functions  | 97.6% |
| Lines      | 95.4% |

*Avg: **93.4%** · `55cffdd` · 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: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure ! feature → next v4 flow: contributor PR targeting the next integration branch type: documentation Relates to docs, README updates, guides, or inline code comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant