[PR #30279] refactor(web): Migrate to Unified TanStack Devtools #32757

Closed
opened 2026-02-21 20:52:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/30279

State: closed
Merged: Yes


Summary

This PR migrates the frontend devtools from the standalone @tanstack/react-query-devtools integration to the official unified TanStack Devtools container and optimizes development tools loading for production performance.

Changes

🔧 Architecture & Migration

  • Dependencies: Modified web/package.json to include @tanstack/react-devtools and @tanstack/react-form-devtools.
  • New Component: Introduced web/app/components/devtools.tsx containing the TanStackDevtoolsWrapper.
  • Integration: Updated web/context/query-client.tsx to use the new wrapper component.

Performance & Tree-Shaking

  • TanStack Devtools: Implemented lazy loading (React.lazy) and dynamic imports in query-client.tsx, ensuring devtools code is completely tree-shaken and excluded from production bundles.
  • React Scan: Refactored static import in web/app/layout.tsx to use next/dynamic with ssr: false. This ensures React Scan is only loaded in the browser during development, further reducing the initial bundle size.

Verification

  1. Run pnpm dev in the web directory.
  2. Open the application.
  3. Verify the TanStack logo appears in the bottom-right corner.
  4. Verify React Scan functionality (if enabled).
  5. (Advanced) Run a production build (pnpm build) and verify that neither TanStack Devtools nor React Scan code is included in the main bundles.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/30279 **State:** closed **Merged:** Yes --- ## Summary This PR migrates the frontend devtools from the standalone `@tanstack/react-query-devtools` integration to the official unified **TanStack Devtools** container and optimizes development tools loading for production performance. - Fixes #30278 ## Changes ### 🔧 Architecture & Migration - **Dependencies**: Modified `web/package.json` to include `@tanstack/react-devtools` and `@tanstack/react-form-devtools`. - **New Component**: Introduced `web/app/components/devtools.tsx` containing the `TanStackDevtoolsWrapper`. - **Integration**: Updated `web/context/query-client.tsx` to use the new wrapper component. ### ⚡ Performance & Tree-Shaking - **TanStack Devtools**: Implemented **lazy loading** (`React.lazy`) and dynamic imports in `query-client.tsx`, ensuring devtools code is completely tree-shaken and excluded from production bundles. - **React Scan**: Refactored static import in `web/app/layout.tsx` to use `next/dynamic` with `ssr: false`. This ensures React Scan is only loaded in the browser during development, further reducing the initial bundle size. ## Verification 1. Run `pnpm dev` in the `web` directory. 2. Open the application. 3. Verify the TanStack logo appears in the bottom-right corner. 4. Verify React Scan functionality (if enabled). 5. (Advanced) Run a production build (`pnpm build`) and verify that neither TanStack Devtools nor React Scan code is included in the main bundles. ## Checklist - [x] I understand that this PR may be closed in case there was no previous discussion or issues. - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:52:01 -05:00
yindo closed this issue 2026-02-21 20:52:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32757