[chore] bump undici for multipart form data support
* bump undici in kit, remove node-fetch
* remove node-fetch from adapter-node
It's used in the tests, but those aren't running currently anyway, so
let's revisit this later.
* update lockfile
* update polyfill to use pure undici
* add changeset
ADD
.changeset/funny-elephants-brake.md
+---
+'@sveltejs/kit': patch
+---
+
+[chore] Upgrade undici so that we can use its multipart form data parsing instead of node-fetch's

MODIFY
packages/adapter-node/package.json
packages/adapter-node/package.json
"@sveltejs/kit": "workspace:*",
"@types/node": "^16.11.36",
"c8": "^7.11.3",
- "node-fetch": "^3.2.4",
"polka": "^1.0.0-next.22",
"rimraf": "^3.0.2",
"sirv": "^2.0.2",

MODIFY
packages/kit/package.json
packages/kit/package.json
"kleur": "^4.1.4",
"magic-string": "^0.26.2",
"mime": "^3.0.0",
- "node-fetch": "^3.2.4",
"sade": "^1.8.1",
"set-cookie-parser": "^2.4.8",
"sirv": "^2.0.2",
"tiny-glob": "^0.2.9",
- "undici": "^5.8.1"
+ "undici": "^5.11.0"
},
"devDependencies": {
"@playwright/test": "^1.25.0",

MODIFY
packages/kit/src/exports/node/polyfills.js
packages/kit/src/exports/node/polyfills.js
import { fetch, Response, Request, Headers, FormData } from 'undici';
import { ReadableStream, TransformStream, WritableStream } from 'stream/web';
-import { Readable } from 'stream';
-import { Request as NodeFetchRequest } from 'node-fetch';
import { webcrypto as crypto } from 'crypto';
/** @type {Record<string, any>} */
@@ -9,24 +7,7 @@ const globals = {
crypto,
fetch,
Response,
- // TODO remove the superclass as soon as Undici supports formData
- // https://github.com/nodejs/undici/issues/974
- Request: class extends Request {
- // @ts-expect-error
- async formData() {
- const nodeFetchFormData = await new NodeFetchRequest(this.url, {
- method: this.method,
- headers: this.headers,
- body: this.body && Readable.from(this.body)
- }).formData();
-
- const formData = new FormData();
- for (const [name, value] of nodeFetchFormData.entries()) {
- formData.append(name, value);
- }
- return formData;
- }
- },
+ Request,
Headers,
ReadableStream,
TransformStream,

MODIFY
pnpm-lock.yaml
pnpm-lock.yaml
@@ -120,7 +120,6 @@ importers:
'@sveltejs/kit': workspace:*
'@types/node': ^16.11.36
c8: ^7.11.3
- node-fetch: ^3.2.4
polka: ^1.0.0-next.22
rimraf: ^3.0.2
rollup: ^2.78.1
@@ -136,7 +135,6 @@ importers:
'@sveltejs/kit': link:../kit
'@types/node': 16.11.42
c8: 7.11.3
- node-fetch: 3.2.6
polka: 1.0.0-next.22
rimraf: 3.0.2
sirv: 2.0.2
@@ -282,7 +280,6 @@ importers:
magic-string: ^0.26.2
marked: ^4.0.16
mime: ^3.0.0
- node-fetch: ^3.2.4
rollup: ^2.78.1
sade: ^1.8.1
set-cookie-parser: ^2.4.8
@@ -291,7 +288,7 @@ importers:
svelte-preprocess: ^4.10.6
tiny-glob: ^0.2.9
typescript: ^4.8.2
- undici: ^5.8.1
+ undici: ^5.11.0
uvu: ^0.5.3
vite: ^3.1.1
dependencies:
@@ -302,12 +299,11 @@ importers:
kleur: 4.1.5
magic-string: 0.26.2
mime: 3.0.0
- node-fetch: 3.2.6
sade: 1.8.1
set-cookie-parser: 2.5.0
sirv: 2.0.2
tiny-glob: 0.2.9
- undici: 5.8.1
+ undici: 5.11.0
devDependencies:
'@playwright/test': 1.25.0
'@types/connect': 3.4.35
@@ -1505,6 +1501,13 @@ packages:
resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==}
engines: {node: '>=6'}
+ /busboy/1.6.0:
+ resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==}
+ engines: {node: '>=10.16.0'}
+ dependencies:
+ streamsearch: 1.1.0
+ dev: false
+
/c8/7.11.3:
resolution: {integrity: sha512-6YBmsaNmqRm9OS3ZbIiL2EZgi1+Xc4O24jL3vMYGE6idixYuGdy76rIfIdltSKDj9DpLNrcXSonUTR1miBD0wA==}
engines: {node: '>=10.12.0'}
@@ -1776,10 +1779,6 @@ packages:
stream-transform: 2.1.3
dev: true
- /data-uri-to-buffer/4.0.0:
- resolution: {integrity: sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==}
- engines: {node: '>= 12'}
-
/dataloader/1.4.0:
resolution: {integrity: sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw==}
dev: true
@@ -2218,13 +2217,6 @@ packages:
reusify: 1.0.4
dev: true
- /fetch-blob/3.1.5:
- resolution: {integrity: sha512-N64ZpKqoLejlrwkIAnb9iLSA3Vx/kjgzpcDhygcqJ2KKjky8nCgUQ+dzXtbrLaWZGZNmNfQTsiQ0weZ1svglHg==}
- engines: {node: ^12.20 || >= 14.13}
- dependencies:
- node-domexception: 1.0.0
- web-streams-polyfill: 3.2.1
-
/file-uri-to-path/1.0.0:
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
dev: false
@@ -2277,12 +2269,6 @@ packages:
signal-exit: 3.0.7
dev: true
- /formdata-polyfill/4.0.10:
- resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
- engines: {node: '>=12.20.0'}
- dependencies:
- fetch-blob: 3.1.5
-
/fs-constants/1.0.0:
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
dev: true
@@ -3103,10 +3089,6 @@ packages:
resolution: {integrity: sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==}
dev: true
- /node-domexception/1.0.0:
- resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
- engines: {node: '>=10.5.0'}
-
/node-fetch/2.6.7:
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
engines: {node: 4.x || >=6.0.0}
@@ -3118,14 +3100,6 @@ packages:
dependencies:
whatwg-url: 5.0.0
- /node-fetch/3.2.6:
- resolution: {integrity: sha512-LAy/HZnLADOVkVPubaxHDft29booGglPFDr2Hw0J1AercRh01UiVFm++KMDnJeH9sHgNB4hsXPii7Sgym/sTbw==}
- engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
- dependencies:
- data-uri-to-buffer: 4.0.0
- fetch-blob: 3.1.5
- formdata-polyfill: 4.0.10
-
/node-gyp-build/4.5.0:
resolution: {integrity: sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==}
hasBin: true
@@ -3960,6 +3934,11 @@ packages:
mixme: 0.5.4
dev: true
+ /streamsearch/1.1.0:
+ resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==}
+ engines: {node: '>=10.0.0'}
+ dev: false
+
/string-width/1.0.2:
resolution: {integrity: sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==}
engines: {node: '>=0.10.0'}
@@ -4531,9 +4510,11 @@ packages:
which-boxed-primitive: 1.0.2
dev: true
- /undici/5.8.1:
- resolution: {integrity: sha512-iDRmWX4Zar/4A/t+1LrKQRm102zw2l9Wgat3LtTlTn8ykvMZmAmpq9tjyHEigx18FsY7IfATvyN3xSw9BDz0eA==}
+ /undici/5.11.0:
+ resolution: {integrity: sha512-oWjWJHzFet0Ow4YZBkyiJwiK5vWqEYoH7BINzJAJOLedZ++JpAlCbUktW2GQ2DS2FpKmxD/JMtWUUWl1BtghGw==}
engines: {node: '>=12.18'}
+ dependencies:
+ busboy: 1.6.0
dev: false
/universalify/0.1.2:
@@ -4636,10 +4617,6 @@ packages:
defaults: 1.0.3
dev: true
- /web-streams-polyfill/3.2.1:
- resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==}
- engines: {node: '>= 8'}
-
/webidl-conversions/3.0.1:
resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==}

[chore] bump undici for multipart form data support (#7131)

* bump undici in kit, remove node-fetch

* remove node-fetch from adapter-node

It's used in the tests, but those aren't running currently anyway, so
let's revisit this later.

* update lockfile

* update polyfill to use pure undici

* add changeset