-
Notifications
You must be signed in to change notification settings - Fork 27k
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
SyntaxError: Named export 'useRouter' not found #48801
Comments
Next 13.3.1 breaks most of ESM apps using named imports to import Next.js CommonJS modules.
A similar issue in nextra: shuding/nextra#1785 |
I believe this problem is caused by swc new module transformer which was introduced by this PR: swc-project/swc#4758 |
The situation only occurs in the following circumstances:
I am considering which aspect of the isuue is the key factor. |
@kdy1 Do you believe that we should always emit the |
Hmm.... Not sure. How another option (e.g. |
The optimal solution should be to set up the correct dual package. |
But well, I think this is due to a wrong usage |
Yeah, I'll try it first |
How do you think about making |
@magic-akari Sadly |
Both interopAnnotation boolean flag or new interop type are OK. |
Then let's use a boolean flag. Will you work on it? If not, I'll do it |
Yes, please assign to me. |
Thank you! |
**Related issue:** - vercel/next.js#48801
- temporary solution to `SyntaxError: Named export 'useRouter' not found` in versions 13.3.1+ - see this issue vercel/next.js#48801
I'm still having issues trying to import a properly bundled package with |
@CobyPear, it may be worth opening a separate ticket with specific example(s) as the issue described in this ticket was fixed in 13.3.2 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023 Binaries: Node: 16.17.0 npm: 8.15.0 Yarn: 1.22.19 pnpm: 7.1.0 Relevant packages: next: 13.3.2-canary.3 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/nextjs-router-esm-qoquxr?file=%2Fpages%2Findex.tsx
To Reproduce
next
version to 13.3.0 and the error goes away.Describe the Bug
It appear that the release 13.3.1 includes certain changes to the named exports, so the following import no longer works in ESM:
The above code produces the following error:
A use-case for ESM import is a 3rd-party ESM-only component library that uses
next/router
.Expected Behavior
Named exports should work in ESM as they used to prior to 13.3.1.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: