Skip to content

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

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 several distinct values, so require("@cldmv/holdmytask") returns the module object instead of the HoldMyTask class. That's a breaking change for CommonJS callers.

Migration:

  • new (require(x))() becomes new (require(x).HoldMyTask)(), or const { HoldMyTask } = require(x); any static read off the class goes through .HoldMyTask
  • the 7 existing names (HoldMyTask, Queue, QueueManager, TaskManager, TaskProcessor, TaskQueue, queue) keep working
  • createHoldMyTask, createQueue, createTaskManager, createTaskProcessor and default are newly available from require()

Resolves #115

src/index.cjs is now the generic CLDMV shim: it returns what import gives, and since holdmytask exports several distinct values, that is the module object. The CJS test pins the new shape and the README's CommonJS usage is updated.

Migration:
- require("@cldmv/holdmytask") now returns the module object, not the HoldMyTask class
- new (require(x))() becomes new (require(x).HoldMyTask)() (or const { HoldMyTask } = require(x)), and any static read off the class goes through .HoldMyTask
- the 7 existing names (HoldMyTask, Queue, QueueManager, TaskManager, TaskProcessor, TaskQueue, queue) keep working
- createHoldMyTask, createQueue, createTaskManager, createTaskProcessor and default are newly available from require()

Resolves #115

BREAKING CHANGE: require("@cldmv/holdmytask") returns the module object instead of the HoldMyTask class.
@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 515a97a into next Nov 28, 2026
37 checks passed
@cldmv-bot
cldmv-bot Bot deleted the feat/generic-cjs-shim branch November 28, 2026 07:11
cldmv-bot Bot added a commit that referenced this pull request Nov 29, 2026
# `@cldmv/holdmytask` 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/holdmytask")` now returns the module object, the same exports `import` gives, instead of the `HoldMyTask` class with the aliases attached as properties.

This is the only breaking change, and it only affects code that uses `require()` and treats the result as the class. ESM `import` is unchanged, and so is the queue itself.

---

## 💥 Breaking Changes

### `require("@cldmv/holdmytask")` returns the module object ([#116](#116), fixes [#115](#115))

The ESM entry exports several distinct values: the `HoldMyTask` class (also exported as `default`, `queue`, `Queue`, `TaskManager`, `TaskQueue`, `QueueManager` and `TaskProcessor`) and the four `create*` factories. With more than one distinct value, the shim hands back the module object:

```javascript
const holdmytask = require("@cldmv/holdmytask");
// => { default, HoldMyTask, queue, Queue, TaskManager, TaskQueue, QueueManager, TaskProcessor,
//      createHoldMyTask, createQueue, createTaskManager, createTaskProcessor }

const { HoldMyTask } = require("@cldmv/holdmytask");
const queue = new HoldMyTask();
```

- `new (require(x))()` becomes `new (require(x).HoldMyTask)()`, or `const { HoldMyTask } = require(x)`.
- Anything read off the class through the result, such as `require(x).someStatic`, goes through `.HoldMyTask`.
- `require(x).HoldMyTask`, `.queue`, `.Queue`, `.TaskManager`, `.TaskQueue`, `.QueueManager` and `.TaskProcessor` keep working, and destructuring them works as before.
- `require(x).default`, `createHoldMyTask`, `createQueue`, `createTaskManager` and `createTaskProcessor` are newly available.

`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 CommonJS entry test expects the module object and checks that every export matches the ESM entry.

---

## 🔧 CI & tooling

- `ci.yml` adopts the CLDMV/.github v4.46.0 concurrency block, so superseded runs on `next`, `hotfixes` and the release PRs are cancelled ([#117](#117), fixes [#114](#114)).
- `ci.yml` is synced with the v4.43.0 template, so the release PR no longer reruns the matrix on a commit its push run already tested ([#112](#112)).
- The `sync-release-notes.yml` companion workflow is added ([#110](#110)).
- `dist/` is now built one file per module instead of bundled with tsup: esbuild minifies each `src/**/*.mjs` file in place (`bundle: false`, names kept, source maps written next to the output), so `dist/` mirrors `src/` and shares code through plain relative imports. `dist/index.mjs` imports `dist/hold-my-task.mjs` and `dist/utils.mjs`, and the deprecated `dist/main.mjs` alias re-exports `dist/index.mjs`. The exports map is unchanged, and `require()`, `import` and `@cldmv/holdmytask/main` resolve to the same values as before; the published tarball now holds a few more, smaller files under `dist/`, still without source maps ([#119](#119), fixes [#113](#113)).
- New `test:dist` script builds the package and runs the vitest suite against `dist/`, and `npm test` now includes it ([#103](#103)).

## 📚 Documentation

- **NEW:** [docs/changelog/v3/v3.0.0.md](https://github.com/CLDMV/holdmytask/blob/v3.0.0/docs/changelog/v3/v3.0.0.md): this changelog.
- README: the CommonJS example shows the module object, and the testing section lists `test:dist`.
- README What's New promoted to v3.0.0.

## 🔧 Dependencies

- The CLDMV dev tools move together: `@cldmv/vitest-runner` 1.5.6 → 1.11.4, `@cldmv/configs` 1.4.0 → 1.5.0 and `@cldmv/fix-headers` 2.2.4 → 2.6.1, with `@html-eslint/eslint-plugin` and `@html-eslint/parser` 0.67 → 0.69. File headers are restamped (`@Filename` no longer has a leading slash) and `.github/dependabot.yml` is synced to the CLDMV/.github v4.47.0 groups ([#120](#120)). This supersedes the earlier `@cldmv/fix-headers` 2.2.6 bump ([#106](#106)).
- `vitest`, `@vitest/coverage-v8` and `@vitest/ui` resolve to 5.1.x in the lockfile ([#105](#105)).
- `tsup` is replaced by `esbuild` ^0.28.2 as the build tool ([#119](#119)).
- All of the above are development only; the package still has no runtime dependencies.

---

## Upgrade notes

- `require("@cldmv/holdmytask")` no longer returns the `HoldMyTask` class. Use `const { HoldMyTask } = require("@cldmv/holdmytask")`, and read anything class-level through `HoldMyTask`.
- The existing alias names work as before; `default` and the `create*` factories are new.
- ESM `import` is unchanged.



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

- @Shinrai

</details>

---

<!-- coverage-start -->

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

| Metric | Coverage |
|--------|----------|
| Statements | 80.8% |
| Branches   | 75.4% |
| Functions  | 73.4% |
| Lines      | 81.9% |

*Avg: **77.8%** · `9cb475d` · 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