Back to Fuse

Developing Fuse.js

DEVELOPERS.md

7.4.23.0 KB
Original Source

Developing Fuse.js

<a name="setup"></a> Setup

Building and releasing require Node >= 22.18 (the bundler, tsdown, needs it); nvm use picks up the pinned .nvmrc. The published library runs on far older Node, and the CI test matrix still includes Node 20.

shell
npm install

<a name="scripts"></a> Scripts

CommandDescription
npm run buildBuild all dist targets (CJS, ESM, minified, types)
npm testRun the test suite (vitest)
npm run typecheckType-check the source without emitting
npm run lintLint source and tests (eslint)
npm run devWatch mode (rebuilds all dist targets via tsdown)
npm run benchBuild, then run the core search + index regression benchmarks
npm run bench:searchSearch benchmark (object/string fuzzy, scaling, remove)
npm run bench:indexIndex creation benchmark across dataset sizes
npm run bench:extendedExtended search + logical query benchmark
npm run bench:tokensToken search vs Bitap A/B benchmark
npm run bench:workersSingle-thread vs parallel workers benchmark

<a name="structure"></a> Project Structure

Source is TypeScript. The build, including .d.ts emit, runs through tsdown (rolldown engine); see tsdown.config.ts.

src/
  core/         — Fuse class, config, scoring, query parser, formatting
  search/       — Bitap algorithm + extended search (operators, matchers)
  tools/        — FuseIndex, KeyStore, MaxHeap, field-length norm
  helpers/      — Utility functions (type guards, get, diacritics)
  types.ts      — Shared type definitions
  entry.ts      — Entry point with static methods and type exports
test/           — Tests and fixtures
bench/          — Benchmarks (search, index creation, extended, tokens, workers)
tsdown.config.ts — Build config (all dist targets + types)
scripts/        — Release + docs helpers (bump-docs, deploy-docs, release)
dist/           — Built output (CJS, ESM, .d.ts)

<a name="commits"></a> Git Commit Guidelines

Fuse.js follows conventional commits. Commit messages are used to generate the changelog.

Format

<type>(<scope>): <subject>

Types

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Formatting, missing semi-colons, etc.
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding or correcting tests
  • chore: Build process or auxiliary tools

Scope

The scope specifies the area of the change, e.g. search, index, options. Use * for changes affecting multiple scopes.

Subject

  • Imperative, present tense: "change" not "changed"
  • Don't capitalize the first letter
  • No period at the end