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

import clearCache Error #2395

Open
Pszz opened this issue Dec 9, 2023 · 2 comments
Open

import clearCache Error #2395

Pszz opened this issue Dec 9, 2023 · 2 comments
Assignees

Comments

@Pszz
Copy link

Pszz commented Dec 9, 2023

Uncaught Error: Module not found: Can't resolve 'ahooks/es/clearCache'

Node Version: v18.14.0

// page.tsx
import { clearCache, useRequest } from 'ahooks'

// package.json
"ahooks": "^3.7.8", "next": "latest", "react": "^18.2.0",

// next.config.js
transpilePackages: ['ahooks'],

@liuyib
Copy link
Collaborator

liuyib commented Dec 17, 2023

The root reason is the modularizeImports config of Next.js, so in ahooks side, we can do nothing.

I have open a PR to resolve it: vercel/next.js#54657, but this still is a temp solution, once ahooks exports a new variable that different with file name, then it will be cause this problem again.

The permanent solution is that Next.js remove ahooks from modularizeImports config, just like this PR: https://github.com/vercel/next.js/pull/58992/files, but I don't think Next.js would agree to that (maybe will), because it will hurt start performance.


similar solution: vercel/next.js#53483


related issue/pr:

@liuyib
Copy link
Collaborator

liuyib commented Dec 26, 2023

The issue may have already been resolved by: https://github.com/vercel/next.js/pull/59294/files, included in v14.0.4: https://github.com/vercel/next.js/releases/tag/v14.0.4

Is anyone able to try Next.js v14.0.4 to verify this problem? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants