Skip to content

Commit

Permalink
fix: update polyfills.js to include File (#8925)
Browse files Browse the repository at this point in the history
* Update polyfills.js

* Update polyfills.js

* Changeset

* try this

---------

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
ConProgramming and Rich-Harris committed Feb 9, 2023
1 parent 475ae48 commit 51cd6e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-hornets-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

chore: polyfill File from node:buffer
9 changes: 7 additions & 2 deletions packages/kit/src/exports/node/polyfills.js
Original file line number Diff line number Diff line change
@@ -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<string, any>} */
const globals = {
Expand All @@ -12,7 +16,8 @@ const globals = {
ReadableStream,
TransformStream,
WritableStream,
FormData
FormData,
File
};

// exported for dev/preview and node environments
Expand Down

0 comments on commit 51cd6e6

Please sign in to comment.