Missing ESM dependencies in standalone bundle
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 185
- PR merge metrics
- No merged PRs in 30d
Description
👋 Hello from Recharts!
We have this problem where Recharts fails to build using next.js standalone.
The situation is:
- Recharts provides both ESM and CJS bundles (https://github.com/recharts/recharts/blob/main/package.json)
- Recharts depends on Redux toolkit, which also provides both ESM and CJS bundles (https://github.com/reduxjs/redux-toolkit/blob/master/packages/toolkit/package.json)
- All works fine when using
next devbut fails to run when usingnext build && node .next/standalone/server.js
The cause seems to be that the Recharts code is referencing redux/toolkit ESM bundle but those files are not included in the standalone build. Copying the appropriate files to the standalone folder fixes it.
Also adding exports to Recharts package.json would fix this - but it breaks so many other places that we can't do that just yet.
Here's a summary with more details: https://github.com/recharts/recharts/issues/6117#issuecomment-3688967008
Here's a reproduction: https://github.com/recharts/recharts-integ/pull/88
Do you have any recommendation what can we do to have everything compile in nextjs? Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction in recharts-integ pull request 88 and run next build && node .next/standalone/server.js to reproduce the missing dependencies. Trace how the standalone build discovers Recharts and Redux Toolkit ESM files; done when the standalone server runs without manually copying files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js, redux
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100