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
Next 12 - ESM Support - SyntaxError: Cannot use import statement outside a module #30441
Comments
Seems Next.js 12 doesn't yet exist on the CodeSandbox environment. |
It doesn't look like validator has a |
Hm, I've tried running this example locally, but I get the same error back. I indeed think this is a change that needs to happen in |
@DaniAkash Does this work if you temporarily patch the |
Tried the same project with lodash-es which has a module type in it's package.json & things seem to work fine Working codesandbox: https://codesandbox.io/s/next-12-esm-issue-forked-q4l8f?file=/pages/index.js Seems like, modules exposing ESM files without specifying entry in |
I have the same problems, the package swiper/react doesn't load. https://stackblitz.com/edit/github-a252xz?file=pages/index.tsx |
Indeed, it looks like the validator package bundle is incorrect. Being fixed here validatorjs/validator.js#1869 |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
12.0.1
What version of Node.js are you using?
14.18.1
What browser are you using?
Chrome
What operating system are you using?
Linux
How are you deploying your application?
Vercel / CodeSandbox
Describe the Bug
Trying to import a ES Module in Next.js 12 throws the following error:
Example based on Tree shakable ESM export of validator library but happens with any other esm package
Expected Behavior
ES Modules should work in Next.js 12
To Reproduce
Visit the following codesandbox:
https://codesandbox.io/s/next-12-esm-issue-nlew9?file=/pages/index.js:62-110
The text was updated successfully, but these errors were encountered: