Using the javascriptservices template with angular2+, I am facing a challenge when it comes to importing libraries into my components that rely on accessing the window object. Since javascript services utilize server-side pre-rendering, importing such libraries directly into components results in a 'window is not defined' error.
Currently, I am attempting to integrate dat.gui into my component but have not yet found a suitable solution. Visit here for more information about dat.gui library
Is there any way to load the dat.gui library on the client-side and then pass it to my component to avoid the 'window is not defined' error upon importing?
This issue persists due to the nature of server side pre-rendering, causing errors whenever the library is added to the component.
const dat = require('dat.gui');
const gui = new dat.GUI();
Alternatively, Import * as dat from ‘dat.gui’;