Skip to content

Commit

Permalink
fix: lazy load ProxyAgent to avoid bundling all the undici
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Aug 17, 2024
1 parent faf9cb2 commit 12dca8f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/http-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as ifm from './interfaces'
import * as net from 'net'
import * as pm from './proxy'
import * as tunnel from 'tunnel'
import {ProxyAgent} from 'undici'
import type ProxyAgent from 'undici/types/proxy-agent'

export enum HttpCodes {
OK = 200,
Expand Down Expand Up @@ -722,6 +722,12 @@ export class HttpClient {
}

const usingSsl = parsedUrl.protocol === 'https:'

// Lazy load ProxyAgent to avoid bundling all the undici
const ProxyAgent =
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
require('undici/lib/proxy-agent') as typeof import('undici/types/proxy-agent').default

proxyAgent = new ProxyAgent({
uri: proxyUrl.href,
pipelining: !this._keepAlive ? 0 : 1,
Expand Down

0 comments on commit 12dca8f

Please sign in to comment.