Skip to content

build: lock file maintenance #30679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 39 additions & 46 deletions packages/angular/build/src/utils/index-file/inline-fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { HttpsProxyAgent } from 'https-proxy-agent';
import { createHash } from 'node:crypto';
import { readFile, rm, writeFile } from 'node:fs/promises';
import * as https from 'node:https';
import { Agent, get as httpsGet } from 'node:https';
import { join } from 'node:path';
import { NormalizedCachedOptions } from '../normalize-cache';
import { htmlRewritingStream } from './html-rewriting-stream';
Expand Down Expand Up @@ -194,56 +194,49 @@ export class InlineFontsProcessor {
} catch {}
}

let agent: HttpsProxyAgent<string> | undefined;
const httpsProxy = process.env.HTTPS_PROXY ?? process.env.https_proxy;

if (httpsProxy) {
agent = new HttpsProxyAgent(httpsProxy);
}

const data = await new Promise<string>((resolve, reject) => {
let rawResponse = '';
https
.get(
url,
{
agent,
headers: {
/**
* Always use a Windows UA. This is because Google fonts will including hinting in fonts for Windows.
* Hinting is a technique used with Windows files to improve appearance however
* results in 20-50% larger file sizes.
*
* @see http://google3/java/com/google/fonts/css/OpenSansWebFontsCssBuilder.java?l=22
* @see https://fonts.google.com/knowledge/glossary/hinting (short)
* @see https://glyphsapp.com/learn/hinting-manual-truetype-hinting (deep dive)
*/
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
},
httpsGet(
url,
{
// TODO(alanagius): remove casting https://github.com/TooTallNate/proxy-agents/issues/379 is fixed.
agent: httpsProxy ? (new HttpsProxyAgent(httpsProxy) as Agent) : undefined,
headers: {
/**
* Always use a Windows UA. This is because Google fonts will including hinting in fonts for Windows.
* Hinting is a technique used with Windows files to improve appearance however
* results in 20-50% larger file sizes.
*
* @see http://google3/java/com/google/fonts/css/OpenSansWebFontsCssBuilder.java?l=22
* @see https://fonts.google.com/knowledge/glossary/hinting (short)
* @see https://glyphsapp.com/learn/hinting-manual-truetype-hinting (deep dive)
*/
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
},
(res) => {
if (res.statusCode !== 200) {
reject(
new Error(
`Inlining of fonts failed. ${url} returned status code: ${res.statusCode}.`,
),
);

return;
}

res.on('data', (chunk) => (rawResponse += chunk)).on('end', () => resolve(rawResponse));
},
)
.on('error', (e) =>
reject(
new Error(
`Inlining of fonts failed. An error has occurred while retrieving ${url} over the internet.\n` +
e.message,
),
},
(res) => {
if (res.statusCode !== 200) {
reject(
new Error(
`Inlining of fonts failed. ${url} returned status code: ${res.statusCode}.`,
),
);

return;
}

res.on('data', (chunk) => (rawResponse += chunk)).on('end', () => resolve(rawResponse));
},
).on('error', (e) =>
reject(
new Error(
`Inlining of fonts failed. An error has occurred while retrieving ${url} over the internet.\n` +
e.message,
),
);
),
);
});

if (cacheFile) {
Expand Down
Loading