feat(event-client): strip the root EventClient export from production by default #471
main fromrefs/pull/471/head·merged by AlemTuzlak View on GitHubSummary#
The root export of @tanstack/devtools-event-client is currently always bundled into consumers' production builds, even though devtools events are a development-time concern. This makes the root export a no-op outside development (tree-shaken away), and adds a new /production subpath for OSS authors who deliberately want devtools events live in production.
This mirrors the existing pattern in @tanstack/devtools-a11y (root export gated on process.env.NODE_ENV, /production subpath for the real implementation).
How it works#
- Root export (
@tanstack/devtools-event-client):process.env.NODE_ENV !== 'development' ? EventClientNoOp : EventClient. A consumer's production bundler replacesNODE_ENV, constant-folds the ternary to the no-op, and tree-shakes the realEventClientout (sideEffects: false, no top-level side effects, and the no-op module never imports the real one). /productionsubpath (@tanstack/devtools-event-client/production): always re-exports the realEventClient.- Public API is identical between the two imports —
class X extends EventClient<EventMap>and: EventClient<EventMap>work unchanged. A type-erasedimplements PublicSurface<EventClient<…>>clause on the no-op guarantees the two never silently drift (drift failstsc).
Changes#
- New
src/types.ts(shared event types),src/noop.ts(standalone no-op),src/production.ts(always-real entry);src/index.tsis now the resolver. package.jsonadds the./productionexport (ESM + CJS);vite.config.tsadds the production build entry.- Tests: existing behavior suite repointed to
../src/production(the real client); new no-op contract tests + resolver tests covering both the production (no-op) and development (real) branches. - Docs: README,
docs/production.md, the framework custom-plugins guides, and the bundled skills updated; stale "you must guardemit()manually" guidance corrected.
Breaking change#
This changes the default-export behavior: code relying on events firing in production via the root import must switch to @tanstack/devtools-event-client/production. A minor changeset is included (0.x semantics) documenting the migration.
Testing#
nx affectedacross all 30+ dependent projects: 85/85 tasks pass (lint, unit tests, types, publint, build).- Package unit tests: 26 pass (no-op contract, resolver dev + prod branches, full real-client behavior suite via
/production). - Verified
process.env.NODE_ENVsurvives into shippeddist/esm/index.js, so consumer bundlers can fold it;publint --strictconfirms the/productionexports resolve.
🤖 Generated with Claude Code
Summary by CodeRabbit#
New Features
- Default import now becomes a no-op in production and is automatically removed via tree-shaking, reducing bundle size
- Added
/productionsubpath import for developers who need devtools events enabled in production
Documentation
- Added "Production builds" sections across all framework guides and core documentation explaining the new import behavior
- 1
View your CI Pipeline Execution ↗ for commit 67ed337299cb32a97820df6c6bf097b8e53cbba3
Command Status Duration Result nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded 14s View ↗
☁️ Nx Cloud last updated this comment at
2026-06-24 11:11:02UTCMore templates
- @tanstack/devtools-example-angular-a11y-devtools
- @tanstack/devtools-example-angular-basic
- @tanstack/devtools-example-angular-panel
- ssr
- @tanstack/devtools-example-angular-with-devtools
- @tanstack/devtools-example-preact-basic
- @tanstack/devtools-custom-devtools-preact
- @tanstack/react-devtools-a11y-example
- @tanstack/devtools-example-react-basic
- start-repro
- @tanstack/devtools-custom-devtools
- tanstack-start-example-counter
- @tanstack/devtools-example-react-https
- start
- start-cloudflare
- start-nitro
- @tanstack/devtools-example-react-time-travel
- @tanstack/query-example-vue-basic
- @tanstack/solid-devtools-a11y-example
- @tanstack/devtools-example-solid-basic
- @tanstack/devtools-example-devtools-ui
- @tanstack/devtools-example-solid-start
@tanstack/angular-devtools
npm i https://pkg.pr.new/@tanstack/angular-devtools@471@tanstack/devtools
npm i https://pkg.pr.new/@tanstack/devtools@471@tanstack/devtools-a11y
npm i https://pkg.pr.new/@tanstack/devtools-a11y@471@tanstack/devtools-client
npm i https://pkg.pr.new/@tanstack/devtools-client@471@tanstack/devtools-ui
npm i https://pkg.pr.new/@tanstack/devtools-ui@471@tanstack/devtools-utils
npm i https://pkg.pr.new/@tanstack/devtools-utils@471@tanstack/devtools-vite
npm i https://pkg.pr.new/@tanstack/devtools-vite@471@tanstack/devtools-event-bus
npm i https://pkg.pr.new/@tanstack/devtools-event-bus@471@tanstack/devtools-event-client
npm i https://pkg.pr.new/@tanstack/devtools-event-client@471@tanstack/preact-devtools
npm i https://pkg.pr.new/@tanstack/preact-devtools@471@tanstack/react-devtools
npm i https://pkg.pr.new/@tanstack/react-devtools@471@tanstack/solid-devtools
npm i https://pkg.pr.new/@tanstack/solid-devtools@471@tanstack/svelte-devtools
npm i https://pkg.pr.new/@tanstack/svelte-devtools@471@tanstack/vue-devtools
npm i https://pkg.pr.new/@tanstack/vue-devtools@471commit:
67ed337AlemTuzlak merged thisb1ac893
AlemTuzlak closed this
Sign in to join this conversation.
Warning
Review limit reached#
@AlemTuzlak, we couldn't start this review because you've reached your PR review rate limit.More reviews will be available in 36 minutes. Learn how PR review limits work.
Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).
⌛ How to resolve this issue?
After more reviews become available, a review can be triggered using the
@coderabbitai reviewcommand as a PR comment. Alternatively, push new commits to this PR.To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.
🚦 How do rate limits work?
CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.
For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.
Please see our Fair Usage Limits Policy for further information.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
cfa59140-f640-4a71-b87f-414f85d66c5e📥 Commits
Reviewing files that changed from the base of the PR and between b37aeb75463d5936ddcfd2125428c275672c3ba4 and 67ed337299cb32a97820df6c6bf097b8e53cbba3.
📒 Files selected for processing (1)
packages/event-bus-client/package.json📝 Walkthrough
Walkthrough#
The
@tanstack/devtools-event-clientpackage root export now conditionally resolves to a no-opEventClientNoOpwhenprocess.env.NODE_ENVis not'development', enabling tree-shaking in production. A new/productionsubpath re-exports the realEventClientunchanged. Supporting changes include a sharedtypes.ts, a new build entry, updated package exports, tests, and documentation across all framework guides.Changes#
EventClient production no-op and /production entrypoint
packages/event-bus-client/src/types.ts,packages/event-bus-client/src/noop.ts,packages/event-bus-client/src/plugin.ts,packages/event-bus-client/src/production.ts,packages/event-bus-client/src/index.tsTanStackDevtoolsEventandAllDevtoolsEventsare extracted intotypes.ts.EventClientNoOpis added with inertemit,on,onAll, andonAllPluginEventsmethods.plugin.tsimports types fromtypes.ts.production.tsre-exports the realEventClient.index.tsconditionally resolves to the real or no-op client based onprocess.env.NODE_ENV.packages/event-bus-client/package.json,packages/event-bus-client/vite.config.ts./productionsubpath is added topackage.jsonexports with ESM and CJS targets.vite.config.tsadds./src/production.tsas a second build entry.packages/event-bus-client/tests/index.test.ts,packages/event-bus-client/tests/noop.test.tsindex.test.tsimport is updated to use../src/production.noop.test.tscoversEventClientNoOpside-effect behavior, root export resolution underNODE_ENV=testandNODE_ENV=developmentviavi.stubEnv/vi.resetModules/dynamic import, and typed class extension..changeset/event-client-production-stripping.md,packages/event-bus-client/README.md,packages/event-bus-client/skills/...,docs/production.md,docs/building-custom-plugins.md,docs/framework/*/guides/custom-plugins.mddocs/production.md, and the README. Updates bothSKILL.mdfiles to reflect no-op root import behavior. Records the change in the changeset.Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem#
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
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