Skip to content

Commit 6d23136

Browse files
committed
build: lock file maintenance
See associated pull request for more information. Closes #30625 as a pr takeover
1 parent 7da683d commit 6d23136

File tree

2 files changed

+562
-655
lines changed

2 files changed

+562
-655
lines changed

packages/angular/build/src/utils/index-file/inline-fonts.ts

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { HttpsProxyAgent } from 'https-proxy-agent';
1010
import { createHash } from 'node:crypto';
1111
import { readFile, rm, writeFile } from 'node:fs/promises';
12-
import * as https from 'node:https';
12+
import { Agent, get as httpsGet } from 'node:https';
1313
import { join } from 'node:path';
1414
import { NormalizedCachedOptions } from '../normalize-cache';
1515
import { htmlRewritingStream } from './html-rewriting-stream';
@@ -194,56 +194,55 @@ export class InlineFontsProcessor {
194194
} catch {}
195195
}
196196

197-
let agent: HttpsProxyAgent<string> | undefined;
197+
let agent: Agent | undefined;
198198
const httpsProxy = process.env.HTTPS_PROXY ?? process.env.https_proxy;
199199

200200
if (httpsProxy) {
201-
agent = new HttpsProxyAgent(httpsProxy);
201+
// TODO(alanagius): remove casting https://github.com/TooTallNate/proxy-agents/issues/379 is fixed.
202+
agent = new HttpsProxyAgent(httpsProxy) as Agent;
202203
}
203204

204205
const data = await new Promise<string>((resolve, reject) => {
205206
let rawResponse = '';
206-
https
207-
.get(
208-
url,
209-
{
210-
agent,
211-
headers: {
212-
/**
213-
* Always use a Windows UA. This is because Google fonts will including hinting in fonts for Windows.
214-
* Hinting is a technique used with Windows files to improve appearance however
215-
* results in 20-50% larger file sizes.
216-
*
217-
* @see http://google3/java/com/google/fonts/css/OpenSansWebFontsCssBuilder.java?l=22
218-
* @see https://fonts.google.com/knowledge/glossary/hinting (short)
219-
* @see https://glyphsapp.com/learn/hinting-manual-truetype-hinting (deep dive)
220-
*/
221-
'user-agent':
222-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
223-
},
207+
httpsGet(
208+
url,
209+
{
210+
agent,
211+
headers: {
212+
/**
213+
* Always use a Windows UA. This is because Google fonts will including hinting in fonts for Windows.
214+
* Hinting is a technique used with Windows files to improve appearance however
215+
* results in 20-50% larger file sizes.
216+
*
217+
* @see http://google3/java/com/google/fonts/css/OpenSansWebFontsCssBuilder.java?l=22
218+
* @see https://fonts.google.com/knowledge/glossary/hinting (short)
219+
* @see https://glyphsapp.com/learn/hinting-manual-truetype-hinting (deep dive)
220+
*/
221+
'user-agent':
222+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
224223
},
225-
(res) => {
226-
if (res.statusCode !== 200) {
227-
reject(
228-
new Error(
229-
`Inlining of fonts failed. ${url} returned status code: ${res.statusCode}.`,
230-
),
231-
);
232-
233-
return;
234-
}
235-
236-
res.on('data', (chunk) => (rawResponse += chunk)).on('end', () => resolve(rawResponse));
237-
},
238-
)
239-
.on('error', (e) =>
240-
reject(
241-
new Error(
242-
`Inlining of fonts failed. An error has occurred while retrieving ${url} over the internet.\n` +
243-
e.message,
244-
),
224+
},
225+
(res) => {
226+
if (res.statusCode !== 200) {
227+
reject(
228+
new Error(
229+
`Inlining of fonts failed. ${url} returned status code: ${res.statusCode}.`,
230+
),
231+
);
232+
233+
return;
234+
}
235+
236+
res.on('data', (chunk) => (rawResponse += chunk)).on('end', () => resolve(rawResponse));
237+
},
238+
).on('error', (e) =>
239+
reject(
240+
new Error(
241+
`Inlining of fonts failed. An error has occurred while retrieving ${url} over the internet.\n` +
242+
e.message,
245243
),
246-
);
244+
),
245+
);
247246
});
248247

249248
if (cacheFile) {

0 commit comments

Comments
 (0)