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
Add the plugin to your config's plugin array:
import { fetchUnfillUnplugin } from "unplugin-fetch-unfill"
// ...
plugins: [
// ...
fetchUnfillUnplugin.{BUNDLER}()
]
Install fetch-unfill
with your package manager.
Open
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,
},
},
})
Open
import { build } from "esbuild"
import fetchUnfillAliases from "fetch-unfill/aliases"
await build({
// ...
alias: {
// Alias any known, replaceable polyfills in use to `fetch-unfill`
...fetchUnfillAliases,
},
})
Open
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
Open
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
Open
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