https://github.com/beeequeue/fetch-unfill
Remove `fetch` polyfills from bundles in favor of native implementations
https://github.com/beeequeue/fetch-unfill
Last synced: 6 months ago
JSON representation
Remove `fetch` polyfills from bundles in favor of native implementations
- Host: GitHub
- URL: https://github.com/beeequeue/fetch-unfill
- Owner: beeequeue
- Created: 2023-04-10T14:13:23.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-01T11:45:59.000Z (7 months ago)
- Last Synced: 2025-07-10T00:17:30.597Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 187 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fetch-unfill + unplugin

[](https://www.npmjs.com/package/fetch-unfill)
[](https://www.npmjs.com/package/unplugin-fetch-unfill)
[](https://bundlejs.com/?q=node-fetch%40%5E1&treeshake=%5B%7B+default+%7D%5D)
[](https://bundlejs.com/?q=fetch-unfill&treeshake=%5B%7B+default+%7D%5D)
Removes `fetch` polyfills from your bundles in favor of native implementations.
- ✅ `node-fetch`
- ✅ `node-fetch-native`
- ✅ `cross-fetch`
- ❔ `whatwg-fetch`
- ❔ `unfetch`
- ❌ `@whatwg-node/fetch`
✅: verified ❔: unverified, should work ❌: not removable
## Usage
### Unplugin
Add the plugin to your config's plugin array:
```ts
import { fetchUnfillUnplugin } from "unplugin-fetch-unfill"
// ...
plugins: [
// ...
fetchUnfillUnplugin.{BUNDLER}()
]
```
### Manual Configuration
Install `fetch-unfill` with your package manager.
### Vite
Open
```ts
import { defineConfig } from "vite"
import fetchUnfillAliases from "fetch-unfill/aliases"
export default defineConfig({
resolve: {
alias: {
// Alias any known, replaceable polyfills in use to `fetch-unfill`
...fetchUnfillAliases,
},
},
})
```
### esbuild
Open
```ts
import { build } from "esbuild"
import fetchUnfillAliases from "fetch-unfill/aliases"
await build({
// ...
alias: {
// Alias any known, replaceable polyfills in use to `fetch-unfill`
...fetchUnfillAliases,
},
})
```
### Webpack/Rspack
Open
```ts
import type { Configuration } from "webpack"
import fetchUnfillAliases from "fetch-unfill/aliases"
export default {
// ...
resolve: {
alias: {
// Alias any known, replaceable polyfills in use to `fetch-unfill`
...fetchUnfillAliases,
},
},
} satisfies Configuration
```
### Rolldown
Open
```ts
import type { RolldownOptions } from "rolldown"
import { aliasPlugin } from "rolldown/experimental"
import { rollupAliases } from "fetch-unfill/aliases"
export default {
// ...
plugins: [
// ...
aliasPlugin({
entries: [
// Alias any known, replaceable polyfills in use to `fetch-unfill`
...rollupAliases,
],
}),
],
} satisfies RolldownOptions
```
### Rollup
Open
```ts
import type { RollupOptions } from "rollup"
import Alias from "@rollup/plugin-alias"
import { rollupAliases } from "fetch-unfill/aliases"
export default {
// ...
plugins: [
// ...
Alias({
entries: [
// Alias any known, replaceable polyfills in use to `fetch-unfill`
...rollupAliases,
],
}),
],
} satisfies RollupOptions
```