Skip to content

Modernize Javascript and tool chain#5

Merged
sderrow merged 6 commits into
masterfrom
modernize
May 9, 2026
Merged

Modernize Javascript and tool chain#5
sderrow merged 6 commits into
masterfrom
modernize

Conversation

@sderrow
Copy link
Copy Markdown
Owner

@sderrow sderrow commented Apr 25, 2025

Why

The upstream bottleneck library is no longer maintained, and its CoffeeScript source + ES5-targeted toolchain are increasingly out of step with the modern Node.js ecosystem. This PR rewrites the codebase and tooling so the fork can be a long-lived, easier-to-contribute-to home for further work (eventually a native TypeScript port).

What changes

This is a large diff but most of it is mechanical (CoffeeScript → JS, test renames, toolchain swaps). The runtime behavior is unchanged — same scheduling/limiting semantics, same job lifecycle, same events. The API surface does change in a few intentional v4 ways (see Breaking changes below), mostly around how Redis clients are wired in and the removal of the ES5 build.

Source modernization

  • Converted all CoffeeScript sources under src/ to modern JS via decaffeinate, then committed the JS as the source of truth (CoffeeScript is removed from the repo and the build).
  • Reorganized Redis-only code under src/cluster/ (datastore, connections, Lua scripts, Scripts.js) so the local-only "light" build no longer needs to know about Redis. Public exports are unchanged.
  • Dropped support for the legacy redis v2/v3 client API; cluster mode now requires redis v4+ (and works with v5) or ioredis v5+.
  • Made ioredis and redis optional peer dependencies — the library no longer implicitly require()s a Redis client; consumers bring their own and pass a Redis constructor (or pre-built client/connection).

Toolchain

  • Migrated the build/package manager from npm + Babel + Rollup to pnpm + tsdown.
  • Added lint/format with oxc (oxlint, oxfmt) — the project previously had no lint or format tooling.
  • Replaced the legacy es5.js / light.js Rollup configs with a single tsdown.config.ts. The ES5 build is removed; the UMD @sderrow/bottleneck/light build remains for browser/non-Node consumers.
  • Added tsconfig.json, .oxlintrc.json, .oxfmtrc.json, .nvmrc, and a Husky + lint-staged pre-commit hook.
  • Replaced Travis with a GitHub Actions CI workflow (.github/workflows/ci.yaml) plus a reusable setup composite action.

Tests

  • Migrated the suite from Mocha-style files to Vitest with vitest.config.ts defining separate projects (local, ioredis, node-redis, light-smoke, memory).
  • Renamed test files to the *.test.js convention and split the monolithic cluster.js / general.js into focused files (cluster.test.js, cluster-coordination.test.js, general.test.js, general-traffic.test.js, etc.).
  • Extracted shared test scaffolding into test/helpers/ (limiter setup, call logging, job tracking, state waiting) and added Testcontainers-based Redis fixtures (global-setup-redis.ts) so cluster tests no longer depend on a manually-run Redis instance.
  • Added smoke and memory-leak suites under test/smoke/ and test/memory/.

Packaging

  • Bumped to 4.0.0-rc.0 and renamed the package to @sderrow/bottleneck.
  • New exports map exposes . and ./light with shared bottleneck.d.ts types; dist/ is the published build output.

Breaking changes (v4)

  • require("bottleneck/es5") is gone — use @sderrow/bottleneck/light if you need a UMD build.
  • Cluster mode requires redis v4+ or ioredis v5+.
  • ioredis / redis must be installed by the consumer (peer deps).
  • The Redis constructor option is required when datastore is "redis" / "ioredis" unless you pass a pre-built client or connection.
  • Internal Redis modules moved to src/cluster/ (only matters if you imported from internal paths).

Follow-ups (out of scope)

  • Native TypeScript rewrite of src/.

@sderrow sderrow force-pushed the modernize branch 2 times, most recently from b682005 to ff2571f Compare April 25, 2025 06:00
@sderrow sderrow marked this pull request as ready for review April 25, 2025 06:00
@sderrow sderrow force-pushed the modernize branch 5 times, most recently from 6eeabf5 to 11a1b3b Compare April 25, 2025 14:44
Copy link
Copy Markdown
Owner Author

sderrow commented Apr 25, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sderrow sderrow mentioned this pull request Apr 25, 2025
@sderrow sderrow changed the base branch from improve-types to graphite-base/5 April 25, 2025 15:41
@sderrow sderrow changed the base branch from graphite-base/5 to master April 25, 2025 15:42
@sderrow sderrow marked this pull request as draft April 25, 2025 19:12
@sderrow sderrow force-pushed the modernize branch 4 times, most recently from 271c3c7 to dd6a959 Compare April 26, 2025 05:22
@sderrow sderrow marked this pull request as ready for review April 26, 2025 06:01
@sderrow sderrow changed the base branch from master to graphite-base/5 April 27, 2025 17:53
@sderrow sderrow changed the base branch from graphite-base/5 to update-package April 27, 2025 17:53
@sderrow sderrow changed the base branch from update-package to graphite-base/5 April 27, 2025 19:06
@sderrow sderrow changed the base branch from graphite-base/5 to master April 27, 2025 19:06
@sderrow sderrow force-pushed the modernize branch 3 times, most recently from 27214fa to 8e07a06 Compare April 28, 2025 22:32
@sderrow sderrow force-pushed the modernize branch 6 times, most recently from 0b13a09 to 9732607 Compare May 9, 2026 06:27
@sderrow sderrow merged commit d4f3339 into master May 9, 2026
2 checks passed
@sderrow sderrow deleted the modernize branch May 9, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant