Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing react-query/devtools #1676

Closed
3 tasks done
itsMapleLeaf opened this issue Jan 23, 2021 · 2 comments
Closed
3 tasks done

Error when importing react-query/devtools #1676

itsMapleLeaf opened this issue Jan 23, 2021 · 2 comments

Comments

@itsMapleLeaf
Copy link

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

When attempting to import react-query/devtools, I get this error. Seems like some issue in module resolution. It worked without errors on beta version 35, if I recall correctly

(node:11664) UnhandledPromiseRejectionWarning: Error: Failed to resolve entry for package "\Projects\vite-react-query\node_modules\.pnpm\react-query@3.6.0_react-dom@17.0.1+react@17.0.1\node_modules\react-query\devtools". The package may have incorrect main/module/exports specified in its package.json.
    at resolvePackageEntry (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:39897:15)
    at tryResolveFile (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:39701:24)
    at tryFsResolve (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:39684:16)
    at resolveDeepImport (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:39932:26)
    at tryNodeResolve (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:39752:11)
    at optimizeDeps (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:71071:30)
    at async runOptimize (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:71577:13)
    at async Server.httpServer.listen (\Projects\vite-react-query\node_modules\.pnpm\vite@2.0.0-beta.44\node_modules\vite\dist\node\chunks\dep-3174cbb5.js:71590:13)

Reproduction

https://github.com/itsMapleLeaf/vite-react-query

System Info

  • vite version: 2.0.0-beta.44
  • Operating System: Windows 10 Home
  • Node version: 14.15.4
  • Package manager (npm/yarn/pnpm) and version: pnpm 5.15.3
@yyx990803
Copy link
Member

Note react-query/devtools has no default export so your usage is wrong. It should be import { ReactQueryDevtools } from 'react-query/devtools' instead of using the default import.

After that there is still a runtime error - which I don't think is Vite related.

@itsMapleLeaf
Copy link
Author

First off, thanks for the quick fix, and for all your awesome work on this 👏

Note react-query/devtools has no default export so your usage is wrong. It should be import { ReactQueryDevtools } from 'react-query/devtools' instead of using the default import.

You're right, and that's how I normally would've done it. But previous Vite versions would transform the module into a default export, which is why I wrote it the way I did. But that also seems to be resolved now 💯

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants