Open olsio opened 12 months ago
Have this issue after updating from 14.0.1 to 14.0.2
Also this code doesn't work:
import * as Highcharts from "highcharts";
import HighchartsReact from 'highcharts-react-official';
export const Charts = (): JSX.Element => {
return <></>;
return <HighchartsReact highcharts={Highcharts}/>
}
But this one works:
import * as Highcharts from "highcharts";
import HighchartsReact from 'highcharts-react-official';
export const Charts = (): JSX.Element => {
return <></>;
}
I had a similar issue in 14.0.2 using react-highcharts-jsx
which I was able to fix using next/dynamic
with server side rendering disabled to delay loading the Highcharts using component till client side.
Weirdly it seems to only occur with some highcharts usage, not all.
Stangely, after deleting my node_modules folder, I am not able to reproduce at build time but now at runtime...
> next start
▲ Next.js 14.0.2
- Local: http://localhost:3000
✓ Ready in 530ms
TypeError: Cannot read properties of undefined (reading 'document')
at D:\Projects\Cloud\frontend\.next\server\chunks\9628.js:1:2975
at 89295 (D:\Projects\Cloud\frontend\.next\server\chunks\9628.js:1:3060)
at t (D:\Projects\Cloud\frontend\.next\server\webpack-runtime.js:1:127)
at 96437 (D:\Projects\Cloud\frontend\.next\server\chunks\6680.js:1:1256)
at t (D:\Projects\Cloud\frontend\.next\server\webpack-runtime.js:1:127)
at 56680 (D:\Projects\Cloud\frontend\.next\server\chunks\6680.js:1:4531)
at t (D:\Projects\Cloud\frontend\.next\server\webpack-runtime.js:1:127)
at 28656 (D:\Projects\Cloud\frontend\.next\server\chunks\8656.js:1:5709)
at t (D:\Projects\Cloud\frontend\.next\server\webpack-runtime.js:1:127)
at 17567 (D:\Projects\Cloud\frontend\.next\server\app\services\assess\page.js:1:2278)
@olsio @abkfenris please check this issue on highcharts, there is some more documentation and workarounds discussed there -> https://github.com/highcharts/highcharts/issues/20129
related to 👉🏼 #58576
any fix for this?
@jonsystems this was fixed on Highcharts' side: https://github.com/highcharts/highcharts/issues/20129
We saw same issue with other libraries and 14.0.4 fixed it.
I'm very curious to know what the change was. It seemed client side code was getting executed server side.
Link to the code that reproduces this issue
https://github.com/olsio/prerender-highcharts
To Reproduce
npm run build
Current vs. Expected behavior
This only happens in 14.0.x releases. When downgrading to 13.5.6 it compiles fine.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure, Standalone mode (output: "standalone")
Additional context
No response