react-financial-charts
react-financial-charts copied to clipboard
Unexpected token 'export'
I'm submitting a...
- [x ] bug
- [ ] feature
- [ ] chore
What is the current behavior
cannot build, Unexpected token 'export'
What is the expected behavior
can build using example code
Please tell us about your environment
- Version: 2.0.1
- Browser: [all | Chrome XX | Firefox XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari ]
Other information
Getting this error:
rts/lib/index.js:1 export * from "@react-financial-charts/annotations"; ^^^^^^
SyntaxError: Unexpected token 'export' at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1195:20) at Module._compile (node:internal/modules/cjs/loader:1239:27) at Module._extensions..js (node:internal/modules/cjs/loader:1329:10) at Module.load (node:internal/modules/cjs/loader:1133:32) at Module._load (node:internal/modules/cjs/loader:972:12) at Module.require (node:internal/modules/cjs/loader:1157:19) at require (node:internal/modules/helpers:119:18)
I'm using Typescript 5.0.2 and react 18.2.0, node 19
Is this combination supported? Or should I use a different version?
I get this same error when trying to build using next.js 12 and react 18.
if you are using next.js use dynamic imports like this.
const CandleChart = dynamic(() => import("components/charts/CandleChart"), {
ssr: false,
});
This is because this library doesn't support commonjs, it only supports ESM.
if you are using next.js use dynamic imports like this.
const CandleChart = dynamic(() => import("components/charts/CandleChart"), { ssr: false, });
Can i ask what's your next.js version? Because I tried your solution, still can't build the project. But it works when dev mode