Skip to content

Commit

Permalink
feat(remix-node)!: don't export fetch API
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Aug 31, 2023
1 parent ea0ecd6 commit 2fa9c01
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-items-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/node": major
---

Don't export fetch API
21 changes: 3 additions & 18 deletions packages/remix-node/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import type { Readable } from "node:stream";
import type { Headers as WebHeaders } from "@remix-run/web-fetch";
import {
fetch as webFetch,
Headers as WebHeaders,
Request as WebRequest,
Response as WebResponse,
} from "@remix-run/web-fetch";
export { FormData } from "@remix-run/web-fetch";
// @ts-ignore
export { File, Blob } from "@remix-run/web-file";

type NodeHeadersInit = ConstructorParameters<typeof WebHeaders>[0];
type NodeResponseInfo = ConstructorParameters<typeof WebResponse>[0];
type NodeResponseInit = NonNullable<
ConstructorParameters<typeof WebResponse>[1]
Expand All @@ -26,13 +22,6 @@ type NodeRequestInit = Omit<
| Readable;
};

export type {
NodeHeadersInit as HeadersInit,
NodeRequestInfo as RequestInfo,
NodeRequestInit as RequestInit,
NodeResponseInit as ResponseInit,
};

interface NodeRequest extends WebRequest {
get headers(): WebHeaders;

Expand All @@ -54,11 +43,7 @@ const NodeResponse = WebResponse as unknown as new (
init?: NodeResponseInit
) => NodeResponse;

export {
WebHeaders as Headers,
NodeRequest as Request,
NodeResponse as Response,
};
export { NodeRequest as Request, NodeResponse as Response };

export const fetch: typeof webFetch = (
info: NodeRequestInfo,
Expand All @@ -71,5 +56,5 @@ export const fetch: typeof webFetch = (
...init,
};

return webFetch(info, init as RequestInit);
return webFetch(info, init as NodeRequestInit);
};
9 changes: 5 additions & 4 deletions packages/remix-node/globals.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
FormData as NodeFormData,
Headers as NodeHeaders,
} from "@remix-run/web-fetch";
import { Blob as NodeBlob, File as NodeFile } from "@remix-run/web-file";
import {
ByteLengthQueuingStrategy as NodeByteLengthQueuingStrategy,
CountQueuingStrategy as NodeCountQueuingStrategy,
Expand All @@ -16,10 +21,6 @@ import {

import { atob, btoa } from "./base64";
import {
Blob as NodeBlob,
File as NodeFile,
FormData as NodeFormData,
Headers as NodeHeaders,
Request as NodeRequest,
Response as NodeResponse,
fetch as nodeFetch,
Expand Down
8 changes: 0 additions & 8 deletions packages/remix-node/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
export type {
HeadersInit,
RequestInfo,
RequestInit,
ResponseInit,
} from "./fetch";
export { fetch, FormData, Headers, Request, Response } from "./fetch";

export { installGlobals } from "./globals";

export { createFileSessionStorage } from "./sessions/fileStorage";
Expand Down

0 comments on commit 2fa9c01

Please sign in to comment.