Issue on Next 12 - CommonJS script issue
- Dominant language
- JavaScript
- Stars
- 46
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Hello
I recently updated a project of mine to Next 12 and then also updated the `converkit-react` library to `1.5.5`.
When I startup the project and load my page with the form on it I now get the following error.
```
error - unhandledRejection: ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/workspaces/project/node_modules/convertkit-react/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
```
I do not think I am going anything special. This is a vanilla next project and I import the form with the following.
```
import ConvertKitForm from 'convertkit-react';
```
I am not sure what might be going wrong here but I see in the project history there was a release specifically for Next around commonjs a few releases back.
Maybe something has changed with Next 12?
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the error in a vanilla Next 12 project using the shown ConvertKitForm import, then inspect convertkit-react/package.json and the module entry selected by that import. Done means the form loads without the ES-module/CommonJS require error while preserving the library's Next.js compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100