Skip to content

Non-zero runtime overhead in production build #112

@vasilii-kovalev

Description

@vasilii-kovalev

TanStack Devtools version

v0.6.4

Framework/Library version

React v19.1.1

Describe the bug and the steps to reproduce it

After creating a production build, I can see a non-zero overhead from the devtools library and its plugins:

Image

Since the devtools are available in development mode only, this overhead should not exist in the production build.

Actually, all devtools components add this overhead, not only TanStack Devtools, so let me know if I should create separate issues in the other libraries.

A workaround is to render the devtools components conditionally depending on the environment variable:

import {
  TanStackDevtools,
} from "@tanstack/react-devtools";
import {
  ReactQueryDevtoolsPanel,
} from "@tanstack/react-query-devtools";
import {
  TanStackRouterDevtoolsPanel,
} from "@tanstack/react-router-devtools";

<Fragment>
  {
    import.meta.env.DEV
      ? (
        <TanStackDevtools
          plugins={[
            {
              name: "TanStack Query",
              render: (
                <ReactQueryDevtoolsPanel
                  client={queryClient}
                />
              ),
            },
            {
              name: "TanStack Router",
              render: (
                <TanStackRouterDevtoolsPanel
                  router={router}
                />
              ),
            },
          ]}
        />
      )
      : null
  }
</Fragment>

Steps to reproduce:

  1. Create a Vite (React + TypeScript) project
  2. (Optional) Add TanStack Query and TanStack Router with devtools
  3. Set up the devtools as written in the documentation
  4. Make a production build
  5. Analyze the production build (using Sonda, for example)

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

vasilii-kovalev/state-manager-examples@63b84aa

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions