blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Cannot use Blitz toolkit beta with @tanstack/react-query installed elsewhere in a monorepo

Open jan-wilhelm opened this issue 2 years ago • 2 comments

What is the problem?

I am using the Blitz toolkit beta in a monorepo setup, where I have a apps/blitz and another apps/docs folder. The blitz folder contains my blitz application, the docs folder contains a separate Next project for documentation.

For some reason, Blitz is requiring me to set public-hoist-pattern[]=@tanstack/react-query in my .npmrc file at the root of my monorepo. Blitz seems to be using version 4.0.10 of react-query.

However, when I install @tanstack/react-query in the apps/docs folder, it is, of course, using the latest version of react-query, which is 4.24.*. This breaks my blitz app, which seems to rely on the exact 4.0.10 version.

Paste all your error logs here:

Error: No QueryClient set, use QueryClientProvider to set one
    at Object.useQueryClient (/Users/Jan/Desktop/project/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@tanstack/react-query/build/cjs/react-query/src/QueryClientProvider.js:68:11)
    at Object.useMutation (/Users/Jan/Desktop/project/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@tanstack/react-query/build/cjs/react-query/src/useMutation.js:43:43)
    at useMutation (/Users/Jan/Desktop/project/node_modules/.pnpm/@[email protected]_z23kptem44zej6xtmrdyaua4dm/node_modules/@blitzjs/rpc/dist/index-browser.cjs:135:25)
    at AdminPanel (/Users/Jan/Desktop/project/apps/app/.next/server/chunks/1744.js:1463:87)
    at Wc (/Users/Jan/Desktop/project/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/Users/Jan/Desktop/project/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/Users/Jan/Desktop/project/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at Zc (/Users/Jan/Desktop/project/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:481)
    at Z (/Users/Jan/Desktop/project/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at Zc (/Users/Jan/Desktop/project/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:481)

Paste all relevant code snippets here:

.

What are detailed steps to reproduce this?

  1. Create a mono repo using PNPM
  2. Create a blitz app inside it
  3. Create another app that uses @tanstack/react-query with the latest version
  4. try to build the Blitz app, you'll get an error

Run blitz -v and paste the output here:

 Package manager: npm

  System:
    OS: macOS 12.6.3
    CPU: (8) arm64 Apple M1 Pro
    Memory: 1.05 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.7.0 - /opt/homebrew/bin/node
    Yarn: Not Found
    npm: 9.5.0 - /opt/homebrew/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.0-beta.23 => 2.0.0-beta.23 
    @blitzjs/next: 2.0.0-beta.23 => 2.0.0-beta.23 
    @blitzjs/rpc: 2.0.0-beta.23 => 2.0.0-beta.23 
    @prisma/client: ^4.10.1 => 4.10.1 
    blitz: 2.0.0-beta.23 => 2.0.0-beta.23 
    next: 12.3.1 => 12.3.1 
    prisma: ^4.10.1 => 4.10.1 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    typescript: ^4.9.5 => 4.9.5 

Please include below any other applicable logs and screenshots that show your problem:

No response

jan-wilhelm avatar Feb 28 '23 15:02 jan-wilhelm

Hey @jan-wilhelm, thanks for the issue. We will have to discuss whether to allow a more flexible versioning of react query used in the RPC package

siddhsuresh avatar Mar 06 '23 13:03 siddhsuresh

@siddhsuresh I overode the version to latest in my repo without any regressions, it is safe to update

datner avatar Mar 30 '23 20:03 datner