So I am trying to use this library penumbra in a NextJS project. After adding it as a dependency, NextJS will throw an error that window is undefined, which makes sense since it's server-side rendering things and penumbra uses unsafe access to the window object.
This is a common problem in NextJS and the goto solution is to use dynamic imports as documented here.
I tried this approach and the returned result is an empty object:
import("@transcend-io/penumbra").then(mod => {
console.log(mod.default); // empty object, default export
console.log(mod.penumbra); // undefined, named export
})
The weird thing is that this works with other modules say moment for example:
import("moment").then(mod => {
console.log(mod.default()); // returns moment object
})
This leads me to believe that either I am missing something or the module itself is problematic.
Here is a working NextJS example. If you check the logs, moment returns a moment object, but penumbra returns {} for default export and undefined for the named one.