From 51cd6e643178e3a113fc2c3e8a63755bcbfe902d Mon Sep 17 00:00:00 2001 From: Conner Date: Thu, 9 Feb 2023 02:16:37 -0600 Subject: [PATCH] fix: update polyfills.js to include File (#8925) * Update polyfills.js * Update polyfills.js * Changeset * try this --------- Co-authored-by: Rich Harris --- .changeset/famous-hornets-invite.md | 5 +++++ packages/kit/src/exports/node/polyfills.js | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/famous-hornets-invite.md diff --git a/.changeset/famous-hornets-invite.md b/.changeset/famous-hornets-invite.md new file mode 100644 index 000000000000..7dec00bed289 --- /dev/null +++ b/.changeset/famous-hornets-invite.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +chore: polyfill File from node:buffer diff --git a/packages/kit/src/exports/node/polyfills.js b/packages/kit/src/exports/node/polyfills.js index 28f9de5f9d9d..950c645258bc 100644 --- a/packages/kit/src/exports/node/polyfills.js +++ b/packages/kit/src/exports/node/polyfills.js @@ -1,6 +1,10 @@ import { ReadableStream, TransformStream, WritableStream } from 'node:stream/web'; +import buffer from 'node:buffer'; import { webcrypto as crypto } from 'node:crypto'; -import { fetch, Response, Request, Headers, FormData } from 'undici'; +import { fetch, Response, Request, Headers, FormData, File as UndiciFile } from 'undici'; + +// @ts-expect-error +const File = buffer.File ?? UndiciFile; /** @type {Record} */ const globals = { @@ -12,7 +16,8 @@ const globals = { ReadableStream, TransformStream, WritableStream, - FormData + FormData, + File }; // exported for dev/preview and node environments