@rspack/core 1.3.5 → 1.3.7

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.
@@ -1,5 +1,8 @@
1
- import { BuiltinPluginName, type JsCompilation } from "@rspack/binding";
1
+ import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
+ import type { Compilation } from "../Compilation";
3
+ import type { Compiler } from "../Compiler";
2
4
  import type { Module } from "../Module";
5
+ import { RspackBuiltinPlugin } from "./base";
3
6
  export type CircularDependencyRspackPluginOptions = {
4
7
  /**
5
8
  * When `true`, the plugin will emit `ERROR` diagnostics rather than the
@@ -33,27 +36,24 @@ export type CircularDependencyRspackPluginOptions = {
33
36
  * Called once for every detected cycle. Providing this handler overrides the
34
37
  * default behavior of adding diagnostics to the compilation.
35
38
  */
36
- onDetected?(entrypoint: Module, modules: string[], compilation: JsCompilation): void;
39
+ onDetected?(entrypoint: Module, modules: string[], compilation: Compilation): void;
37
40
  /**
38
41
  * Called once for every detected cycle that was ignored because of a rule,
39
42
  * either from `exclude` or `ignoredConnections`.
40
43
  */
41
- onIgnored?(entrypoint: Module, modules: string[], compilation: JsCompilation): void;
44
+ onIgnored?(entrypoint: Module, modules: string[], compilation: Compilation): void;
42
45
  /**
43
46
  * Called before cycle detection begins.
44
47
  */
45
- onStart?(compilation: JsCompilation): void;
48
+ onStart?(compilation: Compilation): void;
46
49
  /**
47
50
  * Called after cycle detection finishes.
48
51
  */
49
- onEnd?(compilation: JsCompilation): void;
50
- };
51
- export declare const CircularDependencyRspackPlugin: {
52
- new (options: CircularDependencyRspackPluginOptions): {
53
- name: BuiltinPluginName;
54
- _args: [options: CircularDependencyRspackPluginOptions];
55
- affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined;
56
- raw(compiler: import("..").Compiler): import("@rspack/binding").BuiltinPlugin;
57
- apply(compiler: import("..").Compiler): void;
58
- };
52
+ onEnd?(compilation: Compilation): void;
59
53
  };
54
+ export declare class CircularDependencyRspackPlugin extends RspackBuiltinPlugin {
55
+ name: BuiltinPluginName;
56
+ _options: CircularDependencyRspackPluginOptions;
57
+ constructor(options: CircularDependencyRspackPluginOptions);
58
+ raw(compiler: Compiler): BuiltinPlugin;
59
+ }
@@ -73,7 +73,7 @@ export type HtmlRspackPluginOptions = {
73
73
  */
74
74
  hash?: boolean;
75
75
  };
76
- export declare function validateHtmlPluginOptions(options: HtmlRspackPluginOptions): void;
76
+ export declare function validateHtmlPluginOptions(options: HtmlRspackPluginOptions): string | null;
77
77
  export declare const getPluginOptions: (compilation: Compilation) => HtmlRspackPluginOptions | undefined;
78
78
  export declare const setPluginOptions: (compilation: Compilation, options: HtmlRspackPluginOptions) => void;
79
79
  export declare const cleanPluginOptions: (compilation: Compilation) => void;
@@ -1,4 +1,4 @@
1
- import type { Middleware } from "webpack-dev-server";
2
1
  import type { Compiler, LazyCompilationOptions } from "../..";
2
+ import type { Middleware } from "../../config/devServer";
3
3
  export declare const LAZY_COMPILATION_PREFIX = "/lazy-compilation-using-";
4
4
  export declare const lazyCompilationMiddleware: (compiler: Compiler, userOptions?: LazyCompilationOptions | boolean) => Middleware;
