From 50e174df0acc0c53aa77ae76a14069aa48460f0b Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Fri, 27 Oct 2023 13:10:51 +0200 Subject: [PATCH] chore(deps): remove `cross-fetch` dependency --- .../fbjs-scripts/third-party-module-map.json | 1 - packages/fbjs/package.json | 1 - .../src/__forks__/__tests__/fetch-test.js | 18 ++--------- packages/fbjs/src/__forks__/fetch.js | 9 +----- packages/fbjs/yarn.lock | 32 ------------------- 5 files changed, 3 insertions(+), 58 deletions(-) diff --git a/packages/fbjs-scripts/third-party-module-map.json b/packages/fbjs-scripts/third-party-module-map.json index d131657b..9fdeea67 100644 --- a/packages/fbjs-scripts/third-party-module-map.json +++ b/packages/fbjs-scripts/third-party-module-map.json @@ -1,5 +1,4 @@ { - "cross-fetch": "cross-fetch", "fbjs-css-vars": "fbjs-css-vars", "isomorphic-fetch": "isomorphic-fetch", "object-assign": "object-assign", diff --git a/packages/fbjs/package.json b/packages/fbjs/package.json index 09b3180d..4b6164dd 100644 --- a/packages/fbjs/package.json +++ b/packages/fbjs/package.json @@ -63,7 +63,6 @@ ] }, "dependencies": { - "cross-fetch": "^3.1.5", "fbjs-css-vars": "^1.0.0", "loose-envify": "^1.0.0", "object-assign": "^4.1.0", diff --git a/packages/fbjs/src/__forks__/__tests__/fetch-test.js b/packages/fbjs/src/__forks__/__tests__/fetch-test.js index 7f548fa1..6a077e5d 100644 --- a/packages/fbjs/src/__forks__/__tests__/fetch-test.js +++ b/packages/fbjs/src/__forks__/__tests__/fetch-test.js @@ -10,9 +10,6 @@ 'use strict'; jest.unmock('fetch'); -jest.mock('cross-fetch'); - -const fetchImpl = require('cross-fetch'); describe('fetch', function() { afterEach(() => { @@ -23,23 +20,12 @@ describe('fetch', function() { it('works with global fetch', () => { const fetchMock = jest.fn(); - global.fetch = fetchMock; + globalThis.fetch = fetchMock; const fetch = require('fetch'); fetch(); expect(fetchMock).toHaveBeenCalled(); - expect(fetchImpl).not.toHaveBeenCalled(); - - delete global.fetch; - }); - - it('uses ponyfill without global fetch', () => { - // If node ever gets a global fetch, we'll start failing this case. - expect(global.fetch).toBeUndefined(); - - const fetch = require('fetch'); - fetch(); - expect(fetchImpl).toHaveBeenCalled(); + delete globalThis.fetch; }); }); diff --git a/packages/fbjs/src/__forks__/fetch.js b/packages/fbjs/src/__forks__/fetch.js index be064fa1..0d8a9319 100644 --- a/packages/fbjs/src/__forks__/fetch.js +++ b/packages/fbjs/src/__forks__/fetch.js @@ -9,11 +9,4 @@ 'use strict'; -// This hopefully supports the React Native case, which is already bringing along -// its own fetch polyfill. That should exist on `global`. If that doesn't exist -// then we'll try to ponyfill, which might not work correctly in all environments. -if (global.fetch) { - module.exports = global.fetch.bind(global); -} else { - module.exports = require('cross-fetch'); -} +module.exports = globalThis.fetch.bind(globalThis); diff --git a/packages/fbjs/yarn.lock b/packages/fbjs/yarn.lock index 9a2b6070..9fca248b 100644 --- a/packages/fbjs/yarn.lock +++ b/packages/fbjs/yarn.lock @@ -1538,13 +1538,6 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-fetch@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" - integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== - dependencies: - node-fetch "2.6.7" - cross-spawn@^5.0.1, cross-spawn@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -3876,13 +3869,6 @@ next-tick@~1.0.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= -node-fetch@2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -5232,11 +5218,6 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" @@ -5476,11 +5457,6 @@ watch@~0.18.0: exec-sh "^0.2.0" minimist "^1.2.0" -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" @@ -5498,14 +5474,6 @@ whatwg-mimetype@^2.1.0: resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.2.0.tgz#a3d58ef10b76009b042d03e25591ece89b88d171" integrity sha512-5YSO1nMd5D1hY3WzAQV3PzZL83W3YeyR1yW9PcH26Weh1t+Vzh9B6XkDh7aXm83HBZ4nSMvkjvN2H2ySWIvBgw== -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - whatwg-url@^6.4.1: version "6.5.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8"