Cannot assign to readonly property 'clip' of object '#<CanvasRenderingContext2D'
Hello, I'm trying to use this library, for NextJS server-side rendering for a ChartJS plugin that requires Path2D to work. However, when I build the project I get the following error when adding the polyfill.
node_modules\path2d\dist\index.js (468:41) @ applyPath2DToCanvasRenderingContext
TypeError: Cannot assign to readonly property 'clip' of object '#<CanvasRenderingContext2D>'
Dependency Versions:
{
...
"dependencies": {
"canvas": "^3.0.0-rc2",
"chart.js": "^4.4.3",
"chartjs-plugin-annotations": "^3.0.1",
"next": "13.5.6",
"path2d": "^0.2.1",
...
}
...
}
Looks like your version of CanvasRenderingContext2D has readonly properties. If that's the case, the polyfill will work bad.
Can you post a reproducing example perhaps?
I started getting the same error that loads this package in a node environment. There was no error when running node 18, but the error showed up when upgrading to node 20. Did node 20 make these properties read-only?
I believe this is not an issue anymore, please let me know if that's not the case.