@@ -0,0 +1,207 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack-dev-server/blob/6045b1e9d63078fb24cac52eb361b7356944cddd/types/lib/Server.d.ts
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
9
+ */
10
+ import type { Compiler, MultiCompiler, MultiStats, Stats, Watching } from "..";
11
+ type Logger = ReturnType<Compiler["getInfrastructureLogger"]>;
12
+ type MultiWatching = MultiCompiler["watch"];
13
+ type BasicServer = import("net").Server | import("tls").Server;
14
+ type ReadStream = typeof import("fs").ReadStream;
15
+ type IncomingMessage = typeof import("http").IncomingMessage;
16
+ type ServerResponse = typeof import("http").ServerResponse;
17
+ type ServerOptions = import("https").ServerOptions & {
18
+ spdy?: {
19
+ plain?: boolean | undefined;
20
+ ssl?: boolean | undefined;
21
+ "x-forwarded-for"?: string | undefined;
22
+ protocol?: string | undefined;
23
+ protocols?: string[] | undefined;
24
+ };
25
+ };
26
+ type ResponseData = {
27
+ data: Buffer | ReadStream;
28
+ byteLength: number;
29
+ };
30
+ type ModifyResponseData<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = (req: RequestInternal, res: ResponseInternal, data: Buffer | ReadStream, byteLength: number) => ResponseData;
31
+ type Headers = Array<{
32
+ key: string;
33
+ value: string;
34
+ }> | Record<string, string | string[]>;
35
+ type OutputFileSystem = import("..").OutputFileSystem & {
36
+ createReadStream?: typeof import("fs").createReadStream;
37
+ statSync: import("fs").StatSyncFn;
38
+ readFileSync: typeof import("fs").readFileSync;
39
+ };
40
+ type RspackConfiguration = import("..").Configuration;
41
+ type Port = number | string | "auto";
42
+ type HistoryContext = {
43
+ readonly match: RegExpMatchArray;
44
+ readonly parsedUrl: import("url").Url;
45
+ readonly request: any;
46
+ };
47
+ type RewriteTo = (context: HistoryContext) => string;
48
+ type Rewrite = {
49
+ readonly from: RegExp;
50
+ readonly to: string | RegExp | RewriteTo;
51
+ };
52
+ type HistoryApiFallbackOptions = {
53
+ readonly disableDotRule?: true | undefined;
54
+ readonly htmlAcceptHeaders?: readonly string[] | undefined;
55
+ readonly index?: string | undefined;
56
+ readonly logger?: typeof console.log | undefined;
57
+ readonly rewrites?: readonly Rewrite[] | undefined;
58
+ readonly verbose?: boolean | undefined;
59
+ };
60
+ type DevMiddlewareOptions<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = {
61
+ mimeTypes?: {
62
+ [key: string]: string;
63
+ } | undefined;
64
+ mimeTypeDefault?: string | undefined;
65
+ writeToDisk?: boolean | ((targetPath: string) => boolean) | undefined;
66
+ methods?: string[] | undefined;
67
+ headers?: any;
68
+ publicPath?: NonNullable<RspackConfiguration["output"]>["publicPath"];
69
+ stats?: RspackConfiguration["stats"];
70
+ serverSideRender?: boolean | undefined;
71
+ outputFileSystem?: OutputFileSystem | undefined;
72
+ index?: string | boolean | undefined;
73
+ modifyResponseData?: ModifyResponseData<RequestInternal, ResponseInternal> | undefined;
74
+ etag?: "strong" | "weak" | undefined;
75
+ lastModified?: boolean | undefined;
76
+ cacheControl?: string | number | boolean | {
77
+ maxAge?: number;
78
+ immutable?: boolean;
79
+ } | undefined;
80
+ cacheImmutable?: boolean | undefined;
81
+ };
82
+ type BasicApplication = any;
83
+ type BonjourServer = any;
84
+ type ChokidarWatchOptions = {
85
+ [key: string]: any;
86
+ };
87
+ type ServeIndexOptions = {
88
+ [key: string]: any;
89
+ };
90
+ type ServeStaticOptions = {
91
+ [key: string]: any;
92
+ };
93
+ type HttpProxyMiddlewareOptionsFilter = any;
94
+ type Request = IncomingMessage;
95
+ type Response = ServerResponse;
96
+ type WatchFiles = {
97
+ paths: string | string[];
98
+ options?: (ChokidarWatchOptions & {
99
+ aggregateTimeout?: number;
100
+ ignored?: ChokidarWatchOptions["ignored"];
101
+ poll?: number | boolean;
102
+ }) | undefined;
103
+ };
104
+ type Static = {
105
+ directory?: string | undefined;
106
+ publicPath?: string | string[] | undefined;
107
+ serveIndex?: boolean | ServeIndexOptions | undefined;
108
+ staticOptions?: ServeStaticOptions | undefined;
109
+ watch?: boolean | (ChokidarWatchOptions & {
110
+ aggregateTimeout?: number;
111
+ ignored?: ChokidarWatchOptions["ignored"];
112
+ poll?: number | boolean;
113
+ }) | undefined;
114
+ };
115
+ type ServerType<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<IncomingMessage, ServerResponse>> = "http" | "https" | "spdy" | "http2" | string | ((arg0: ServerOptions, arg1: A) => S);
116
+ type ServerConfiguration<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<IncomingMessage, ServerResponse>> = {
117
+ type?: ServerType<A, S> | undefined;
118
+ options?: ServerOptions | undefined;
119
+ };
120
+ type WebSocketServerConfiguration = {
121
+ type?: string | Function | undefined;
122
+ options?: Record<string, any> | undefined;
123
+ };
124
+ type NextFunction = (err?: any) => void;
125
+ type ProxyConfigArrayItem = {
126
+ path?: HttpProxyMiddlewareOptionsFilter | undefined;
127
+ context?: HttpProxyMiddlewareOptionsFilter | undefined;
128
+ } & {
129
+ bypass?: ByPass;
130
+ } & {
131
+ [key: string]: any;
132
+ };
133
+ type ByPass = (req: Request, res: Response, proxyConfig: ProxyConfigArrayItem) => any;
134
+ type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[];
135
+ type Callback = (stats?: Stats | MultiStats | undefined) => any;
136
+ type DevMiddlewareContext<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = {
137
+ state: boolean;
138
+ stats: Stats | MultiStats | undefined;
139
+ callbacks: Callback[];
140
+ options: any;
141
+ compiler: Compiler | MultiCompiler;
142
+ watching: Watching | MultiWatching | undefined;
143
+ logger: Logger;
144
+ outputFileSystem: OutputFileSystem;
145
+ };
146
+ type Server = any;
147
+ type MiddlewareHandler = any;
148
+ type MiddlewareObject = {
149
+ name?: string;
150
+ path?: string;
151
+ middleware: MiddlewareHandler;
152
+ };
153
+ export type Middleware = MiddlewareObject | MiddlewareHandler;
154
+ type OpenApp = {
155
+ name?: string | undefined;
156
+ arguments?: string[] | undefined;
157
+ };
158
+ type Open = {
159
+ app?: string | string[] | OpenApp | undefined;
160
+ target?: string | string[] | undefined;
161
+ };
162
+ type OverlayMessageOptions = boolean | ((error: Error) => void);
163
+ type WebSocketURL = {
164
+ hostname?: string | undefined;
165
+ password?: string | undefined;
166
+ pathname?: string | undefined;
167
+ port?: string | number | undefined;
168
+ protocol?: string | undefined;
169
+ username?: string | undefined;
170
+ };
171
+ type ClientConfiguration = {
172
+ logging?: "none" | "error" | "warn" | "info" | "log" | "verbose" | undefined;
173
+ overlay?: boolean | {
174
+ warnings?: OverlayMessageOptions;
175
+ errors?: OverlayMessageOptions;
176
+ runtimeErrors?: OverlayMessageOptions;
177
+ } | undefined;
178
+ progress?: boolean | undefined;
179
+ reconnect?: number | boolean | undefined;
180
+ webSocketTransport?: string | undefined;
181
+ webSocketURL?: string | WebSocketURL | undefined;
182
+ };
183
+ export type DevServerOptions<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<IncomingMessage, ServerResponse>> = {
184
+ ipc?: string | boolean | undefined;
185
+ host?: string | undefined;
186
+ port?: Port | undefined;
187
+ hot?: boolean | "only" | undefined;
188
+ liveReload?: boolean | undefined;
189
+ devMiddleware?: DevMiddlewareOptions | undefined;
190
+ compress?: boolean | undefined;
191
+ allowedHosts?: string | string[] | undefined;
192
+ historyApiFallback?: boolean | HistoryApiFallbackOptions | undefined;
193
+ bonjour?: boolean | Record<string, never> | BonjourServer | undefined;
194
+ watchFiles?: string | string[] | WatchFiles | (string | WatchFiles)[] | undefined;
195
+ static?: string | boolean | Static | (string | Static)[] | undefined;
196
+ server?: ServerType<A, S> | ServerConfiguration<A, S> | undefined;
197
+ app?: (() => Promise<A>) | undefined;
198
+ webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined;
199
+ proxy?: ProxyConfigArray | undefined;
200
+ open?: string | boolean | Open | (string | Open)[] | undefined;
201
+ setupExitSignals?: boolean | undefined;
202
+ client?: boolean | ClientConfiguration | undefined;
203
+ headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response> | undefined) => Headers) | undefined;
204
+ onListening?: ((devServer: Server) => void) | undefined;
205
+ setupMiddlewares?: ((middlewares: Middleware[], devServer: Server) => Middleware[]) | undefined;
206
+ };
207
+ export {};
@@ -1,5 +1,4 @@
1
1
  import type { AssetInfo, RawFuncUseCtx } from "@rspack/binding";
