-
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
When using "type": "module" import
does not interop the default
export for commonjs modules
#34412
Comments
@timneutkens Hey! Just curious if there Is there currently a timeline for when this'll be finished/closed? Thanks! |
Getting error when calling an api route when my package.json type=module
|
fixes #34412 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
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. |
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.11-canary.17
What version of Node.js are you using?
v16.13.0
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Affects all platforms
Describe the Bug
When using
next/link
,next/image
, or any other module that is not real ESM but has adefault
export the code importing the module does not automatically useinteropRequireDefault
which turns the default import into an object holdingdefault
and any other exports from the module. Example:Result from above code:
This results in the build error below:
Build error
info - Checking validity of types
info - Creating an optimized production build
info - Compiled successfully
info - Collecting page data
[ ] info - Generating static pages (0/3)
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at a.b.render (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:45:32)
at a.b.read (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83)
at Object.exports.renderToString (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138)
at Object.renderPage (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/next/dist/server/render.js:749:45)
at Object.defaultGetInitialProps (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/next/dist/server/render.js:387:51)
at Function.getInitialProps (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/.next/server/pages/_document.js:530:20)
at Object.loadGetInitialProps (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/next/dist/shared/lib/utils.js:69:29)
at renderDocument (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/next/dist/server/render.js:762:48)
at renderToHTML (/Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/next/dist/server/render.js:826:34)
at async /Users/timneutkens/projects/sandbox/kfjkdsfjkjdkfsjkd/node_modules/next/dist/export/worker.js:269:36
info - Generating static pages (3/3)
Expected Behavior
I need to check this one with @sokra given that there's two ways we could go with this. Will circle back on this issue once I've done so.
To Reproduce
yarn create next-app module-issue && cd module-issue && yarn add next@canary
package.json
and add"type": "module"
to the topnpm run build
The text was updated successfully, but these errors were encountered: