Skip to content

Commit

Permalink
fix: remove node: protocol from imports (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Mar 12, 2024
1 parent 17555d0 commit c6f93ee
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .changeset/five-icons-nail.md
@@ -0,0 +1,6 @@
---
"@whatwg-node/node-fetch": patch
"@whatwg-node/server": patch
---

Remove node: protocol which is not supported still in some Node versions and ESM mode
2 changes: 1 addition & 1 deletion e2e/bun/tests/bun.spec.ts
@@ -1,4 +1,4 @@
import { createServer } from 'node:http';
import { createServer } from 'http';
import { afterEach, describe, expect, it } from 'bun:test';
import { createServerAdapter } from '@whatwg-node/server';
import { assertDeployedEndpoint } from '../../shared-scripts/src/index';
Expand Down
2 changes: 1 addition & 1 deletion packages/node-fetch/src/Headers.ts
@@ -1,4 +1,4 @@
import { inspect } from 'node:util';
import { inspect } from 'util';

export type PonyfillHeadersInit = [string, string][] | Record<string, string> | Headers;

Expand Down
2 changes: 1 addition & 1 deletion packages/node-fetch/src/fetchCurl.ts
@@ -1,4 +1,4 @@
import { PassThrough, Readable } from 'node:stream';
import { PassThrough, Readable } from 'stream';
import { PonyfillRequest } from './Request.js';
import { PonyfillResponse } from './Response.js';
import { defaultHeadersSerializer, isNodeReadable } from './utils.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/node-fetch/src/utils.ts
@@ -1,4 +1,4 @@
import { Readable } from 'node:stream';
import { Readable } from 'stream';

function isHeadersInstance(obj: any): obj is Headers {
return obj?.forEach != null;
Expand Down
4 changes: 2 additions & 2 deletions packages/node-fetch/tests/http2.spec.ts
@@ -1,5 +1,5 @@
import { createSecureServer, type Http2SecureServer } from 'node:http2';
import { AddressInfo } from 'node:net';
import { createSecureServer, type Http2SecureServer } from 'http2';
import { AddressInfo } from 'net';
import { CertificateCreationResult, createCertificate } from 'pem';
import { fetchPonyfill } from '../src/fetch';

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/types.ts
@@ -1,4 +1,4 @@
import type { RequestListener } from 'node:http';
import type { RequestListener } from 'http';
import type { NodeRequest, NodeResponse } from './utils.js';
import { UWSHandler, UWSRequest, UWSResponse } from './uwebsockets.js';

Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/utils.ts
@@ -1,7 +1,7 @@
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
import type { Socket } from 'node:net';
import type { Readable } from 'node:stream';
import type { IncomingMessage, ServerResponse } from 'http';
import type { Http2ServerRequest, Http2ServerResponse } from 'http2';
import type { Socket } from 'net';
import type { Readable } from 'stream';
import { URL } from '@whatwg-node/fetch';
import type { FetchEvent } from './types.js';

Expand Down Expand Up @@ -207,7 +207,7 @@ export function normalizeNodeRequest(
bunNodeCompatModeWarned = true;
console.warn(
`You use Bun Node compatibility mode, which is not recommended!
It will affect your performance. Please check our Bun integration recipe, and avoid using 'node:http' for your server implementation.`,
It will affect your performance. Please check our Bun integration recipe, and avoid using 'http' for your server implementation.`,
);
}
return new RequestCtor(fullUrl, {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/uwebsockets.ts
@@ -1,4 +1,4 @@
import type { Readable } from 'node:stream';
import type { Readable } from 'stream';
import type { FetchAPI } from './types.js';
import { ServerAdapterRequestAbortSignal } from './utils.js';

Expand Down
4 changes: 2 additions & 2 deletions packages/server/test/proxy.spec.ts
@@ -1,5 +1,5 @@
import { createServer } from 'node:http';
import { AddressInfo } from 'node:net';
import { createServer } from 'http';
import { AddressInfo } from 'net';
import { fetch } from '@whatwg-node/fetch';
import { createServerAdapter } from '../src/createServerAdapter';
import { runTestsForEachFetchImpl } from './test-fetch';
Expand Down
4 changes: 2 additions & 2 deletions packages/server/test/test-fetch.ts
@@ -1,6 +1,6 @@
/* eslint-disable n/no-callback-literal */
import { globalAgent as httpGlobalAgent } from 'node:http';
import { globalAgent as httpsGlobalAgent } from 'node:https';
import { globalAgent as httpGlobalAgent } from 'http';
import { globalAgent as httpsGlobalAgent } from 'https';

const libcurl = globalThis.libcurl;
export function runTestsForEachFetchImpl(callback: (implementationName: string) => void) {
Expand Down

0 comments on commit c6f93ee

Please sign in to comment.