File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
packages/react-app-polyfill Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,12 @@ if (typeof Promise === 'undefined') {
1414 window . Promise = require ( 'promise/lib/es6-extensions.js' ) ;
1515}
1616
17- // fetch() polyfill for making API calls.
18- require ( 'whatwg-fetch' ) ;
17+ // Make sure we're in a Browser-like environment before importing polyfills
18+ // This prevents `fetch()` from being imported in a Node test environment
19+ if ( typeof window !== 'undefined' ) {
20+ // fetch() polyfill for making API calls.
21+ require ( 'whatwg-fetch' ) ;
22+ }
1923
2024// Object.assign() is commonly used with React.
2125// It will use the native implementation if it's present and isn't buggy.
Original file line number Diff line number Diff line change @@ -14,8 +14,12 @@ if (typeof Promise === 'undefined') {
1414 window . Promise = require ( 'promise/lib/es6-extensions.js' ) ;
1515}
1616
17- // fetch() polyfill for making API calls.
18- require ( 'whatwg-fetch' ) ;
17+ // Make sure we're in a Browser-like environment before importing polyfills
18+ // This prevents `fetch()` from being imported in a Node test environment
19+ if ( typeof window !== 'undefined' ) {
20+ // fetch() polyfill for making API calls.
21+ require ( 'whatwg-fetch' ) ;
22+ }
1923
2024// Object.assign() is commonly used with React.
2125// It will use the native implementation if it's present and isn't buggy.
You can’t perform that action at this time.
0 commit comments