mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 02:54:21 +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//semver",
|
||||||
"@npm//tslib",
|
"@npm//tslib",
|
||||||
"@npm//typescript",
|
"@npm//typescript",
|
||||||
"@npm//undici",
|
|
||||||
"@npm//vite",
|
"@npm//vite",
|
||||||
"@npm//watchpack",
|
"@npm//watchpack",
|
||||||
],
|
],
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
"rollup": "4.18.0",
|
"rollup": "4.18.0",
|
||||||
"sass": "1.77.6",
|
"sass": "1.77.6",
|
||||||
"semver": "7.6.2",
|
"semver": "7.6.2",
|
||||||
"undici": "6.19.2",
|
|
||||||
"vite": "5.3.3",
|
"vite": "5.3.3",
|
||||||
"watchpack": "2.4.1"
|
"watchpack": "2.4.1"
|
||||||
},
|
},
|
||||||
|
@ -10,7 +10,6 @@ import { lookup as lookupMimeType } from 'mrmime';
|
|||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
import { extname } from 'node:path';
|
import { extname } from 'node:path';
|
||||||
import { workerData } from 'node:worker_threads';
|
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.
|
* 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:';
|
const RESOLVE_PROTOCOL = 'resolve:';
|
||||||
|
|
||||||
export function patchFetchToLoadInMemoryAssets(): void {
|
export function patchFetchToLoadInMemoryAssets(): void {
|
||||||
const global = globalThis as unknown as { fetch: typeof fetch };
|
const originalFetch = globalThis.fetch;
|
||||||
const originalFetch = global.fetch;
|
|
||||||
const patchedFetch: typeof fetch = async (input, init) => {
|
const patchedFetch: typeof fetch = async (input, init) => {
|
||||||
let url: URL;
|
let url: URL;
|
||||||
if (input instanceof 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//tree-kill",
|
||||||
"@npm//tslib",
|
"@npm//tslib",
|
||||||
"@npm//typescript",
|
"@npm//typescript",
|
||||||
"@npm//undici",
|
|
||||||
"@npm//vite",
|
"@npm//vite",
|
||||||
"@npm//watchpack",
|
"@npm//watchpack",
|
||||||
"@npm//webpack",
|
"@npm//webpack",
|
||||||
|
@ -61,7 +61,6 @@
|
|||||||
"terser": "5.29.2",
|
"terser": "5.29.2",
|
||||||
"tree-kill": "1.2.2",
|
"tree-kill": "1.2.2",
|
||||||
"tslib": "2.6.3",
|
"tslib": "2.6.3",
|
||||||
"undici": "6.19.2",
|
|
||||||
"vite": "5.3.3",
|
"vite": "5.3.3",
|
||||||
"watchpack": "2.4.1",
|
"watchpack": "2.4.1",
|
||||||
"webpack": "5.92.1",
|
"webpack": "5.92.1",
|
||||||
@ -73,6 +72,9 @@
|
|||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"esbuild": "0.23.0"
|
"esbuild": "0.23.0"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"undici": "6.19.2"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/compiler-cli": "^18.0.0 || ^18.1.0-next.0",
|
"@angular/compiler-cli": "^18.0.0 || ^18.1.0-next.0",
|
||||||
"@angular/localize": "^18.0.0 || ^18.1.0-next.0",
|
"@angular/localize": "^18.0.0 || ^18.1.0-next.0",
|
||||||
|
@ -418,7 +418,6 @@ __metadata:
|
|||||||
rollup: "npm:4.18.0"
|
rollup: "npm:4.18.0"
|
||||||
sass: "npm:1.77.6"
|
sass: "npm:1.77.6"
|
||||||
semver: "npm:7.6.2"
|
semver: "npm:7.6.2"
|
||||||
undici: "npm:6.19.2"
|
|
||||||
vite: "npm:5.3.3"
|
vite: "npm:5.3.3"
|
||||||
watchpack: "npm:2.4.1"
|
watchpack: "npm:2.4.1"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user