diff --git a/package.json b/package.json index 73f36ceaeb7f..1fb082f1d73c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "lint:js": "pnpm run lint-ci:js --write", "lint-ci:js": "biome check --diagnostic-level=warn --no-errors-on-unmatched --max-diagnostics=none --error-on-warnings", "lint:rs": "cargo clippy --workspace --all-targets", - "lint:type": "rslint --config rslint.json --max-warnings=2278", + "lint:type": "rslint --config rslint.json --max-warnings=2281", "build:binding:dev": "pnpm --filter @rspack/binding run build:dev", "build:binding:debug": "pnpm --filter @rspack/binding run build:debug", "build:binding:ci": "pnpm --filter @rspack/binding run build:ci", diff --git a/packages/rspack/etc/core.api.md b/packages/rspack/etc/core.api.md index 754de0c13790..a5f36d090f8d 100644 --- a/packages/rspack/etc/core.api.md +++ b/packages/rspack/etc/core.api.md @@ -1539,6 +1539,14 @@ function createNativePlugin(name: CustomPluginName, resolve: }; }; +// @public (undocumented) +type CreateReadStream = (path: PathLike, options?: NodeJS.BufferEncoding | ReadStreamOptions) => NodeJS.ReadableStream; + +// @public (undocumented) +type CreateReadStreamFSImplementation = FSImplementation & { + read: (...args: any[]) => any; +}; + // @public (undocumented) type CreateStatsOptionsContext = KnownCreateStatsOptionsContext & Record; @@ -2803,6 +2811,14 @@ interface ForStatement extends Node_4, HasSpan { update?: Expression; } +// @public (undocumented) +interface FSImplementation { + // (undocumented) + close?: (...args: any[]) => any; + // (undocumented) + open?: (...args: any[]) => any; +} + // @public (undocumented) interface FunctionDeclaration extends Fn { // (undocumented) @@ -5381,6 +5397,8 @@ export interface OutputFileSystem { // (undocumented) chmod: (arg0: string, arg1: number, arg2: (arg0?: NodeJS.ErrnoException | null) => void) => void; // (undocumented) + createReadStream?: CreateReadStream; + // (undocumented) dirname?: (arg0: string) => string; // (undocumented) join?: (arg0: string, arg1: string) => string; @@ -5971,6 +5989,12 @@ type ReadlinkSync = { // @public (undocumented) type ReadStream = ReadStream_2; +// @public (undocumented) +type ReadStreamOptions = StreamOptions & { + fs?: null | CreateReadStreamFSImplementation; + end?: number; +}; + // @public (undocumented) type RealPath = { (path: PathLike, options: EncodingOption, callback: StringCallback): void; @@ -7566,6 +7590,26 @@ type StatSyncOptions = { throwIfNoEntry?: boolean; }; +// @public (undocumented) +interface StreamOptions { + // (undocumented) + autoClose?: boolean; + // (undocumented) + emitClose?: boolean; + // (undocumented) + encoding?: NodeJS.BufferEncoding; + // (undocumented) + fd?: any; + // (undocumented) + flags?: string; + // (undocumented) + mode?: number; + // (undocumented) + signal?: null | AbortSignal; + // (undocumented) + start?: number; +} + // @public export type StrictModuleErrorHandling = boolean; diff --git a/packages/rspack/src/util/fs.ts b/packages/rspack/src/util/fs.ts index 372e7848e431..50b0382eb2e6 100644 --- a/packages/rspack/src/util/fs.ts +++ b/packages/rspack/src/util/fs.ts @@ -77,6 +77,36 @@ interface IDirent { name: string | Buffer; } +export interface StreamOptions { + flags?: string; + encoding?: NodeJS.BufferEncoding; + fd?: any; + mode?: number; + autoClose?: boolean; + emitClose?: boolean; + start?: number; + signal?: null | AbortSignal; +} + +export interface FSImplementation { + open?: (...args: any[]) => any; + close?: (...args: any[]) => any; +} + +export type CreateReadStreamFSImplementation = FSImplementation & { + read: (...args: any[]) => any; +}; + +export type ReadStreamOptions = StreamOptions & { + fs?: null | CreateReadStreamFSImplementation; + end?: number; +}; + +export type CreateReadStream = ( + path: PathLike, + options?: NodeJS.BufferEncoding | ReadStreamOptions +) => NodeJS.ReadableStream; + export interface OutputFileSystem { writeFile: ( arg0: string | number, @@ -122,6 +152,7 @@ export interface OutputFileSystem { join?: (arg0: string, arg1: string) => string; relative?: (arg0: string, arg1: string) => string; dirname?: (arg0: string) => string; + createReadStream?: CreateReadStream; } export type JsonPrimitive = string | number | boolean | null;