Closed timnew closed 6 years ago
I guess the issue is caused by next.js
's server-side rendering, that the code is executed in node environment rather than browser one.
Seems to be caused by https://github.com/webpack/webpack/issues/6522, will use one of the work arounds
Mobx-react-devtools
reportsReferenceError: window is not defined
when render the site in Next.jsI tried to wrapped the render code with different guards, but it doesn't help:
In the end, I found the error was yield when import the type rather than render it. By de-uglify the
index.js
I found the issue occurs on iife call, which is executed when the code is required.Not sure how to fix this on the client side, as
import
is executed out of the normal logic flow.Now I worked around it by fork the code and changing
window
in iife to(typeof window === 'undefined' ? global : window)
, looks patched the issue.