diff --git a/plugin/package-lock.json b/plugin/package-lock.json index 32fe46e5..1403fc3f 100644 --- a/plugin/package-lock.json +++ b/plugin/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "@netlify/functions": "^1.6.0", "@netlify/ipx": "^1.4.6", - "abortcontroller-polyfill": "^1.7.3", "chalk": "^4.1.2", "co-body": "^6.1.0", "cookie": "^0.7.0", @@ -19,13 +18,12 @@ "fs-extra": "^10.0.0", "linkfs": "^2.1.0", "multer": "^2.0.0", - "node-fetch": "^2.6.1", "node-stream-zip": "^1.15.0", "pathe": "^0.3.0", "pretty-bytes": "^5.6.0", "semver": "^7.3.5", "statuses": "^2.0.1", - "uuid": "^9.0.0" + "uuid": "^11.1.0" }, "devDependencies": { "@gatsbyjs/reach-router": "^2.0.0", @@ -4160,19 +4158,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@netlify/build/node_modules/uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/esm/bin/uuid" - } - }, "node_modules/@netlify/build/node_modules/yaml": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz", @@ -4481,19 +4466,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@netlify/dev-utils/node_modules/uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/esm/bin/uuid" - } - }, "node_modules/@netlify/dev-utils/node_modules/write-file-atomic": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", @@ -4683,19 +4655,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@netlify/edge-bundler/node_modules/uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/esm/bin/uuid" - } - }, "node_modules/@netlify/functions": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-1.6.0.tgz", @@ -7828,7 +7787,8 @@ "node_modules/abortcontroller-polyfill": { "version": "1.7.8", "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.8.tgz", - "integrity": "sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ==" + "integrity": "sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ==", + "dev": true }, "node_modules/accepts": { "version": "1.3.8", @@ -23836,15 +23796,16 @@ } }, "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" ], + "license": "MIT", "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/v8-compile-cache": { @@ -27857,12 +27818,6 @@ "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", "dev": true }, - "uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "dev": true - }, "yaml": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz", @@ -28064,12 +28019,6 @@ "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true }, - "uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "dev": true - }, "write-file-atomic": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", @@ -28199,12 +28148,6 @@ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", "dev": true - }, - "uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "dev": true } } }, @@ -30423,7 +30366,8 @@ "abortcontroller-polyfill": { "version": "1.7.8", "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.8.tgz", - "integrity": "sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ==" + "integrity": "sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ==", + "dev": true }, "accepts": { "version": "1.3.8", @@ -42144,9 +42088,9 @@ "dev": true }, "uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==" }, "v8-compile-cache": { "version": "2.3.0", diff --git a/plugin/package.json b/plugin/package.json index 2dc98407..df49a717 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -42,7 +42,6 @@ "dependencies": { "@netlify/functions": "^1.6.0", "@netlify/ipx": "^1.4.6", - "abortcontroller-polyfill": "^1.7.3", "chalk": "^4.1.2", "co-body": "^6.1.0", "cookie": "^0.7.0", @@ -50,13 +49,12 @@ "fs-extra": "^10.0.0", "linkfs": "^2.1.0", "multer": "^2.0.0", - "node-fetch": "^2.6.1", "node-stream-zip": "^1.15.0", "pathe": "^0.3.0", "pretty-bytes": "^5.6.0", "semver": "^7.3.5", "statuses": "^2.0.1", - "uuid": "^9.0.0" + "uuid": "^11.1.0" }, "devDependencies": { "@gatsbyjs/reach-router": "^2.0.0", diff --git a/plugin/src/index.ts b/plugin/src/index.ts index 22a71be4..9337818b 100644 --- a/plugin/src/index.ts +++ b/plugin/src/index.ts @@ -1,11 +1,9 @@ import path from 'path' import process from 'process' -import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only' import { NetlifyPluginOptions } from '@netlify/build' import { stripIndent } from 'common-tags' import { existsSync } from 'fs-extra' -import fetch from 'node-fetch' import { normalizedCacheDir, restoreCache, saveCache } from './helpers/cache' import { diff --git a/plugin/src/templates/api/utils.ts b/plugin/src/templates/api/utils.ts index ae321233..5c14ce75 100644 --- a/plugin/src/templates/api/utils.ts +++ b/plugin/src/templates/api/utils.ts @@ -12,7 +12,6 @@ import { import cookie from 'cookie' import type { GatsbyFunctionResponse } from 'gatsby' import { GatsbyFunctionRequest } from 'gatsby' -import fetch, { Headers } from 'node-fetch' import statuses from 'statuses' interface NetlifyFunctionParams { @@ -311,6 +310,6 @@ export const proxyRequest = async (event: HandlerEvent, res) => { } } - res.write(await response.buffer()) + res.write(Buffer.from(await response.arrayBuffer())) res.send() } diff --git a/plugin/test/fixtures/v4/functions-without-gatsby-plugin/e2e-tests/test-helpers.js b/plugin/test/fixtures/v4/functions-without-gatsby-plugin/e2e-tests/test-helpers.js index 23228678..34c37074 100644 --- a/plugin/test/fixtures/v4/functions-without-gatsby-plugin/e2e-tests/test-helpers.js +++ b/plugin/test/fixtures/v4/functions-without-gatsby-plugin/e2e-tests/test-helpers.js @@ -1,9 +1,7 @@ /* eslint-disable no-unused-vars */ -const fetch = require(`node-fetch`) const { readFileSync } = require('fs') const path = require('path') -const FormData = require('form-data') // Based on Gatsby Functions integration tests // Source: https://github.com/gatsbyjs/gatsby/blob/master/integration-tests/functions/test-helpers.js diff --git a/plugin/test/fixtures/v5/functions-without-gatsby-plugin/e2e-tests/test-helpers.js b/plugin/test/fixtures/v5/functions-without-gatsby-plugin/e2e-tests/test-helpers.js index 23228678..34c37074 100644 --- a/plugin/test/fixtures/v5/functions-without-gatsby-plugin/e2e-tests/test-helpers.js +++ b/plugin/test/fixtures/v5/functions-without-gatsby-plugin/e2e-tests/test-helpers.js @@ -1,9 +1,7 @@ /* eslint-disable no-unused-vars */ -const fetch = require(`node-fetch`) const { readFileSync } = require('fs') const path = require('path') -const FormData = require('form-data') // Based on Gatsby Functions integration tests // Source: https://github.com/gatsbyjs/gatsby/blob/master/integration-tests/functions/test-helpers.js diff --git a/plugin/test/fixtures/v5/with-adapters/e2e-tests/test-helpers.js b/plugin/test/fixtures/v5/with-adapters/e2e-tests/test-helpers.js index 437f1f69..8bed4ec2 100644 --- a/plugin/test/fixtures/v5/with-adapters/e2e-tests/test-helpers.js +++ b/plugin/test/fixtures/v5/with-adapters/e2e-tests/test-helpers.js @@ -1,9 +1,7 @@ /* eslint-disable no-unused-vars */ -const fetch = require(`node-fetch`) const { readFileSync } = require('fs') const path = require('path') -const FormData = require('form-data') // Based on Gatsby Functions integration tests // Source: https://github.com/gatsbyjs/gatsby/blob/master/integration-tests/functions/test-helpers.js diff --git a/plugin/test/unit/index.spec.ts b/plugin/test/unit/index.spec.ts index 33165404..4699b257 100644 --- a/plugin/test/unit/index.spec.ts +++ b/plugin/test/unit/index.spec.ts @@ -7,11 +7,6 @@ import Chance from 'chance' import { onBuild, onSuccess } from '../../src/index' import { enableGatsbyExcludeDatastoreFromBundle } from '../helpers' -jest.mock('node-fetch', () => ({ - __esModule: true, - default: jest.fn(), -})) - jest.mock('../../src/helpers/config', () => { const configObj = jest.requireActual('../../src/helpers/config') @@ -209,14 +204,18 @@ describe('plugin', () => { }) describe('onSuccess', () => { - const fetch = require('node-fetch').default + const mockFetch = jest.fn() + const originalFetch = globalThis.fetch beforeEach(() => { - fetch.mockImplementation(mockFetchMethod) + globalThis.fetch = mockFetch + mockFetch.mockImplementation(mockFetchMethod) enableGatsbyExcludeDatastoreFromBundle() }) afterEach(() => { + globalThis.fetch = originalFetch + jest.clearAllMocks() delete process.env.GATSBY_EXCLUDE_DATASTORE_FROM_BUNDLE delete process.env.DEPLOY_PRIME_URL })