Skip to content

Commit 8f50b2c

Browse files
committed
fix(deps): remove node-fetch and abortcontroller-polyfill, upgrade uuid
1 parent 91587ca commit 8f50b2c

File tree

8 files changed

+21
-89
lines changed

8 files changed

+21
-89
lines changed

plugin/package-lock.json

Lines changed: 13 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,19 @@
4242
"dependencies": {
4343
"@netlify/functions": "^1.6.0",
4444
"@netlify/ipx": "^1.4.6",
45-
"abortcontroller-polyfill": "^1.7.3",
4645
"chalk": "^4.1.2",
4746
"co-body": "^6.1.0",
4847
"cookie": "^0.7.0",
4948
"etag": "^1.8.1",
5049
"fs-extra": "^10.0.0",
5150
"linkfs": "^2.1.0",
5251
"multer": "^2.0.0",
53-
"node-fetch": "^2.6.1",
5452
"node-stream-zip": "^1.15.0",
5553
"pathe": "^0.3.0",
5654
"pretty-bytes": "^5.6.0",
5755
"semver": "^7.3.5",
5856
"statuses": "^2.0.1",
59-
"uuid": "^9.0.0"
57+
"uuid": "^11.1.0"
6058
},
6159
"devDependencies": {
6260
"@gatsbyjs/reach-router": "^2.0.0",

plugin/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import path from 'path'
22
import process from 'process'
3-
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
43

54
import { NetlifyPluginOptions } from '@netlify/build'
65
import { stripIndent } from 'common-tags'
76
import { existsSync } from 'fs-extra'
8-
import fetch from 'node-fetch'
97

108
import { normalizedCacheDir, restoreCache, saveCache } from './helpers/cache'
119
import {

plugin/src/templates/api/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import cookie from 'cookie'
1313
import type { GatsbyFunctionResponse } from 'gatsby'
1414
import { GatsbyFunctionRequest } from 'gatsby'
15-
import fetch, { Headers } from 'node-fetch'
1615
import statuses from 'statuses'
1716

1817
interface NetlifyFunctionParams {
@@ -311,6 +310,6 @@ export const proxyRequest = async (event: HandlerEvent, res) => {
311310
}
312311
}
313312

314-
res.write(await response.buffer())
313+
res.write(Buffer.from(await response.arrayBuffer()))
315314
res.send()
316315
}

plugin/test/fixtures/v4/functions-without-gatsby-plugin/e2e-tests/test-helpers.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable no-unused-vars */
2-
const fetch = require(`node-fetch`)
32
const { readFileSync } = require('fs')
43
const path = require('path')
54

6-
const FormData = require('form-data')
75
// Based on Gatsby Functions integration tests
86
// Source: https://github.com/gatsbyjs/gatsby/blob/master/integration-tests/functions/test-helpers.js
97

plugin/test/fixtures/v5/functions-without-gatsby-plugin/e2e-tests/test-helpers.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable no-unused-vars */
2-
const fetch = require(`node-fetch`)
32
const { readFileSync } = require('fs')
43
const path = require('path')
54

6-
const FormData = require('form-data')
75
// Based on Gatsby Functions integration tests
86
// Source: https://github.com/gatsbyjs/gatsby/blob/master/integration-tests/functions/test-helpers.js
97

plugin/test/fixtures/v5/with-adapters/e2e-tests/test-helpers.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable no-unused-vars */
2-
const fetch = require(`node-fetch`)
32
const { readFileSync } = require('fs')
43
const path = require('path')
54

6-
const FormData = require('form-data')
75
// Based on Gatsby Functions integration tests
86
// Source: https://github.com/gatsbyjs/gatsby/blob/master/integration-tests/functions/test-helpers.js
97

plugin/test/unit/index.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import Chance from 'chance'
77
import { onBuild, onSuccess } from '../../src/index'
88
import { enableGatsbyExcludeDatastoreFromBundle } from '../helpers'
99

10-
jest.mock('node-fetch', () => ({
11-
__esModule: true,
12-
default: jest.fn(),
13-
}))
14-
1510
jest.mock('../../src/helpers/config', () => {
1611
const configObj = jest.requireActual('../../src/helpers/config')
1712

@@ -209,14 +204,18 @@ describe('plugin', () => {
209204
})
210205

211206
describe('onSuccess', () => {
212-
const fetch = require('node-fetch').default
207+
const mockFetch = jest.fn()
208+
const originalFetch = globalThis.fetch
213209

214210
beforeEach(() => {
215-
fetch.mockImplementation(mockFetchMethod)
211+
globalThis.fetch = mockFetch
212+
mockFetch.mockImplementation(mockFetchMethod)
216213
enableGatsbyExcludeDatastoreFromBundle()
217214
})
218215

219216
afterEach(() => {
217+
globalThis.fetch = originalFetch
218+
jest.clearAllMocks()
220219
delete process.env.GATSBY_EXCLUDE_DATASTORE_FROM_BUNDLE
221220
delete process.env.DEPLOY_PRIME_URL
222221
})

0 commit comments

Comments
 (0)