summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonathan Neal <jonathantneal@hotmail.com> 2022-01-25 11:37:06 -0500
committerGravatar GitHub <noreply@github.com> 2022-01-25 11:37:06 -0500
commita764264d29648e31e3d0908343da9e0454ef8e88 (patch)
treef273905265d52e312715522a5e3b06994a06e386
parentce542cbad3c866c098f5ae91b4d56b4c6e7c04cd (diff)
downloadastro-a764264d29648e31e3d0908343da9e0454ef8e88.tar.gz
astro-a764264d29648e31e3d0908343da9e0454ef8e88.tar.zst
astro-a764264d29648e31e3d0908343da9e0454ef8e88.zip
Remove `node-fetch` (#2462)
* remove node-fetch * use webapi polyfill like astro
-rw-r--r--packages/astro/package.json1
-rw-r--r--packages/astro/test/fixtures/fetch/src/components/AlreadyImported.astro4
-rw-r--r--packages/astro/test/test-utils.js7
3 files changed, 6 insertions, 6 deletions
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'
----
-
<span id="already-imported">{typeof fetch}</span>
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