-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update polyfills.js to include File #8925
Conversation
Makes sense to me. Could you please do the |
That was my original solution, but actually this is the const { File: UndiciFile, FileLike, isFileLike } = require('./file')
const { Blob, File: NativeFile } = require('buffer')
/** @type {globalThis['File']} */
const File = NativeFile ?? UndiciFile In node environments like SvelteKit, it'll use the native node I'll add the changeset though. |
You have to use the import from |
Hm well we'd have to do it conditionally like const { File: UndiciFile, FileLike, isFileLike } = require('./file')
const { Blob, File: NativeFile } = require('buffer')
/** @type {globalThis['File']} */
const File = NativeFile ?? UndiciFile On Node16 Is this possible currently, since |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for my uses. Thanks!
I guess then tree shaking doesn't matter for built in node modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Currently there is no global
File
object available. Usually this is fine, as any "file" returned byFormData
still has the normal properties and methods available.The problem became apparent when using
zod-form-data
, a library that relies on the globalFile
object.Discussion here.
This is a simple fix, just adds another import from
undici
to includeFile
.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.