Skip to content

Commit

Permalink
refactor!: always use native fetch in builds (#2527)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Jun 13, 2024
1 parent b32e083 commit 3253d31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
22 changes: 6 additions & 16 deletions src/core/config/resolvers/fetch.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}
4 changes: 0 additions & 4 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 3253d31

Please sign in to comment.