Skip to content

[Replacement]: fetch-blob and formdata-polyfill #1309

Backlog

Description

@maksimgm

Package to replace

fetch-blob, formdata-polyfill

Package link

https://npmx.dev/package/fetch-blob
https://npmx.dev/package/formdata-polyfill

Native replacement(s)

Blob, File and FormData (globals), fs.openAsBlob for fetch-blob/from.js

Documentation

https://developer.mozilla.org/en-US/docs/Web/API/Blob
https://developer.mozilla.org/en-US/docs/Web/API/File
https://developer.mozilla.org/en-US/docs/Web/API/FormData
https://nodejs.org/api/fs.html#fsopenasblobpath-options

Availability

Blob and FormData are globals since Node.js v18, File since v20, fs.openAsBlob since v19.8. all available in Deno, Bun and modern browsers

Rationale

both are polyfills that come in through node-fetch@3 (~97M weekly downloads each). node-fetch is already in the manifests, but these get installed on their own too. blobFrom(path) and openAsBlob(path) gave the same contents, and formdata-polyfill's formDataToBlob(fd) is new Response(fd).blob() natively. fileFrom doesn't have a one-call native version, it'd be new File([await openAsBlob(path)], name)

Code example (optional)

import { Blob } from 'fetch-blob' // [!code --]
import { FormData } from 'formdata-polyfill/esm.min.js' // [!code --]

const form = new FormData()
form.append('file', new Blob(['hello']), 'hello.txt')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions