Skip to content

Commit cf830e6

Browse files
author
Nick Galloway
committed
4.0.2-next.3
1 parent 0f530f5 commit cf830e6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/react-scripts/config/webpack.config.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,21 @@ module.exports = function (webpackEnv) {
259259
/* webpack-5-react-scripts end */
260260
// this defaults to 'window', but by setting it to 'this' then
261261
// module chunks which are built will work in web workers as well.
262-
globalObject: 'this',
262+
/* webpack-5-react-scripts start */
263+
// Fix for issue: https://github.com/webpack/webpack/issues/6525#issuecomment-552140798
264+
// globalObject: 'this',
265+
globalObject: `(() => {
266+
if (typeof self !== 'undefined') {
267+
return self;
268+
} else if (typeof window !== 'undefined') {
269+
return window;
270+
} else if (typeof global !== 'undefined') {
271+
return global;
272+
} else {
273+
return Function('return this')();
274+
}
275+
})()`,
276+
/* webpack-5-react-scripts end */
263277
},
264278
optimization: {
265279
minimize: isEnvProduction,

packages/react-scripts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-5-react-scripts",
3-
"version": "4.0.2-next.2",
3+
"version": "4.0.2-next.3",
44
"description": "Configuration and scripts for Create React App using Webpack 5.",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)