-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Update polyfills.js to include File #8925
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
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 ?? UndiciFileIn 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 ?? UndiciFileOn Node16 Is this possible currently, since |
ConProgramming
left a comment
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?
dummdidumm
left a comment
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
Fileobject available. Usually this is fine, as any "file" returned byFormDatastill has the normal properties and methods available.The problem became apparent when using
zod-form-data, a library that relies on the globalFileobject.Discussion here.
This is a simple fix, just adds another import from
undicito includeFile.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.