2
- import type * as webpackDevServer from "webpack-dev-server";
3
2
  import type { ChunkGraph } from "../ChunkGraph";
4
3
  import type { Compilation, PathData } from "../Compilation";
5
4
  import type { Compiler } from "../Compiler";
@@ -8,6 +7,7 @@ import type ModuleGraph from "../ModuleGraph";
8
7
  import type { HttpUriPluginOptions } from "../builtin-plugin/HttpUriPlugin";
9
8
  import type { Chunk } from "../exports";
10
9
  import type { ResolveCallback } from "./adapterRuleUse";
10
+ import type { DevServerOptions } from "./devServer";
11
11
  export type FilenameTemplate = string;
12
12
  export type Filename = FilenameTemplate | ((pathData: PathData, assetInfo?: AssetInfo) => string);
13
13
  /** Name of the configuration. Used when loading multiple configurations. */
@@ -1812,11 +1812,13 @@ export type RspackFutureOptions = {
1812
1812
  */
1813
1813
  export type LazyCompilationOptions = {
1814
1814
  /**
1815
- * Enable lazy compilation for imports.
1815
+ * Enable lazy compilation for dynamic imports.
1816
+ * @default true
1816
1817
  */
1817
1818
  imports?: boolean;
1818
1819
  /**
1819
1820
  * Enable lazy compilation for entries.
1821
+ * @default true
1820
1822
  */
1821
1823
  entries?: boolean;
1822
1824
  /**
@@ -1824,13 +1826,23 @@ export type LazyCompilationOptions = {
1824
1826
  */
1825
1827
  test?: RegExp | ((module: Module) => boolean);
1826
1828
  /**
1827
- * The runtime code path for client
1829
+ * The path to a custom runtime code that overrides the default lazy
1830
+ * compilation client. If you want to customize the logic of the client
1831
+ * runtime, you can specify it through this option.
1828
1832
  */
1829
1833
  client?: string;
1830
1834
  /**
1831
- * The server url
1835
+ * Tells the client the server URL that needs to be requested.
1836
+ * By default it is empty, in a browser environment it will find
1837
+ * the server path where the page is located, but in a node
1838
+ * environment you need to explicitly specify a specific path.
1832
1839
  */
1833
1840
  serverUrl?: string;
1841
+ /**
1842
+ * Customize the prefix used for lazy compilation endpoint.
1843
+ * @default "/lazy-compilation-using-"
1844
+ */
1845
+ prefix?: string;
1834
1846
  };
1835
1847
  /**
1836
1848
  * Options for incremental builds.
@@ -2007,7 +2019,7 @@ export type WatchOptions = {
2007
2019
  /**
2008
2020
  * Options for devServer, it based on `webpack-dev-server@5`
2009
2021
  * */
2010
- export interface DevServer extends webpackDevServer.Configuration {
2022
+ export interface DevServer extends DevServerOptions {
2011
2023
  }
2012
2024
  /**
2013
2025
  * An array of either regular expressions or functions that determine if a warning should be ignored.
@@ -1,10 +1,10 @@
1
- import { type IssueData, type ParseReturnType, ZodType, type ZodTypeDef, z } from "../../compiled/zod";
1
+ import z, { type IssueData, type ParseReturnType, ZodType, type ZodTypeDef } from "../../compiled/zod";
2
2
  import type { RspackOptions } from "./types";
3
3
  export type ZodCrossFieldsOptions = ZodTypeDef & {
4
4
  patterns: Array<{
5
- test: (root: RspackOptions) => boolean;
5
+ test: (root: RspackOptions, input: z.ParseInput) => boolean;
6
6
  type: ZodType;
7
- issue?: (res: ParseReturnType<any>) => Array<IssueData>;
7
+ issue?: (res: ParseReturnType<any>, root: RspackOptions, input: z.ParseInput) => Array<IssueData>;
8
8
  }>;
9
9
  default: ZodType;
10
10
  };