-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Closed as not planned
Closed as not planned
Copy link
Labels
WebpackRelated to Webpack with Next.js.Related to Webpack with Next.js.bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.lockedstaleThe issue has not seen recent activity.The issue has not seen recent activity.
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000
Binaries:
Node: 16.16.0
npm: 8.11.0
Yarn: 1.22.15
pnpm: 7.5.2
Relevant packages:
next: 12.2.4
eslint-config-next: 12.2.4
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Next.js fails to resolve sub dependencies correctly and tries to load CJS from ESM modules, causing the build to fail.
SyntaxError: Named export 'theme' not found. The requested module '@chakra-ui/react' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
@chakra-ui/react a dependency of @saas-ui/react
Saas UI uses exports definition in package.json to define package entries and exports the ESM module as default.
{
"exports": {
".": {
"require": "./dist/index.js",
"default": "./dist/index.modern.mjs"
},
"./src": {
"default": "./src/index.ts"
}
},
"main": "./dist/index.js",
"module": "./dist/index.modern.mjs",
"types": "./dist/index.d.ts"
}
Removing exports or changing default to import fixes the issue.
However I think Next.js should handle this correctly.
Expected Behavior
Next.js resolves all packages correctly as ESM.
Link to reproduction
https://github.com/msnegurski/test-saas-ui
To Reproduce
- Clone the repo.
- npm i
- npm run dev
Make sure @saas-ui/[email protected] is installed (not 1.3)
msnegurski, nick-kang, wenerme, hubertkuoch, willbamford and 39 moreremithomas
Metadata
Metadata
Assignees
Labels
WebpackRelated to Webpack with Next.js.Related to Webpack with Next.js.bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.lockedstaleThe issue has not seen recent activity.The issue has not seen recent activity.