Skip to content

fix!: make HoldMyTask and its constructor aliases real classes - #11

Merged
Shinrai merged 4 commits into
nextfrom
fix/constructor-aliases-issue-3
Aug 8, 2026
Merged

fix!: make HoldMyTask and its constructor aliases real classes#11
Shinrai merged 4 commits into
nextfrom
fix/constructor-aliases-issue-3

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

✨ Features

No new features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

👥 Contributors

index.mjs exported HoldMyTask, Queue, TaskManager, TaskQueue, QueueManager,
and TaskProcessor as async factory functions (createHoldMyTask() and
friends) rather than the actual HoldMyTask class, so `new QueueManager()`
etc. threw "QueueManager is not a constructor" - the entire
CommonAliases.test.vitest.mjs suite (35/36 tests) was failing and had been
worked around by skipping the whole file rather than fixed (#3).

index.cjs already assumed the ESM HoldMyTask export was the real class
(`module.exports = HoldMyTask`), and every README/example already used
`new HoldMyTask(...)` - the async-factory pattern was the actual bug, not
the tests or the CJS bridge.

Switches index.mjs to a static top-level import of the real HoldMyTask
class from @cldmv/holdmytask/main and re-exports it (and its aliases)
directly. The createHoldMyTask/createQueue/createTaskManager/
createTaskProcessor async factory functions are kept as-is for backward
compatibility, just simplified to use the now-eagerly-loaded class instead
of a fresh dynamic import per call.

Un-skips CommonAliases.test.vitest.mjs (all 36 tests now pass) and
regenerates types/index.d.mts via `npm run build:types` to match the new
export shapes.
@cldmv-bot cldmv-bot Bot added the ! fix → next v4 flow: fix contributor PR targeting the next integration branch label Aug 7, 2026
@Shinrai

Shinrai commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Resolves #3 — closed when this ships to the default branch.

@cldmv-bot cldmv-bot Bot added the area: tests Touches test files, fixtures, or test infrastructure label Aug 7, 2026
@Shinrai
Shinrai requested a lite review from Copilot August 7, 2026 23:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the package entrypoints and type declarations so HoldMyTask and the common aliases (Queue, TaskManager, etc.) are exported as real constructors (classes), aligning runtime behavior with the documented “new Queue()”-style usage and re-enabling the previously skipped alias-compatibility test suite.

Changes:

  • Update index.mjs exports to make HoldMyTask (and alias names) refer to the underlying class instead of async factory functions.
  • Update types/index.d.mts to export HoldMyTask as the default and as the constructor aliases.
  • Unskip alias/compatibility tests and adjust generated type output for the priority stress test example.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
index.mjs Switches exports so HoldMyTask + aliases are real class constructors; keeps async factory helpers.
tests/CommonAliases.test.vitest.mjs Re-enables tests that validate alias constructor behavior and method aliases.
types/index.d.mts Updates type exports to match the new runtime export surface (HoldMyTask as default + aliases).
types/index.d.mts.map Regenerated sourcemap corresponding to the updated types/index.d.mts.
types/examples/priority-stress-test.d.mts Updates generated type signature for the stress-test result shape.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread index.mjs
Comment thread types/index.d.mts Outdated
Comment thread types/examples/priority-stress-test.d.mts
Comment thread index.mjs
Shinrai added 2 commits August 7, 2026 18:11
…yTask

Addresses PR #11 review feedback: the factory functions' JSDoc @returns
was Promise<object>, losing the actual return type now that HoldMyTask is
statically imported and in scope. Regenerated types/index.d.mts via
`npm run build:types`.
Addresses PR #11 review feedback: the PR's auto-generated changelog
claimed "No breaking changes", but cbc1ac7 changed the default export
(and the HoldMyTask/Queue/TaskManager/TaskQueue/QueueManager/TaskProcessor
named aliases) from an async factory function to the real HoldMyTask
class. Code that previously called these as functions - e.g.
`await HoldMyTask()`, or `await (await import("@cldmv/holdmytask")).default()`
- now gets "Class constructor HoldMyTask cannot be invoked without 'new'"
and must switch to `new HoldMyTask()` / `new QueueManager()` etc. instead.

This matches the already-documented `new HoldMyTask(options)` usage
throughout README and every example, and the existing CJS bridge
(index.cjs), which already assumed the ESM default export was the class -
only the previously-buggy async-factory calling convention on these
specific export names is removed.

BREAKING CHANGE: HoldMyTask, Queue, TaskManager, TaskQueue, QueueManager,
TaskProcessor, and the package default export are now the real HoldMyTask
class instead of an async factory function. Use `new HoldMyTask(options)`
(or `new QueueManager(options)`, etc.) instead of calling them as
functions. The createHoldMyTask/createQueue/createTaskManager/
createTaskProcessor named async factory functions are unchanged.
@cldmv-bot cldmv-bot Bot changed the title fix: make HoldMyTask and its constructor aliases real classes fix!: make HoldMyTask and its constructor aliases real classes Aug 8, 2026
@cldmv-bot

cldmv-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Auto-normalized PR title: rewrote PR title to match the highest-priority commit type (fix).

  • Before: fix: make HoldMyTask and its constructor aliases real classes
  • After: fix!: make HoldMyTask and its constructor aliases real classes

If this isn't what you want, edit the title — the normalizer won't re-fire as long as the title stays conventional.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

index.mjs:23

  • The header comment says the devcheck “must happen before holdmytask imports”, but this module now has a static ESM import of @cldmv/holdmytask/main. Since ESM imports are evaluated before the module body, that ordering guarantee isn’t true and the comment is misleading for future maintainers.
import { HoldMyTask } from "@cldmv/holdmytask/main";

Addresses the suppressed Copilot comment on PR #11 (index.mjs:23): the comment
claimed the devcheck "must happen before holdmytask imports", but the static
`import` of the core is hoisted and evaluated before the devcheck IIFE runs, so
that ordering isn't real. Reworded to state devcheck is a best-effort,
fire-and-forget dev-time warning that does NOT run before the core loads, and
why (running it strictly first needs top-level await, which breaks index.cjs's
synchronous require). Regenerated the types sourcemap (source positions shifted;
the .d.ts itself is unchanged).
@Shinrai

Shinrai commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Addressing the suppressed comment from the 2026-08-08 review (index.mjs:23 — the "must happen before holdmytask imports" comment is misleading now that the core is a static import):

Fixed in 1a2b6f3. Reworded the comment to state the truth: the static import of the core is hoisted and evaluated before the devcheck IIFE, so devcheck is a best-effort, fire-and-forget dev-time warning that does not run before the core loads — and noted why running it strictly first isn't done (it'd need top-level await, which breaks index.cjs's synchronous require).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

@Shinrai
Shinrai merged commit 979ea9c into next Aug 8, 2026
25 checks passed
@cldmv-bot
cldmv-bot Bot deleted the fix/constructor-aliases-issue-3 branch August 9, 2026 00:00
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants