Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Side Rendering creates global "window" object during import #1335

Closed
ex3ndr opened this issue Jan 23, 2018 · 4 comments
Closed

Server Side Rendering creates global "window" object during import #1335

ex3ndr opened this issue Jan 23, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@ex3ndr
Copy link

ex3ndr commented Jan 23, 2018

Right after importing react-map-gl object "window"object "window" in the global scope appears and this breaks a lot of stuff on the server side.

console.warn(typeof window);
import 'deck.gl';
console.warn(typeof window);

Will output

undefined
deck.gl 5.0.2 - set deck.log.priority=1 (or higher) to trace attribute updates
object

Workaround is to use dynamic imports and do not import deck.gl directly.

@ibgreen ibgreen added the bug label Jan 23, 2018
@ibgreen
Copy link
Collaborator

ibgreen commented Jan 23, 2018

@ex3ndr Confirmed. I put a "breakpoint". looks like the problem is in webgl-debug module, which is imported by luma.gl .

  • One starting point could be to file a bug on webgl-debug.
  • Another to file a bug on luma.gl, we could work around by restoring window to whatever it was before importing webgl-debug.

Error: here
at set (/Users/ib/Documents/deck.gl/test/node.js:37:25)
at /Users/ib/Documents/deck.gl/node_modules/webgl-debug/index.js:32:12

@ex3ndr ex3ndr changed the title Server Side Rendering creates global "window" object during import. Server Side Rendering creates global "window" object during import Jan 23, 2018
@ex3ndr
Copy link
Author

ex3ndr commented Jan 23, 2018

Workaround (canUseDom is my helper variable):

let w = typeof window === 'undefined' ? undefined : window;
import * as Deck from 'deck.gl';
if (!canUseDOM) {
    window = w;
}

@ibgreen ibgreen added this to the V 5.1.0 milestone Jan 23, 2018
@ibgreen ibgreen added the P1 label Jan 23, 2018
@ex3ndr
Copy link
Author

ex3ndr commented Jan 24, 2018

Seems to be fixed at webgl-debug!

@1chandu
Copy link
Contributor

1chandu commented Jan 24, 2018

CC: @ex3ndr
Closing this , opened this issue on luma.gl : visgl/luma.gl#394

@1chandu 1chandu closed this as completed Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants