Skip to content

Commit c8937e7

Browse files
authored
V11 release removal of node-fetch and undici dependencies (#8492)
Our v11 release will require node 18+. Since fetch has been introduced in these node versions, we can remove our dependency on third party fetch implementations. This change removes our usage of fetch variants undici and node-fetch for our node target builds and our CI tools.
1 parent a377fb2 commit c8937e7

File tree

36 files changed

+102
-189
lines changed

36 files changed

+102
-189
lines changed

.changeset/plenty-beers-decide.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@firebase/rules-unit-testing': patch
3+
'@firebase/firestore-compat': patch
4+
'@firebase/functions-compat': patch
5+
'@firebase/storage-compat': patch
6+
'@firebase/auth-compat': patch
7+
'@firebase/firestore': patch
8+
'@firebase/functions': patch
9+
'@firebase/storage': patch
10+
'@firebase/auth': patch
11+
---
12+
13+
Removed dependency on undici and node-fetch in our node bundles, replacing them with the native fetch implementation.

integration/messaging/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"express": "4.19.2",
1616
"geckodriver": "2.0.4",
1717
"mocha": "9.2.2",
18-
"undici": "6.19.7",
1918
"selenium-assistant": "6.1.1"
2019
},
2120
"engines": {

integration/messaging/test/utils/sendMessage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
const undici = require('undici');
1918
const FCM_SEND_ENDPOINT = 'https://fcm.googleapis.com/fcm/send';
2019
// Rotatable fcm server key. It's generally a bad idea to expose server keys. The reason is to
2120
// simplify testing process (no need to implement server side decryption of git secret). The
@@ -28,7 +27,7 @@ module.exports = async payload => {
2827
'Requesting to send an FCM message with payload: ' + JSON.stringify(payload)
2928
);
3029

31-
const response = await undici.fetch(FCM_SEND_ENDPOINT, {
30+
const response = await fetch(FCM_SEND_ENDPOINT, {
3231
method: 'POST',
3332
body: JSON.stringify(payload),
3433
headers: {

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
"tslint": "6.1.3",
157157
"typedoc": "0.16.11",
158158
"typescript": "4.7.4",
159-
"undici": "6.19.7",
160159
"watch": "1.0.2",
161160
"webpack": "5.76.0",
162161
"yargs": "17.7.2"

packages/auth-compat/index.node.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323
*/
2424
export * from './index';
2525
import { FetchProvider } from '@firebase/auth/internal';
26-
import {
27-
fetch as undiciFetch,
28-
Headers as undiciHeaders,
29-
Response as undiciResponse
30-
} from 'undici';
3126
import './index';
3227

33-
FetchProvider.initialize(
34-
undiciFetch as unknown as typeof fetch,
35-
undiciHeaders as unknown as typeof Headers,
36-
undiciResponse as unknown as typeof Response
37-
);
28+
FetchProvider.initialize(fetch, Headers, Response);

packages/auth-compat/karma.conf.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ module.exports = function (config) {
3030
// frameworks to use
3131
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
3232
frameworks: ['mocha'],
33-
// undici is a fetch polyfill that test helpers call for Node tests, and browser tests should
34-
// ignore its import to avoid compilation errors in those test helpers.
35-
webpack: {
36-
...webpackBase,
37-
resolve: {
38-
...webpackBase.resolve,
39-
alias: {
40-
'undici': false
41-
}
42-
}
43-
},
44-
4533
client: Object.assign({}, karmaBase.client, getClientConfig())
4634
});
4735

packages/auth-compat/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"@firebase/auth-types": "0.12.2",
5656
"@firebase/component": "0.6.8",
5757
"@firebase/util": "1.9.7",
58-
"undici": "6.19.7",
5958
"tslib": "^2.1.0"
6059
},
6160
"license": "Apache-2.0",

packages/auth/karma.conf.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ module.exports = function (config) {
2727
// frameworks to use
2828
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
2929
frameworks: ['mocha'],
30-
// undici is a fetch polyfill that test helpers call for Node tests, and browser tests should
31-
// ignore its import to avoid compilation errors in those test helpers.
32-
webpack: {
33-
...webpackBase,
34-
resolve: {
35-
...webpackBase.resolve,
36-
alias: {
37-
'undici': false
38-
}
39-
}
40-
},
4130
client: Object.assign({}, karmaBase.client, getClientConfig(argv))
4231
});
4332

packages/auth/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130
"@firebase/component": "0.6.8",
131131
"@firebase/logger": "0.4.2",
132132
"@firebase/util": "1.9.7",
133-
"undici": "6.19.7",
134133
"tslib": "^2.1.0"
135134
},
136135
"license": "Apache-2.0",

packages/auth/src/platform_node/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,9 @@ import { AuthImpl } from '../core/auth/auth_impl';
2828

2929
import { FetchProvider } from '../core/util/fetch_provider';
3030
import { getDefaultEmulatorHost } from '@firebase/util';
31-
import {
32-
fetch as undiciFetch,
33-
Headers as undiciHeaders,
34-
Response as undiciResponse
35-
} from 'undici';
3631

3732
// Initialize the fetch polyfill, the types are slightly off so just cast and hope for the best
38-
FetchProvider.initialize(
39-
undiciFetch as unknown as typeof fetch,
40-
undiciHeaders as unknown as typeof Headers,
41-
undiciResponse as unknown as typeof Response
42-
);
33+
FetchProvider.initialize(fetch, Headers, Response);
4334

4435
// First, we set up the various platform-specific features for Node (register
4536
// the version and declare the Node getAuth function)

0 commit comments

Comments
 (0)