-
Notifications
You must be signed in to change notification settings - Fork 8
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
Error when using in Next.js: Unexpected token 'export' #15
Comments
Hi @renet, thanks for commenting on the issue. It seems that is not related to this React wrapper but the way Next is transpiling ECharts modules. I'm treating ECharts as external so I am not exactly sure about what is causing it. Could you dig deeper into the issue? (like is happening in other React wrappers libs around ECharts, or is it reported in the ECharts repo) I'm a little bit short of time these days but I'm glad to help as far as I can. |
I stumbled upon a workaround while evaluating an alternative library than echarts for usage with the Next.js pages router: Nivo. So the same thing happened there and the fix works for echarts, as well. Just add the following to your transpilePackages: [
"@kbox-labs/react-echarts",
"echarts",
], As you see, I had to add both dependencies to the |
That's great @renet! Precious feedback. I'll give it a look as soon as I got some time and sorry for the inconveniences. Thanks! |
Hi @renet if you don't need server-side rendering of echarts - dynamic importing works well for me: import dynamic from 'next/dynamic';
const Echarts = dynamic(() => import('../Echarts'), { ssr: false }); Where ../Echarts is my wrapper component with my defaults. Direct dynamic import of next-echarts should also work. |
At least with the latest version of
Neither the |
Description
When I added
react-echarts
to my Next.js 14 project using the pages router, I get the following error message when calling a page that imports anEChart
component:Link to Reproduction
https://github.com/renet/next-echarts-repro
Steps to reproduce
pnpm i
pnpm dev
JS Framework
Next.js / React TS
Version
1.0.3
Browser
Safari
Operating System
Additional Information
The sandbox did not work, throwing an pnpm-specific error, but it works just fine locally with a clean
pnpm install
. The error does not occur, when the app router is used.The text was updated successfully, but these errors were encountered: