devtools/packages/event-bus-client
Alem Tuzlak 53805408af
chore: upgrade Vitest to v4 (#497)
* ci: stop Release test:lib flakes from runner overload

Release runs nx run-many across every package at nx.json parallel: 5.
That oversubscribes GitHub-hosted runners and flakes two test:lib jobs:

- @tanstack/devtools-ui: default 5s timeout on Solid + goober mounts
- @tanstack/devtools: vitest worker RPC stall (onTaskUpdate)

PR already caps NX_PARALLEL at 3 (#478). Apply the same cap to Release,
and raise the 30s test/hook timeouts on the remaining heavy UI packages.

* chore: upgrade Vitest to v4

Bump vitest from 3.2.4 to 4.1.10. Vitest 4 replaces the 60s
onTaskUpdate RPC timeout that failed Release after every
@tanstack/devtools test had already passed.

Migrate defineWorkspace to test.projects. Turn off Solid HMR in
tests so the module runner does not load /@solid-refresh. Update
mocks and timers that Vitest 4 types or isolates differently.
History 2026-08-12 16:20:22 +02:00
..
bin ci: Version Packages (#380) 2026-03-11 14:39:21 +01:00
skills feat(event-client): strip the root EventClient export from production by default (#471) 2026-06-24 13:13:14 +02:00
src feat(event-client): strip the root EventClient export from production by default (#471) 2026-06-24 13:13:14 +02:00
tests chore: upgrade Vitest to v4 (#497) 2026-08-12 16:20:22 +02:00
CHANGELOG.md ci: Version Packages (#475) 2026-06-24 13:21:43 +02:00
eslint.config.js chore: rename package exports and names 2025-08-08 11:22:52 +02:00
package.json ci: Version Packages (#475) 2026-06-24 13:21:43 +02:00
README.md feat(event-client): strip the root EventClient export from production by default (#471) 2026-06-24 13:13:14 +02:00
tsconfig.docs.json chore: rename package exports and names 2025-08-08 11:22:52 +02:00
tsconfig.json chore: rename package exports and names 2025-08-08 11:22:52 +02:00
vite.config.ts feat(event-client): strip the root EventClient export from production by default (#471) 2026-06-24 13:13:14 +02:00

@tanstack/devtools-event-client

This package is still under active development and might have breaking changes in the future. Please use it with caution.

General Usage

import { EventClient } from '@tanstack/devtools-event-client'

interface EventMap {
  'query-devtools:a': { foo: string }
  'query-devtools:b': { foo: number }
}

class QueryDevtoolsPlugin extends EventClient<EventMap> {
  constructor() {
    super({
      pluginId: 'query-devtools',
    })
  }
}

export const queryPlugin = new QueryDevtoolsPlugin()

// I'm fully typed here
plugin.emit('a', {
  foo: 'bar',
})
plugin.on('b', (e) => {
  // I'm fully typed here
  e.payload.foo
})

Understanding the implementation

The EventClient class is a base class for creating plugins that can subscribe to events in the TanStack Devtools event bus. It allows you to define a set of events and their corresponding data schemas using a standard-schema based schemas.

It will work on both the client/server side and all you have to worry about is emitting/listening to events.

Production builds

By default the root import of @tanstack/devtools-event-client no-ops outside development. When your bundler sets process.env.NODE_ENV to anything other than 'development', the real client is replaced by a no-op and tree-shaken out of your production bundle:

// dev: real client — production: no-op (tree-shaken away)
import { EventClient } from '@tanstack/devtools-event-client'

If you are an open-source author who deliberately wants devtools events in production, import the real client from the /production subpath instead. It is never stripped:

// always the real client, in every environment
import { EventClient } from '@tanstack/devtools-event-client/production'

The public API is identical between the two imports — only the production runtime behavior differs.

"Outside development" includes when NODE_ENV is unset — common in plain Node scripts, some SSR dev servers, and test runners — so the root import resolves to the no-op there too. Set NODE_ENV=development, or use the /production subpath, to get the real client in those contexts.