diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 3e8ddd149..ecdc73bfa 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -3402,8 +3402,11 @@ export interface LazyCompilationDefaultBackendOptions { * Specifies how to create the server handling the EventSource requests. */ server?: - | (import("https").ServerOptions | import("http").ServerOptions) - | (() => import("net").Server); + | ( + | import("../lib/hmr/lazyCompilationBackend").HttpsServerOptions + | import("../lib/hmr/lazyCompilationBackend").HttpServerOptions + ) + | (() => import("../lib/hmr/lazyCompilationBackend").Server); } /** * Options for compiling entrypoints and import()s only when they are accessed. diff --git a/package.json b/package.json index 257995dda..5b4f32e0b 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@types/glob-to-regexp": "^0.4.4", "@types/jest": "^29.5.11", "@types/mime-types": "^2.1.4", - "@types/node": "^22.0.0", + "@types/node": "^22.13.10", "assemblyscript": "^0.27.34", "babel-loader": "^9.1.3", "benchmark": "^2.1.4", diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 6863ffe88..82d7660da 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -2086,12 +2086,12 @@ "type": "object", "additionalProperties": true, "properties": {}, - "tsType": "(import(\"https\").ServerOptions | import(\"http\").ServerOptions)" + "tsType": "(import(\"../lib/hmr/lazyCompilationBackend\").HttpsServerOptions | import(\"../lib/hmr/lazyCompilationBackend\").HttpServerOptions)" }, { "description": "A custom create server function.", "instanceof": "Function", - "tsType": "(() => import(\"net\").Server)" + "tsType": "(() => import(\"../lib/hmr/lazyCompilationBackend\").Server)" } ] } diff --git a/types.d.ts b/types.d.ts index 879c270b2..03e2cafd0 100644 --- a/types.d.ts +++ b/types.d.ts @@ -85,11 +85,7 @@ import { WithStatement, YieldExpression } from "estree"; -import { - IncomingMessage, - ServerOptions as ServerOptionsImport, - ServerResponse -} from "http"; +import { IncomingMessage, ServerOptions } from "http"; import { ListenOptions, Server } from "net"; import { validate as validateFunction } from "schema-utils"; import { default as ValidationError } from "schema-utils/declarations/ValidationError"; @@ -249,19 +245,19 @@ declare interface ArgumentConfig { values?: any[]; } type ArrayBufferLike = ArrayBuffer | SharedArrayBuffer; -type ArrayBufferView = - | Uint8Array - | Uint8ClampedArray - | Uint16Array - | Uint32Array - | Int8Array - | Int16Array - | Int32Array - | BigUint64Array - | BigInt64Array - | Float32Array - | Float64Array - | DataView; +type ArrayBufferView = + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Int8Array + | Int16Array + | Int32Array + | BigUint64Array + | BigInt64Array + | Float32Array + | Float64Array + | DataView; declare interface Asset { /** * the filename of the asset @@ -876,10 +872,10 @@ type BufferEncoding = | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex"; type BufferEncodingOption = "buffer" | { encoding: "buffer" }; type BuildInfo = KnownBuildInfo & Record; @@ -3957,10 +3953,10 @@ type EncodingOption = | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | ObjectEncodingOptions; type Entry = @@ -5545,7 +5541,7 @@ declare interface HashedModuleIdsPluginOptions { /** * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. */ - hashDigest?: "latin1" | "base64" | "hex"; + hashDigest?: "base64" | "latin1" | "hex"; /** * The prefix length of the hash digest to use, defaults to 4. @@ -5621,6 +5617,9 @@ declare class HttpUriPlugin { */ apply(compiler: Compiler): void; } +type HttpsServerOptions = SecureContextOptions & + TlsOptions & + ServerOptions; type IBigIntStats = IStatsBase & { atimeNs: bigint; mtimeNs: bigint; @@ -5891,15 +5890,15 @@ declare interface IntermediateFileSystemExtras { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | WriteStreamOptions ) => NodeJS.WritableStream; open: Open; - read: Read; + read: Read>; close: ( df: number, callback: (err: null | NodeJS.ErrnoException) => void @@ -8013,8 +8012,8 @@ declare interface LazyCompilationDefaultBackendOptions { * Specifies how to create the server handling the EventSource requests. */ server?: - | ServerOptionsImport - | ServerOptionsHttps + | ServerOptions + | HttpsServerOptions | (() => Server); } @@ -10145,10 +10144,10 @@ declare interface ObjectEncodingOptions { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex"; } declare interface ObjectForExtract { @@ -11369,9 +11368,13 @@ declare interface PathData { url?: string; } type PathLikeFs = string | Buffer | URL; -type PathLikeTypes = string | Buffer | URL_url; +type PathLikeTypes = string | URL_url | Buffer; type PathOrFileDescriptorFs = string | number | Buffer | URL; -type PathOrFileDescriptorTypes = string | number | Buffer | URL_url; +type PathOrFileDescriptorTypes = + | string + | number + | Buffer + | URL_url; type Pattern = | Identifier | MemberExpression @@ -11722,7 +11725,10 @@ declare interface RawSourceMap { mappings: string; file: string; } -declare interface Read { +declare interface Read< + TBuffer extends + ArrayBufferView = ArrayBufferView +> { ( fd: number, buffer: TBuffer, @@ -11749,11 +11755,13 @@ declare interface Read { callback: ( err: null | NodeJS.ErrnoException, bytesRead: number, - buffer: ArrayBufferView + buffer: ArrayBufferView ) => void ): void; } -declare interface ReadAsyncOptions { +declare interface ReadAsyncOptions< + TBuffer extends ArrayBufferView +> { offset?: number; length?: number; position?: null | number | bigint; @@ -11805,6 +11813,7 @@ declare interface ReadFileFs { ( path: PathOrFileDescriptorFs, options: + | ({ encoding: BufferEncoding; flag?: string } & Abortable) | "ascii" | "utf8" | "utf-8" @@ -11812,11 +11821,10 @@ declare interface ReadFileFs { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" - | ({ encoding: BufferEncoding; flag?: string } & Abortable) | "base64" | "base64url" + | "latin1" + | "binary" | "hex", callback: (err: null | NodeJS.ErrnoException, result?: string) => void ): void; @@ -11832,10 +11840,10 @@ declare interface ReadFileFs { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | (ObjectEncodingOptions & { flag?: string } & Abortable), callback: ( @@ -11863,10 +11871,10 @@ declare interface ReadFileSync { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | { encoding: BufferEncoding; flag?: string } ): string; @@ -11881,10 +11889,10 @@ declare interface ReadFileSync { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | (ObjectEncodingOptions & { flag?: string }) ): string | Buffer; @@ -11908,10 +11916,10 @@ declare interface ReadFileTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | ({ encoding: BufferEncoding; flag?: string } & Abortable), callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void @@ -11928,10 +11936,10 @@ declare interface ReadFileTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | (ObjectEncodingOptions & { flag?: string } & Abortable), callback: ( @@ -11957,10 +11965,10 @@ declare interface ReaddirFs { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | { encoding: @@ -11972,10 +11980,10 @@ declare interface ReaddirFs { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex"; withFileTypes?: false; recursive?: boolean; @@ -12005,10 +12013,10 @@ declare interface ReaddirFs { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | (ObjectEncodingOptions & { withFileTypes?: false; @@ -12040,10 +12048,10 @@ declare interface ReaddirSync { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | { encoding: @@ -12055,10 +12063,10 @@ declare interface ReaddirSync { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex"; withFileTypes?: false; recursive?: boolean; @@ -12081,10 +12089,10 @@ declare interface ReaddirSync { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | (ObjectEncodingOptions & { withFileTypes?: false; recursive?: boolean }) ): string[] | Buffer[]; @@ -12109,10 +12117,10 @@ declare interface ReaddirTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | { encoding: @@ -12124,10 +12132,10 @@ declare interface ReaddirTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex"; withFileTypes?: false; recursive?: boolean; @@ -12157,10 +12165,10 @@ declare interface ReaddirTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | (ObjectEncodingOptions & { withFileTypes?: false; @@ -14087,10 +14095,6 @@ declare abstract class SerializerMiddleware { context?: any ): DeserializedType | Promise; } -type ServerOptionsHttps< - Request extends typeof IncomingMessage = typeof IncomingMessage, - Response extends typeof ServerResponse = typeof ServerResponse -> = SecureContextOptions & TlsOptions & ServerOptionsImport; declare class SharePlugin { constructor(options: SharePluginOptions); @@ -15938,10 +15942,10 @@ type WriteFileOptions = | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex" | (ObjectEncodingOptions & Abortable & { mode?: string | number; flag?: string; flush?: boolean }); @@ -15959,10 +15963,10 @@ declare interface WriteStreamOptions { | "utf-16le" | "ucs2" | "ucs-2" - | "latin1" - | "binary" | "base64" | "base64url" + | "latin1" + | "binary" | "hex"; fd?: any; mode?: number; diff --git a/yarn.lock b/yarn.lock index d9b8d552e..dbbcf7830 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1303,12 +1303,12 @@ resolved "https://registry.yarnpkg.com/@types/mime-types/-/mime-types-2.1.4.tgz#93a1933e24fed4fb9e4adc5963a63efcbb3317a2" integrity sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w== -"@types/node@*", "@types/node@^22.0.0": - version "22.5.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.5.tgz#52f939dd0f65fc552a4ad0b392f3c466cc5d7a44" - integrity sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA== +"@types/node@*", "@types/node@^22.13.10": + version "22.13.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.13.10.tgz#df9ea358c5ed991266becc3109dc2dc9125d77e4" + integrity sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw== dependencies: - undici-types "~6.19.2" + undici-types "~6.20.0" "@types/normalize-package-data@^2.4.3": version "2.4.4" @@ -6112,6 +6112,11 @@ undici-types@~6.19.2: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== +undici-types@~6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433" + integrity sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg== + unicorn-magic@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.1.0.tgz#1bb9a51c823aaf9d73a8bfcd3d1a23dde94b0ce4"