@rspack/core 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,6 @@
10
10
  import { type JsLoaderContext, type JsLoaderItem } from "@rspack/binding";
11
11
  import type { Compiler } from "../Compiler";
12
12
  export declare class LoaderObject {
13
- #private;
14
13
  request: string;
15
14
  path: string;
16
15
  query: string;
@@ -21,13 +20,16 @@ export declare class LoaderObject {
21
20
  pitch?: Function;
22
21
  raw?: boolean;
23
22
  type?: "module" | "commonjs";
23
+ parallel?: boolean;
24
+ /**
25
+ * @internal This field is rspack internal. Do not edit.
26
+ */
27
+ loaderItem: JsLoaderItem;
24
28
  constructor(loaderItem: JsLoaderItem, compiler: Compiler);
25
29
  get pitchExecuted(): boolean;
26
30
  set pitchExecuted(value: boolean);
27
31
  get normalExecuted(): boolean;
28
32
  set normalExecuted(value: boolean);
29
- get data(): any;
30
- set data(data: any);
31
33
  shouldYield(): boolean;
32
34
  static __from_binding(loaderItem: JsLoaderItem, compiler: Compiler): LoaderObject;
33
35
  static __to_binding(loader: LoaderObject): JsLoaderItem;
@@ -0,0 +1,71 @@
1
+ import type { Tinypool } from "tinypool" with { "resolution-mode": "import" };
2
+ type RunOptions = Parameters<Tinypool["run"]>[1];
3
+ export interface WorkerResponseMessage {
4
+ type: "response";
5
+ id: number;
6
+ data: any;
7
+ }
8
+ export interface WorkerResponseErrorMessage {
9
+ type: "response-error";
10
+ id: number;
11
+ error: WorkerError;
12
+ }
13
+ interface WorkerDoneMessage {
14
+ type: "done";
15
+ data: WorkerArgs;
16
+ }
17
+ interface WorkerDoneErrorMessage {
18
+ type: "done-error";
19
+ error: WorkerError;
20
+ }
21
+ export interface WorkerRequestMessage {
22
+ type: "request";
23
+ id: number;
24
+ requestType: RequestType;
25
+ data: WorkerArgs;
26
+ }
27
+ export interface WorkerRequestSyncMessage {
28
+ type: "request-sync";
29
+ id: number;
30
+ requestType: RequestSyncType;
31
+ data: WorkerArgs;
32
+ sharedBuffer: SharedArrayBuffer;
33
+ }
34
+ export type WorkerMessage = WorkerResponseMessage | WorkerDoneMessage | WorkerRequestMessage | WorkerResponseErrorMessage | WorkerDoneErrorMessage | WorkerRequestSyncMessage;
35
+ export declare function isWorkerResponseMessage(message: WorkerMessage): message is WorkerResponseMessage;
36
+ export declare function isWorkerResponseErrorMessage(message: WorkerMessage): message is WorkerResponseErrorMessage;
37
+ export declare enum RequestType {
38
+ AddDependency = "AddDependency",
39
+ AddContextDependency = "AddContextDependency",
40
+ AddMissingDependency = "AddMissingDependency",
41
+ AddBuildDependency = "AddBuildDependency",
42
+ GetDependencies = "GetDependencies",
43
+ GetContextDependencies = "GetContextDependencies",
44
+ GetMissingDependencies = "GetMissingDependencies",
45
+ ClearDependencies = "ClearDependencies",
46
+ Resolve = "Resolve",
47
+ GetResolve = "GetResolve",
48
+ GetLogger = "GetLogger",
49
+ EmitError = "EmitError",
50
+ EmitWarning = "EmitWarning",
51
+ EmitFile = "EmitFile",
52
+ EmitDiagnostic = "EmitDiagnostic",
53
+ SetCacheable = "SetCacheable",
54
+ ImportModule = "ImportModule",
55
+ UpdateLoaderObjects = "UpdateLoaderObjects",
56
+ CompilationGetPath = "CompilationGetPath",
57
+ CompilationGetPathWithInfo = "CompilationGetPathWithInfo",
58
+ CompilationGetAssetPath = "CompilationGetAssetPath",
59
+ CompilationGetAssetPathWithInfo = "CompilationGetAssetPathWithInfo"
60
+ }
61
+ export declare enum RequestSyncType {
62
+ WaitForPendingRequest = "WaitForPendingRequest"
63
+ }
64
+ export type HandleIncomingRequest = (requestType: RequestType, ...args: any[]) => Promise<any> | any;
65
+ type WorkerArgs = any[];
66
+ export type WorkerError = Error;
67
+ export declare function serializeError(error: unknown): WorkerError;
68
+ export declare const run: (task: any, options: RunOptions & {
69
+ handleIncomingRequest: HandleIncomingRequest;
70
+ }) => Promise<WorkerArgs>;
71
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { LoaderObject } from ".";
2
+ import type { LoaderContext } from "../config/adapterRuleUse";
3
+ export declare function convertArgs(args: any[], raw: boolean): void;
4
+ export declare const loadLoader: (loaderObject: LoaderObject) => Promise<void>;
5
+ export declare const runSyncOrAsync: (arg1: Function, arg2: LoaderContext<{}>, arg3: any[]) => Promise<any[]>;
@@ -0,0 +1,14 @@
1
+ import { type MessagePort } from "node:worker_threads";
2
+ import { JsLoaderState } from "@rspack/binding";
3
+ import type { LoaderContext } from "../config";
4
+ interface WorkerOptions {
5
+ loaderContext: LoaderContext;
6
+ loaderState: JsLoaderState;
7
+ args: any[];
8
+ workerData?: {
9
+ workerPort: MessagePort;
10
+ workerSyncPort: MessagePort;
11
+ };
12
+ }
13
+ declare function worker(workerOptions: WorkerOptions): void;
14
+ export = worker;
@@ -4,7 +4,7 @@ export declare function mapValues(record: Record<string, string>, fn: (key: stri
4
4
  [k: string]: string;
5
5
  };
6
6
  export declare function isNil(value: unknown): value is null | undefined;
7
- export declare const toBuffer: (bufLike: string | Buffer) => Buffer;
7
+ export declare const toBuffer: (bufLike: string | Buffer | Uint8Array) => Buffer;
8
8
  export declare const toObject: (input: string | Buffer | object) => object;
9
9
  export declare function serializeObject(map: string | object | undefined | null): Buffer | undefined;
10
10
  export declare function isPromiseLike(value: unknown): value is Promise<any>;