-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Bug]: Jest runtime cannot use import statement outside a module in @storybook/nextjs v7.5 #24550
Comments
@martinnabhan It seems that #24146 introduced the issue. We need another solution for the original issue. cc @ndelangen Maybe you have also some idea to resolve the singleton issue differently. |
I would really appreciate a reproduction as I'm not sure why Jest would be importing modules from If I manage to reproduce the issue I might be able to take a look! |
A repository to reproduction is available here. |
Hi @martinnabhan, Have you managed to take a look? |
Sorry for the late reply! Looking at the reproduction, the error happens because you're trying to import As far as I know there are three ways to support importing ESM modules in Jest's setup files: I believe Storybook is looking to slowly move towards ESM modules, so I don't think reversing #24146 is the right thing to do, since this error will happen with any ESM-only module. |
@martinnabhan I guess we can revert #24146 since the root cause of loading CommonJS and ESM in parallel is resolved by this change: https://github.com/storybookjs/storybook/pull/24841/files#diff-262a077136aafb9802aeaedb913c7d8ff477a72c6ce005e29e146f64e518b5cbL72-R72 We should try this out! |
Describe the bug
Jest fails in projects using Next.js after upgrading @storybook/nextjs v7.5.
It seems to be attributed to #24146.
Specifically, the following parts
code/frameworks/nextjs/package.json
To Reproduce
Run jest in Next.js project that using @storybook/next.
https://github.com/minami-minami/storybook-next-jest
System
Additional context
Workaround:
I hope you will consider reverting the change as the impact on jest users is significant!
The text was updated successfully, but these errors were encountered: