I have a react app and a components library. Library uses webpack and compiled into umd and uses react and react-dom as externals. Now I want to use it with another project which has Next.js SSR.
I can import components using next/dynamic
and they work fine. But lib also has non-component stuff like breakpoints and colors and when I try to import them inside SSR, it complains ReferenceError: self is not defined
. Lib's compiled code has self
keyword in it. So it seems whenever I try to import breakpoints, next try to run library code server-side and throws.
Cannot use next/dynamic
with non-components as it's only for components. I tried conditional import by checking process.browser
but failed.
Any thoughts?