bankai icon indicating copy to clipboard operation
bankai copied to clipboard

Server Side Rendering Skipped due to error: window is not defined

Open EyalSi opened this issue 5 years ago • 4 comments

I have a large app using choo.js and bankai. I'm trying to move from choo 6.0.0 to 6.13.0 & bankai 8.1.1 to 9.15.0 I'm getting the following error when running bankai build: node ./node_modules/bankai/bin.js build index.js

"Server Side Rendering Skipped due to error: window is not defined"

Does anyone have an idea why I'm getting this? everything is working, but wanted to know what is the problem...

EyalSi avatar Oct 05 '18 13:10 EyalSi

for me, it was that I had a reference window in my choo entry point. (even trying to wrap it in like if (window) {...} )

laduke avatar Oct 15 '18 20:10 laduke

this is such persistent issue for me - and clearly for others. I think this should be possible for bankai to handle automatically. Specifically I think it should be possible to make a browserify transform that detects calls to the browser-exclusive API and wraps them automatically in the necessary protection to allow server-side rendering.

Is there any reason not to do this?

blahah avatar Jan 31 '19 14:01 blahah

Also - I really think this needs to be in the README. Bankai errors out with no obvious route to a solution on many of the standard browser libraries. @yoshuawuyts thoughts on documenting it until a better solution is in place?

edit - links to where others eloquently described the problem:

  • https://github.com/choojs/bankai/issues/226#issuecomment-322948009
  • https://github.com/choojs/bankai/issues/226#issuecomment-325221051

blahah avatar Jan 31 '19 14:01 blahah

@blahah PRs to document this would be very welcome. Possibly its own section in the readme, or else as part of a FAQ.

yoshuawuyts avatar Feb 01 '19 13:02 yoshuawuyts