I'd like to import dat.gui in my Next.js project, but when importing it the normal way (import * as dat from "dat.gui), I get the error "window is not defined", so apparently the script references the window object somewhere in the initialization. One way to circumvent this is using dynamic imports, but as far as I understand, this means the code from the library is not bundled in the page build but dynamically imported after the page script loaded and started to execute.
It is basically fine, but might be a little bit slower, and also cumbersome to work with as I need to do everything which references the library after the loading process finished. So I wonder, is it also possible to include a library such a dat.gui in the build without running the initialization on the server? Or is my understanding of dynamic imports totally wrong?