From 1ff5bdf1befaa2a0ae5c8deb2b0aa752a7d10da3 Mon Sep 17 00:00:00 2001 From: Hui Zhao <10602282+HuiSF@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:23:44 -0700 Subject: [PATCH] chore(core): remove the isomorphic-unfetch dependency (#12023) --- packages/core/__tests__/clients/fetch.test.ts | 20 ++++++------- packages/core/package.json | 2 -- packages/core/src/clients/handlers/fetch.ts | 1 - yarn.lock | 30 ------------------- 4 files changed, 10 insertions(+), 43 deletions(-) diff --git a/packages/core/__tests__/clients/fetch.test.ts b/packages/core/__tests__/clients/fetch.test.ts index ad8cd6fde52..c3aaef011d0 100644 --- a/packages/core/__tests__/clients/fetch.test.ts +++ b/packages/core/__tests__/clients/fetch.test.ts @@ -1,8 +1,3 @@ -const mockUnfetch = jest.fn(); -jest.mock('isomorphic-unfetch', () => { - global['fetch'] = mockUnfetch; -}); - import { fetchTransferHandler } from '../../src/clients/handlers/fetch'; describe(fetchTransferHandler.name, () => { @@ -25,17 +20,22 @@ describe(fetchTransferHandler.name, () => { url: new URL('https://foo.bar'), }; const mockPayloadValue = 'payload value'; + const mockFetch = jest.fn(); + + beforeAll(() => { + global['fetch'] = mockFetch; + }); beforeEach(() => { jest.clearAllMocks(); - mockUnfetch.mockResolvedValue(mockFetchResponse); + mockFetch.mockResolvedValue(mockFetchResponse); }); test('should support abort signal', async () => { const signal = new AbortController().signal; await fetchTransferHandler(mockRequest, { abortSignal: signal }); - expect(mockUnfetch).toBeCalledTimes(1); - expect(mockUnfetch.mock.calls[0][1]).toEqual( + expect(mockFetch).toBeCalledTimes(1); + expect(mockFetch.mock.calls[0][1]).toEqual( expect.objectContaining({ signal }) ); }); @@ -88,8 +88,8 @@ describe(fetchTransferHandler.name, () => { { ...mockRequest, method, body: 'Mock Body' }, {} ); - expect(mockUnfetch).toBeCalledTimes(1); - expect(mockUnfetch.mock.calls[0][0].body).toBeUndefined(); + expect(mockFetch).toBeCalledTimes(1); + expect(mockFetch.mock.calls[0][0].body).toBeUndefined(); } ); }); diff --git a/packages/core/package.json b/packages/core/package.json index 892c31d4c8b..bf1cb7423cf 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -65,8 +65,6 @@ "@aws-crypto/sha256-js": "5.0.0", "@aws-sdk/types": "3.398.0", "@smithy/util-hex-encoding": "2.0.0", - "@types/node-fetch": "2.6.4", - "isomorphic-unfetch": "^3.0.0", "tslib": "^2.5.0", "uuid": "^9.0.0", "zen-observable-ts": "0.8.19", diff --git a/packages/core/src/clients/handlers/fetch.ts b/packages/core/src/clients/handlers/fetch.ts index d26deb20c3c..245d7e2bebf 100644 --- a/packages/core/src/clients/handlers/fetch.ts +++ b/packages/core/src/clients/handlers/fetch.ts @@ -1,7 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import 'isomorphic-unfetch'; // TODO: remove this dependency in v6 import { HttpRequest, HttpResponse, HttpTransferOptions } from '../types/http'; import { TransferHandler } from '../types/core'; import { withMemoization } from '../utils/memoization'; diff --git a/yarn.lock b/yarn.lock index 93f272b50c3..9258f5ba262 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2761,14 +2761,6 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c" integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ== -"@types/node-fetch@2.6.4": - version "2.6.4" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.4.tgz#1bc3a26de814f6bf466b25aeb1473fa1afe6a660" - integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - "@types/node@*", "@types/node@^20.3.1": version "20.5.7" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.7.tgz#4b8ecac87fbefbc92f431d09c30e176fc0a7c377" @@ -5684,15 +5676,6 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - form-data@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" @@ -7064,14 +7047,6 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== -isomorphic-unfetch@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz#87341d5f4f7b63843d468438128cb087b7c3e98f" - integrity sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q== - dependencies: - node-fetch "^2.6.1" - unfetch "^4.2.0" - isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -12395,11 +12370,6 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" -unfetch@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be" - integrity sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA== - unicode-canonical-property-names-ecmascript@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"