Skip to content

Development Workflow

Requirements

  • Node.js 20+
  • pnpm 10+ (see package.json)
bash
pnpm install

Scripts

CommandDescription
pnpm testRun Vitest (test/emitter.test.ts) with coverage output.
pnpm lintESLint with auto-fix for src/.
pnpm buildBuild ESM + IIFE bundles and .d.ts files.
pnpm docs:dev / docs:buildWork on or build the VitePress docs.
pnpm releaseRuns tests, builds, and updates the changelog via changelogen.

Workflow

  1. pnpm test --watch when touching src/index.ts to catch regressions around listener bookkeeping.
  2. Update docs (README.md, docs/) in the same PR to keep API guidance current.
  3. pnpm build before publishing to ensure bundles + types remain valid.
  4. pnpm docs:build if you edited docs to catch MD/TSX issues.

Coverage & debugging

  • Vitest coverage lives in coverage/. Open coverage/index.html to inspect missing branches.
  • Use vitest --runInBand when debugging race conditions or synchronous edge cases.
  • Add temporary logs around emit/off while debugging; remove before committing.

Contributing tips

  • Preserve the typed tuple contract when adding features. Breaking it is a major version change.
  • Expand the test suite with scenarios such as nested emits, listener removal during dispatch, etc.
  • Document behavior changes in CHANGELOG.md and highlight them in the README.

Built with VitePress – Released under the MIT License.