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

[1.1.0]breaks my SSR application #237

Closed
ram-you opened this issue Oct 8, 2017 · 3 comments
Closed

[1.1.0]breaks my SSR application #237

ram-you opened this issue Oct 8, 2017 · 3 comments

Comments

@ram-you
Copy link

ram-you commented Oct 8, 2017

Hello,
because of the using of window variable without test, the new 1.1.0 breaks my VueJS application Server Side Rendered (SSR).

@abiyasa
Copy link

abiyasa commented Oct 9, 2017

Same with me, happened with React.
On my React component, I got an error as soon as it execute the line import Cropper from 'cropperjs';:

Server Error: ReferenceError: window is not defined
    at Object.<anonymous> (/Users/works/superapp/node_modules/cropperjs/dist/cropper.common.js:13:15)
    at Module._compile (module.js:570:32)
    at Module._extensions..js (module.js:579:10)
...

As a workaround on my app, I changed:

import Cropper from 'cropperjs';

to

let Cropper;
if (process.env.BROWSER) {
  Cropper = require('cropperjs');
}

process.env.BROWSER is injected by webpack when it's bundling browser-side code.

@alanct-minted
Copy link

Same over here.

2017-10-09T18:49:53.694163+00:00 app[web.1]: /app/node_modules/cropperjs/dist/cropper.common.js:13
2017-10-09T18:49:53.694178+00:00 app[web.1]: var _window = window;
2017-10-09T18:49:53.694179+00:00 app[web.1]:               ^
2017-10-09T18:49:53.694180+00:00 app[web.1]: 
2017-10-09T18:49:53.694180+00:00 app[web.1]: ReferenceError: window is not defined
2017-10-09T18:49:53.694182+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/cropperjs/dist/cropper.common.js:13:15)
2017-10-09T18:49:53.694183+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-10-09T18:49:53.694183+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-10-09T18:49:53.694184+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-10-09T18:49:53.694185+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-10-09T18:49:53.694185+00:00 app[web.1]:     at Function.Module._load (module.js:438:3)
...

@alanct-minted
Copy link

alanct-minted commented Oct 9, 2017

It seems like this was intentional?

5a86608

@fengyuanchen is window needed even on the server side to render the initial state, or only to handle events, browser detection, and finding other instances on the page? Seems like maybe those could all still be handled safely and get some initial HTML rendered without them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants