mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
refactor(@angular/build): remove direct usage of undici dependency for SSR
The Node.js types (`@types/node`) now contains the information for the `Response` class and the global `fetch` function. The `Response` object is also globally accessible in all versions of Node.js supported by the Angular CLI. This removes the need to depend directly on the `undici` package. The `undici` package is still used for unit-testing and remains as a development dependency.
This commit is contained in:
parent
4da922e4f4
commit
4286bb03b5
@ -95,7 +95,6 @@ ts_library(
|
||||
"@npm//semver",
|
||||
"@npm//tslib",
|
||||
"@npm//typescript",
|
||||
"@npm//undici",
|
||||
"@npm//vite",
|
||||
"@npm//watchpack",
|
||||
],
|
||||
|
@ -42,7 +42,6 @@
|
||||
"rollup": "4.18.0",
|
||||
"sass": "1.77.6",
|
||||
"semver": "7.6.2",
|
||||
"undici": "6.19.2",
|
||||
"vite": "5.3.3",
|
||||
"watchpack": "2.4.1"
|
||||
},
|
||||
|
@ -10,7 +10,6 @@ import { lookup as lookupMimeType } from 'mrmime';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { extname } from 'node:path';
|
||||
import { workerData } from 'node:worker_threads';
|
||||
import { Response, fetch } from 'undici';
|
||||
|
||||
/**
|
||||
* This is passed as workerData when setting up the worker via the `piscina` package.
|
||||
@ -25,8 +24,7 @@ const assetsCache: Map<string, { headers: undefined | Record<string, string>; co
|
||||
const RESOLVE_PROTOCOL = 'resolve:';
|
||||
|
||||
export function patchFetchToLoadInMemoryAssets(): void {
|
||||
const global = globalThis as unknown as { fetch: typeof fetch };
|
||||
const originalFetch = global.fetch;
|
||||
const originalFetch = globalThis.fetch;
|
||||
const patchedFetch: typeof fetch = async (input, init) => {
|
||||
let url: URL;
|
||||
if (input instanceof URL) {
|
||||
@ -72,5 +70,5 @@ export function patchFetchToLoadInMemoryAssets(): void {
|
||||
});
|
||||
};
|
||||
|
||||
global.fetch = patchedFetch;
|
||||
globalThis.fetch = patchedFetch;
|
||||
}
|
||||
|
@ -198,7 +198,6 @@ ts_library(
|
||||
"@npm//tree-kill",
|
||||
"@npm//tslib",
|
||||
"@npm//typescript",
|
||||
"@npm//undici",
|
||||
"@npm//vite",
|
||||
"@npm//watchpack",
|
||||
"@npm//webpack",
|
||||
|
@ -61,7 +61,6 @@
|
||||
"terser": "5.29.2",
|
||||
"tree-kill": "1.2.2",
|
||||
"tslib": "2.6.3",
|
||||
"undici": "6.19.2",
|
||||
"vite": "5.3.3",
|
||||
"watchpack": "2.4.1",
|
||||
"webpack": "5.92.1",
|
||||
@ -73,6 +72,9 @@
|
||||
"optionalDependencies": {
|
||||
"esbuild": "0.23.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"undici": "6.19.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/compiler-cli": "^18.0.0 || ^18.1.0-next.0",
|
||||
"@angular/localize": "^18.0.0 || ^18.1.0-next.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user