yocontra / react-responsive

CSS media queries in react - for responsive design, and more.
https://contra.io/react-responsive
MIT License
7.04k stars 298 forks source link

aws err build arr #244

Closed arsendev closed 4 years ago

arsendev commented 4 years ago

Update to v8.0.2. An error appears. What's the problem?


ReferenceError: window is not defined
--
299 | at Object.<anonymous> (/usr/src/app/node_modules/react-responsive/dist/react-responsive.js:10:4)
macdonst commented 4 years ago

@arsendev I'm pretty sure this is a duplicate of #243. @contra already has pushed a fix to master we can all help verify the fix by testing based on the instructions in #243 which is what I'm about to do.

docccdev commented 4 years ago

This would be a bug in Webpack 4 https://github.com/webpack/webpack/issues/6677. Webpack 3 produces a proper bundle.

This issue should be fixed with this feature, until it's done the suggested workaround is using globalObject https://github.com/webpack/webpack/issues/6525:

output: {
    path: resolve(__dirname, 'umd'),
    filename: 'lib.js',
    libraryTarget: 'umd',
    library: 'lib',
    umdNamedDefine: true,
    globalObject: `(typeof self !== 'undefined' ? self : this)`
}
yocontra commented 4 years ago

Duplicate of #243 - issue has been resolved.