Skip to content
Source
Sign inSign up
TanStack/devtools

feat(event-client): strip the root EventClient export from production by default #471

MergedAlemTuzlakmerged 9 commits intomain fromrefs/pull/471/headmerged by AlemTuzlak View on GitHub

AlemTuzlakcommented

Summary

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 replaces NODE_ENV, constant-folds the ternary to the no-op, and tree-shakes the real EventClient out (sideEffects: false, no top-level side effects, and the no-op module never imports the real one).
  • /production subpath (@tanstack/devtools-event-client/production): always re-exports the real EventClient.
  • Public API is identical between the two imports — class X extends EventClient<EventMap> and : EventClient<EventMap> work unchanged. A type-erased implements PublicSurface<EventClient<…>> clause on the no-op guarantees the two never silently drift (drift fails tsc).

Changes

  • New src/types.ts (shared event types), src/noop.ts (standalone no-op), src/production.ts (always-real entry); src/index.ts is now the resolver.
  • package.json adds the ./production export (ESM + CJS); vite.config.ts adds 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 guard emit() 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 affected across 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_ENV survives into shipped dist/esm/index.js, so consumer bundlers can fold it; publint --strict confirms the /production exports 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 /production subpath 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. Review Change Stack

      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 review command 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-client package root export now conditionally resolves to a no-op EventClientNoOp when process.env.NODE_ENV is not 'development', enabling tree-shaking in production. A new /production subpath re-exports the real EventClient unchanged. Supporting changes include a shared types.ts, a new build entry, updated package exports, tests, and documentation across all framework guides.

      Changes

      EventClient production no-op and /production entrypoint

      Layer / File(s)Summary
      Event types, no-op class, and conditional root export
      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.ts
      TanStackDevtoolsEvent and AllDevtoolsEvents are extracted into types.ts. EventClientNoOp is added with inert emit, on, onAll, and onAllPluginEvents methods. plugin.ts imports types from types.ts. production.ts re-exports the real EventClient. index.ts conditionally resolves to the real or no-op client based on process.env.NODE_ENV.
      Package exports and build entrypoints
      packages/event-bus-client/package.json, packages/event-bus-client/vite.config.ts
      The ./production subpath is added to package.json exports with ESM and CJS targets. vite.config.ts adds ./src/production.ts as a second build entry.
      No-op and root-export resolver tests
      packages/event-bus-client/tests/index.test.ts, packages/event-bus-client/tests/noop.test.ts
      The existing index.test.ts import is updated to use ../src/production. noop.test.ts covers EventClientNoOp side-effect behavior, root export resolution under NODE_ENV=test and NODE_ENV=development via vi.stubEnv/vi.resetModules/dynamic import, and typed class extension.
      Documentation, README, skills, and changeset
      .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.md
      Adds "Production builds" sections to all framework guides, docs/production.md, and the README. Updates both SKILL.md files to reflect no-op root import behavior. Records the change in the changeset.

      Estimated code review effort

      🎯 3 (Moderate) | ⏱️ ~20 minutes

      Poem

      A bunny hops through prod with glee, No-op client, light and free! When NODE_ENV says "not dev today," The real client stays tucked away. /production path unlocks the gate, Tree-shaken bundles — isn't that great? 🐇✨

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Description check⚠️ WarningThe description comprehensively covers changes, testing, and migration guidance, but is missing the required changelog/Release Impact checklist items.Complete the checklist section: confirm the changeset was generated and mark the appropriate Release Impact checkbox to acknowledge breaking change documentation.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title accurately and concisely describes the main change: making the root EventClient export tree-shakeable in production by default.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `feat/event-client-production-stripping`

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. View your CI Pipeline Execution ↗ for commit 67ed337299cb32a97820df6c6bf097b8e53cbba3

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded14sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-06-24 11:11:02 UTC

    3. More templates

      @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@471

      commit: 67ed337

    4. AlemTuzlak merged thisb1ac893

    5. AlemTuzlak closed this

Sign in to join this conversation.