Skip to content

fix(pacer): only run devtools integration in development - #308

Open
schiller-manuel wants to merge 6 commits into
mainfrom
schiller-manuel-gate-devtools-in-production
Open

schiller-manuel wants to merge 6 commits into
mainfrom
schiller-manuel-gate-devtools-in-production

Conversation

@schiller-manuel

@schiller-manuel schiller-manuel commented Nov 12, 2026 •

Copy link
Copy Markdown

🎯 Changes

Since 0.5, @tanstack/devtools-event-client turns EventClient into a no-op unless process.env.NODE_ENV === 'development'. Pacer's own devtools code around it had no such check, so production builds still shipped and ran it:

  • On every state change of a keyed util, emitChange stored the instance in a module-level map that is never cleared, and deep-cloned its state and options with JSON.parse(JSON.stringify()) before passing them to the no-op emit.
  • Keyed utils subscribed to d-* events in their constructors.
  • pacerEventClient was created at module load from a subclass, so bundlers could not drop it or @tanstack/devtools-event-client.

This PR puts the same NODE_ENV === 'development' check in front of emitChange and the constructor subscriptions. It also creates pacerEventClient as a /* @__PURE__ */ new EventClient(...) without the subclass, because esbuild keeps an unused class extends. The guards check key first, so unkeyed utils in unbundled Node skip the process.env lookup.

Exports and development behaviour are unchanged. Events never reached devtools in production before this change, so the only production difference is that the registry and cloning no longer run.

Bundle of new Throttler(...).maybeExecute() with NODE_ENV=production and minification:

before after
esbuild 6619 B (2551 gzip) 5822 B (2217 gzip)
rolldown 6655 B (2516 gzip) 5842 B (2190 gzip)

After the change, neither bundle contains event client code.

I did not use @__NO_SIDE_EFFECTS__ on emitChange. Its return value is never used, so bundlers would remove every call, including in development. I checked this with rolldown: devtools stopped receiving updates.

A new event-client.test.ts covers both modes. The existing registry tests now stub NODE_ENV=development, because vitest runs with test.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Improvements
    • Devtools integration now runs only in development. In production, keyed utilities no longer register devtools listeners or emit devtools events, helping reduce production bundle size.
  • Documentation
    • Updated references to describe the development-only devtools behavior and the event client.

schiller-manuel and others added 2 commits November 12, 2026 12:52
…n tree-shake it

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7054b8d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@tanstack/pacer Patch
@tanstack/alpine-pacer Patch
@tanstack/angular-pacer Patch
@tanstack/ember-pacer Patch
@tanstack/lit-pacer Patch
@tanstack/octane-pacer Patch
@tanstack/preact-pacer Patch
@tanstack/react-pacer Patch
@tanstack/solid-pacer Patch
@tanstack/svelte-pacer Patch
@tanstack/vue-pacer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Keyed Pacer devtools listeners and event emission now require development mode. The event client uses a plain EventClient, and TypeScript documentation configurations include the ambient NODE_ENV declaration. Tests and reference documentation reflect these changes.

Changes: Development-only devtools

Layer / File(s) Summary
Declare NODE_ENV for package and docs builds
packages/pacer/src/process-env.d.ts, packages/*-pacer/tsconfig.docs.json
Adds an ambient type for process.env.NODE_ENV and includes it in the framework packages’ documentation TypeScript configurations.
Gate devtools registration and event emission
packages/pacer/src/*, packages/pacer/tests/*, docs/reference/functions/emitChange.md, docs/reference/variables/pacerEventClient.md, .changeset/pacer-gate-devtools-production.md
Keyed utility listeners and event emission require development mode. The event client is a plain EventClient configured with the Pacer plugin ID and reconnect interval. Tests check development and production behavior; references and the changeset describe the update.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: kevinvandy

Merge Risk: Minimal · up to 7054b

Devtools integration now runs only in development, and production skips the event-client work. No remaining merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Pacer's devtools integration now runs only in development. The change set gates emitChange, keyed-util subscriptions, and the pacerEventClient setup on NODE_ENV === 'd…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template. It has the Changes section, the Checklist, and the Release Impact section. The Changes section explains the problem and the fix. It names the affected …
Full details: Title check

Explanation

The title names the main change: Pacer's devtools integration now runs only in development. The change set gates emitChange, keyed-util subscriptions, and the pacerEventClient setup on NODE_ENV === 'development'. The title uses the conventional 'fix(pacer):' prefix and is concise. It does not mention the bundle-size or pure-annotation details, which is acceptable.

Full details: Description check

Explanation

The description follows the repository template. It has the Changes section, the Checklist, and the Release Impact section. The Changes section explains the problem and the fix. It names the affected code paths: emitChange, keyed-util constructor subscriptions, and pacerEventClient creation. It explains why the key check runs before the environment lookup. It reports bundle size results for esbuild and rolldown, and it explains why @__NO_SIDE_EFFECTS__ was not used. It states that exports and development behavior are unchanged. All three checklist items are ticked, and the Release Impact section marks the changeset item. The description does not mention the later tsconfig and process type changes listed in the commit summary, which affect docs builds and type-checking. Those changes are part of the PR but are not described in the author text.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 34d6213 and 7054b8d.

Files selected for processing: 31

  • .changeset/pacer-gate-devtools-production.md
  • docs/reference/functions/emitChange.md
  • docs/reference/variables/pacerEventClient.md
  • packages/alpine-pacer/tsconfig.docs.json
  • packages/angular-pacer/tsconfig.docs.json
  • packages/ember-pacer/tsconfig.docs.json
  • packages/lit-pacer/tsconfig.docs.json
  • packages/octane-pacer/tsconfig.docs.json
  • packages/pacer/src/async-batcher.ts
  • packages/pacer/src/async-debouncer.ts
  • packages/pacer/src/async-queuer.ts
  • packages/pacer/src/async-rate-limiter.ts
  • packages/pacer/src/async-throttler.ts
  • packages/pacer/src/batcher.ts
  • packages/pacer/src/debouncer.ts
  • packages/pacer/src/event-client.ts
  • packages/pacer/src/process-env.d.ts
  • packages/pacer/src/queuer.ts
  • packages/pacer/src/rate-limiter.ts
  • packages/pacer/src/throttler.ts
  • packages/pacer/tests/async-debouncer.test.ts
  • packages/pacer/tests/async-queuer.test.ts
  • packages/pacer/tests/async-rate-limiter.test.ts
  • packages/pacer/tests/async-retryer.test.ts
  • packages/pacer/tests/async-throttler.test.ts
  • packages/pacer/tests/event-client.test.ts
  • packages/preact-pacer/tsconfig.docs.json
  • packages/react-pacer/tsconfig.docs.json
  • packages/solid-pacer/tsconfig.docs.json
  • packages/svelte-pacer/tsconfig.docs.json
  • packages/vue-pacer/tsconfig.docs.json

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 10 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/pacer 0.23.1 → 0.23.2 Changeset
@tanstack/alpine-pacer 0.2.0 → 0.2.1 Dependent
@tanstack/angular-pacer 0.27.0 → 0.27.1 Dependent
@tanstack/ember-pacer 0.2.0 → 0.2.1 Dependent
@tanstack/lit-pacer 0.2.0 → 0.2.1 Dependent
@tanstack/octane-pacer 0.3.0 → 0.3.1 Dependent
@tanstack/preact-pacer 0.24.2 → 0.24.3 Dependent
@tanstack/react-pacer 0.24.1 → 0.24.2 Dependent
@tanstack/solid-pacer 0.24.0 → 0.24.1 Dependent
@tanstack/svelte-pacer 0.2.0 → 0.2.1 Dependent
@tanstack/vue-pacer 0.2.0 → 0.2.1 Dependent

@nx-cloud

nx-cloud Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 49885b6

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-11-12 13:35:28 UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/alpine-pacer

npm i https://pkg.pr.new/@tanstack/alpine-pacer@308

@tanstack/angular-pacer

npm i https://pkg.pr.new/@tanstack/angular-pacer@308

@tanstack/angular-pacer-devtools

npm i https://pkg.pr.new/@tanstack/angular-pacer-devtools@308

@tanstack/ember-pacer

npm i https://pkg.pr.new/@tanstack/ember-pacer@308

@tanstack/lit-pacer

npm i https://pkg.pr.new/@tanstack/lit-pacer@308

@tanstack/octane-pacer

npm i https://pkg.pr.new/@tanstack/octane-pacer@308

@tanstack/pacer

npm i https://pkg.pr.new/@tanstack/pacer@308

@tanstack/pacer-devtools

npm i https://pkg.pr.new/@tanstack/pacer-devtools@308

@tanstack/pacer-lite

npm i https://pkg.pr.new/@tanstack/pacer-lite@308

@tanstack/preact-pacer

npm i https://pkg.pr.new/@tanstack/preact-pacer@308

@tanstack/preact-pacer-devtools

npm i https://pkg.pr.new/@tanstack/preact-pacer-devtools@308

@tanstack/react-pacer

npm i https://pkg.pr.new/@tanstack/react-pacer@308

@tanstack/react-pacer-devtools

npm i https://pkg.pr.new/@tanstack/react-pacer-devtools@308

@tanstack/solid-pacer

npm i https://pkg.pr.new/@tanstack/solid-pacer@308

@tanstack/solid-pacer-devtools

npm i https://pkg.pr.new/@tanstack/solid-pacer-devtools@308

@tanstack/svelte-pacer

npm i https://pkg.pr.new/@tanstack/svelte-pacer@308

@tanstack/svelte-pacer-devtools

npm i https://pkg.pr.new/@tanstack/svelte-pacer-devtools@308

@tanstack/vue-pacer

npm i https://pkg.pr.new/@tanstack/vue-pacer@308

@tanstack/vue-pacer-devtools

npm i https://pkg.pr.new/@tanstack/vue-pacer-devtools@308

commit: 7054b8d

schiller-manuel and others added 3 commits November 12, 2026 14:30
TypeScript 6 no longer loads @types/node by default, and the docs
tsconfigs don't include the config files that pull it in. The new
`process.env.NODE_ENV` checks then failed type-checking in typedoc,
which made generate-docs wipe every reference docs folder without
writing new output.

Declare a minimal `process` type in pacer (same as
preact-pacer-devtools) and include it in the framework docs tsconfigs,
which compile pacer from source.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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