diff --git a/packages/astro/package.json b/packages/astro/package.json index 067e30813..07e88ddaf 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -86,7 +86,6 @@ "magic-string": "^0.25.7", "mime": "^3.0.0", "morphdom": "^2.6.1", - "node-fetch": "^3.0.0", "parse5": "^6.0.1", "path-to-regexp": "^6.2.0", "postcss": "^8.3.8", diff --git a/packages/astro/test/fixtures/fetch/src/components/AlreadyImported.astro b/packages/astro/test/fixtures/fetch/src/components/AlreadyImported.astro index 486eeacaa..40dd58012 100644 --- a/packages/astro/test/fixtures/fetch/src/components/AlreadyImported.astro +++ b/packages/astro/test/fixtures/fetch/src/components/AlreadyImported.astro @@ -1,5 +1 @@ ---- -import fetch from 'node-fetch' ---- - {typeof fetch} diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js index 18c83d506..88b46908d 100644 --- a/packages/astro/test/test-utils.js +++ b/packages/astro/test/test-utils.js @@ -1,5 +1,5 @@ import { execa } from 'execa'; -import fetch from 'node-fetch'; +import { polyfill } from '@astropub/webapi'; import fs from 'fs'; import { fileURLToPath } from 'url'; import { loadConfig } from '../dist/core/config.js'; @@ -8,6 +8,11 @@ import build from '../dist/core/build/index.js'; import preview from '../dist/core/preview/index.js'; import os from 'os'; +// polyfill WebAPIs to globalThis for Node v12, Node v14, and Node v16 +polyfill(globalThis, { + exclude: 'window document', +}); + /** * @typedef {import('node-fetch').Response} Response * @typedef {import('../src/core/dev/index').DevServer} DevServer