Skip to content

Commit f6897fc

Browse files
committed
chore: update .gitignore and improve type imports; add notes for Node.js-only functionality in BaseRestClient
1 parent 6e39e56 commit f6897fc

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ node_modules/
2020
.env.test
2121
.cache
2222
lib
23+
dist
24+
doc
2325
bundleReport.html
2426
.history/
2527
rawReq.ts

src/types/websockets/ws-general.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ClientRequestArgs } from 'http';
1+
import type { ClientRequestArgs } from 'http';
22
import WebSocket from 'isomorphic-ws';
33

44
import { RestClientOptions, WS_KEY_MAP } from '../../util';

src/util/BaseRestClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
3+
// NOTE: https.Agent is Node.js-only and not available in browser environments
4+
// Browser builds (via webpack) exclude this module - see webpack.config.js fallback settings
35
import https from 'https';
46

57
import {
@@ -149,6 +151,9 @@ export default abstract class BaseRestClient {
149151
};
150152

151153
// If enabled, configure a https agent with keepAlive enabled
154+
// NOTE: This is Node.js-only functionality. In browser environments, this code is skipped
155+
// as the 'https' module is excluded via webpack fallback configuration.
156+
// Browser connection pooling is handled automatically by the browser itself.
152157
if (this.options.keepAlive) {
153158
// Extract existing https agent parameters, if provided, to prevent the keepAlive flag from overwriting
154159
// an existing https agent completely

webpack/webpack.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ function generateConfig(name) {
2020
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"],
2121
alias: {
2222
process: "process/browser",
23+
},
24+
fallback: {
25+
// Node.js core modules not available in browsers
26+
// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers
27+
"http": false,
28+
"https": false,
2329
}
2430
},
2531

0 commit comments

Comments
 (0)