From 3253d319dd8cfa48f09529bd479a699dc8968cb2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 14 Jun 2024 00:36:26 +0200 Subject: [PATCH] refactor!: always use native fetch in builds (#2527) --- src/core/config/resolvers/fetch.ts | 22 ++++++---------------- src/types/config.ts | 4 ---- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/core/config/resolvers/fetch.ts b/src/core/config/resolvers/fetch.ts index ad2bbc5e59..b412cca0a3 100644 --- a/src/core/config/resolvers/fetch.ts +++ b/src/core/config/resolvers/fetch.ts @@ -1,21 +1,11 @@ import consola from "consola"; import type { NitroOptions } from "nitro/types"; -import { nodeMajorVersion, provider } from "std-env"; export async function resolveFetchOptions(options: NitroOptions) { - if (options.experimental.nodeFetchCompat === undefined) { - options.experimental.nodeFetchCompat = (nodeMajorVersion || 0) < 18; - if (options.experimental.nodeFetchCompat && provider !== "stackblitz") { - consola.warn( - "Node fetch compatibility is enabled. Please consider upgrading to Node.js >= 18." - ); - } - } - if (!options.experimental.nodeFetchCompat) { - options.alias = { - "node-fetch-native/polyfill": "unenv/runtime/mock/empty", - "node-fetch-native": "node-fetch-native/native", - ...options.alias, - }; - } + // Use native fetch in builds + options.alias = { + "node-fetch-native/polyfill": "unenv/runtime/mock/empty", + "node-fetch-native": "node-fetch-native/native", + ...options.alias, + }; } diff --git a/src/types/config.ts b/src/types/config.ts index 7a9d8dc4ab..814e0c6096 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -116,10 +116,6 @@ export interface NitroOptions extends PresetOptions { * Disable Experimental Sourcemap Minification */ sourcemapMinify?: false; - /** - * Backward compatibility support for Node fetch (required for Node < 18) - */ - nodeFetchCompat?: boolean; /** * Allow env expansion in runtime config *