Skip to content

Commit 0c9c97a

Browse files
gshilinTimer
authored andcommittedNov 13, 2018
Don't polyfill fetch for Node -- additional files (#5789)
1 parent 1d8d9ea commit 0c9c97a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed
 

‎packages/react-app-polyfill/ie11.js

+6-2
Original file line numberDiff line numberDiff 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.

‎packages/react-app-polyfill/ie9.js

+6-2
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)
Please sign in to comment.