jcoreio / crater

Meteor/Webpack/React SSR app skeleton that runs your app code outside of Meteor Isobuild
ISC License
82 stars 10 forks source link

Using a package that accesses the window object #61

Closed darkadept closed 7 years ago

darkadept commented 7 years ago

I'm trying to use a component that is trying to use the global window object (google-maps-react). In dev mode it works fine, but in prod mode the server webpack config has trouble. Obviously window is not defined on the server.

How does one use these kind of components with SSR?

jedwards1211 commented 7 years ago

It just depends on each component. google-maps-react may not support SSR right now, which wouldn't be too surprising since the google maps api is probably client-side-only. To work around these kinds of issues you can render a loading placeholder if Meteor.isServer.

darkadept commented 7 years ago

Yeah, makes sense.

Is there a way to disable SSR? I don't need it and it's causing more headaches than usefulness.

jedwards1211 commented 7 years ago

Yeah, I don't use it my real project yet either... Just change this line to check some other environment variable or get rid of that block entirely. I should probably make a separate switch for it in this project as well.

jedwards1211 commented 7 years ago

@darkadept sorry, that was not right. Let me dig a bit deeper. I'll try to PR a flag to turn off full SSR right now.