Skip to content

@tanstack/react-query-devtools v4 does not include NODE_ENV check  #3860

@jaworek

Description

@jaworek

Describe the bug

According to the documention, devtools should only be included in development mode:
https://tanstack.com/query/v4/docs/devtools#install-and-import-the-devtools

React Query v3 devtools include check for that:
https://github.com/TanStack/query/blob/v3/devtools/index.js

React Query v4 are missing this check which results in devtools being bundled in production and increasing overall bundle size:
https://github.com/TanStack/query/blob/main/packages/react-query-devtools/src/index.ts

Your minimal, reproducible example

https://stackblitz.com/edit/nextjs-odbs3c?file=pages/_app.js

React Query v3 does not have this issue:
https://stackblitz.com/edit/nextjs-ssq6g3?file=pages/_app.js

Steps to reproduce

  1. Open _app.js file
  2. Open terminal and run npm run build
  3. Comment out <ReactQueryDevtools initialIsOpen={false} /> and import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
  4. Run npm run build
  5. Notice that shared bundle size decreased from 103kB to 90kB

Expected behavior

React Query Devtools should not be bundled in production build by default.

How often does this bug happen?

Every time

Screenshots or Videos

Next 12.2 project with devtools enabled:
image

Next 12.2 project with devtools disabled:
image

Platform

  • OS: MacOS
  • Browser: Chromium
  • Version: 4.0.3

react-query version

4.0.3

TypeScript version

4.7.4

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions