flint-chart/react fails to build without every optional backend installed (dynamic imports of chart.js / plotly.js-dist-min)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- chart.js, next.js, react, typescript
Research direction
Start by tracing the dynamic imports in flint-chart/react and flint-chart/interactive, including the backend entry points named in the issue. Check how optional peer dependencies are declared and how the package is built with a backend peer missing. Done means consumers can build with only their chosen backend installed, or the README documents a reliable workaround.
Written by the indexing model from the issue text.
Description
flint-chart/react (and flint-chart/interactive) reach every interactive backend through dynamic imports:
import('../chartjs/interactive') // imports 'chart.js'
import('../plotly/interactive') // imports 'plotly.js-dist-min'
import('../echarts/interactive') // imports 'echarts'
import('../vegalite/interactive')
chart.js, plotly.js-dist-min and echarts are optional peer dependencies (peerDependenciesMeta), so an app that only renders one backend leaves the others uninstalled. But bundlers resolve dynamic imports at build time, so the build fails even though those modules would never load.
Reproduce
flint-chart 1.0.1, Next.js 16 (Turbopack), with vega, vega-lite, vega-tooltip and echarts installed but not chart.js or Plotly:
import { FlintChart } from "flint-chart/react";
<FlintChart spec={spec} backend="vegalite" />
Module not found: Can't resolve 'chart.js'
./node_modules/flint-chart/dist/chartjs/interactive.js (1:1)
> 1 | import { Chart, registerables } from 'chart.js';
The same happens for plotly.js-dist-min. The workaround is aliasing the missing packages to a stub (turbopack.resolveAlias / webpack resolve.alias), which every consumer has to rediscover.
Possible fixes
- Let the host pass the backend's interactive renderer in, e.g.
<FlintChart renderer={createVegaLiteInteractiveRenderer()} />(or aflint-chart/react/vegaliteentry), so only the imported backend is bundled. - Or mark the optional-backend imports so bundlers skip them (
/* webpackIgnore: true *///* @vite-ignore */with a runtime-resolved specifier), and document installing the peer for the backend you use. - At least document the alias workaround next to "Interactive charts" in the README.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 256
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
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.
More from microsoft/flint-chart
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
microsoft/flint-chart#156 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/flint-chart#149 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/flint-chart#66 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
microsoft/flint-chart#65 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 8/100
microsoft/flint-chart#158 · 2 reactions ·
Maintainers usually reply within 1 day
All issues in microsoft/flint-chart
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
components-web-app/docs#311 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NEARBuilders/everything-dev#678 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
formbricks/formbricks#9881 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day