I'm using a third party package which im loading using next js dynamic:
const am5 = dynamic(() => import("@amcharts/amcharts5"), {ssr: false})
The amcharts5 that it's importing is a bunch of exports and imports
export { Root } from "./.internal/core/Root";
export { Theme } from "./.internal/core/Theme";
export { addLicense, registry, disposeAllRootElements } from "./.internal/core/Registry";
export { ready } from "./.internal/core/util/Utils";
...several other lines and some imports too
However when I run dev/build my application is falling over due to this line below.
let root = am5.Root.new('chart')
The error is
TypeError: Cannot read properties of undefined (reading 'new')
I assume I need to somehow import the Root dynamically too ? I've tried the following already but it didn't work.
const { Root }= dynamic(() =>
import('@amcharts/amcharts5').then((mod) => mod),{ssr:false}
)
And also
const Root = dynamic(() =>
import('@amcharts/amcharts5').then((mod) => mod.Root),{ssr:false}
)
For reference the package documents importing like this (though i need to dynamically import this)
import * as am5 from "@amcharts/amcharts5"
Any help appreciated! :)