@rspack/dev-server 2.0.0-rc.0 → 2.0.0-rc.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.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,587 @@
1
- export { Server as RspackDevServer } from './server.js';
2
- export type { DevServer as Configuration } from '@rspack/core';
1
+ import { API } from '@rspack/dev-middleware';
2
+ import { Callback } from '@rspack/dev-middleware';
3
+ import { Compiler } from '@rspack/core';
4
+ import { DevServer as Configuration } from '@rspack/core';
5
+ import { Context } from '@rspack/dev-middleware';
6
+ import type { DevServerClient } from '@rspack/core';
7
+ import type { DevServerHeaders } from '@rspack/core';
8
+ import type { DevServerHost } from '@rspack/core';
9
+ import type { DevServerMiddlewareHandler } from '@rspack/core';
10
+ import type { DevServerOpenOptions } from '@rspack/core';
11
+ import type { DevServerProxyConfigArray } from '@rspack/core';
12
+ import type { DevServerStatic } from '@rspack/core';
13
+ import type { Dirent } from 'node:fs';
14
+ import { EventEmitter } from 'node:events';
15
+ import * as http from 'node:http';
16
+ import type { IncomingMessage as IncomingMessage_2 } from 'node:http';
17
+ import type { ListenOptions } from 'node:net';
18
+ import { MultiCompiler } from '@rspack/core';
19
+ import { MultiStats } from '@rspack/core';
20
+ import { Options } from '@rspack/dev-middleware';
21
+ import { Readable } from 'node:stream';
22
+ import { Server as Server_2 } from 'node:net';
23
+ import { Server as Server_3 } from 'node:tls';
24
+ import type { Server as Server_4 } from 'node:http';
25
+ import type { ServerOptions } from 'node:https';
26
+ import type { ServerResponse } from 'node:http';
27
+ import { Socket } from 'node:net';
28
+ import { Stats } from 'node:fs';
29
+ import { Stats as Stats_2 } from '@rspack/core';
30
+ import { StatsOptions } from '@rspack/core';
31
+ import type { WatchEventType } from 'node:fs';
32
+ import { WebSocket as WebSocket_2 } from 'ws';
33
+ import { WebSocketServer as WebSocketServer_2 } from 'ws';
34
+
35
+ declare type AWF = {
36
+ stabilityThreshold: number;
37
+ pollInterval: number;
38
+ };
39
+
40
+ declare type BasicApplication = {
41
+ use: UseFn;
42
+ };
43
+
44
+ declare type BasicOpts = {
45
+ persistent: boolean;
46
+ ignoreInitial: boolean;
47
+ followSymlinks: boolean;
48
+ cwd?: string;
49
+ usePolling: boolean;
50
+ interval: number;
51
+ binaryInterval: number;
52
+ alwaysStat?: boolean;
53
+ depth?: number;
54
+ ignorePermissionErrors: boolean;
55
+ atomic: boolean | number;
56
+ };
57
+
58
+ declare type BasicServer = Server_2 | Server_3;
59
+
60
+ declare type ChokidarOptions = Partial<BasicOpts & {
61
+ ignored: Matcher | Matcher[];
62
+ awaitWriteFinish: boolean | Partial<AWF>;
63
+ }>;
64
+
65
+ declare type ClientConnection = WebSocket_2 & {
66
+ isAlive?: boolean;
67
+ };
68
+
69
+ export { Configuration }
70
+
71
+ declare interface Configuration_2<A extends BasicApplication = Server, S extends BasicServer = Server_4> {
72
+ ipc?: boolean | string;
73
+ host?: DevServerHost;
74
+ port?: Port;
75
+ hot?: boolean | 'only';
76
+ liveReload?: boolean;
77
+ devMiddleware?: DevMiddlewareOptions<Request_2, Response_2>;
78
+ compress?: boolean;
79
+ allowedHosts?: LiteralUnion<'auto' | 'all', string> | string[];
80
+ historyApiFallback?: boolean | ConnectHistoryApiFallbackOptions;
81
+ watchFiles?: string | string[] | WatchFiles | Array<string | WatchFiles>;
82
+ static?: DevServerStatic;
83
+ server?: ServerType<A, S> | ServerConfiguration<A, S>;
84
+ app?: () => Promise<A>;
85
+ webSocketServer?: boolean | LiteralUnion<'ws', string> | WebSocketServerConfiguration;
86
+ proxy?: DevServerProxyConfigArray;
87
+ open?: boolean | string | Open | Array<string | Open>;
88
+ setupExitSignals?: boolean;
89
+ client?: boolean | DevServerClient;
90
+ headers?: DevServerHeaders | ((req: Request_2, res: Response_2, context: DevMiddlewareContext<Request_2, Response_2> | undefined) => DevServerHeaders);
91
+ onListening?: (devServer: RspackDevServer<A, S>) => void;
92
+ setupMiddlewares?: (middlewares: Middleware[], devServer: RspackDevServer<A, S>) => Middleware[];
93
+ }
94
+
95
+ declare type ConnectHistoryApiFallbackOptions = Exclude<NonNullable<Configuration['historyApiFallback']>, boolean>;
96
+
97
+ declare type DevMiddlewareContext<T extends Request_2, U extends Response_2> = Context<T, U>;
98
+
99
+ declare type DevMiddlewareOptions<T extends Request_2, U extends Response_2> = Options<T, U>;
100
+
101
+ /** Directory entry. Contains path, depth count, and files. */
102
+ declare interface DirEntry {
103
+ files: PathOrDirent[];
104
+ depth: number;
105
+ path: Path_2;
106
+ }
107
+
108
+ /**
109
+ * Directory entry.
110
+ */
111
+ declare class DirEntry_2 {
112
+ path: Path;
113
+ _removeWatcher: (dir: string, base: string) => void;
114
+ items: Set<Path>;
115
+ constructor(dir: Path, removeWatcher: (dir: string, base: string) => void);
116
+ add(item: string): void;
117
+ remove(item: string): Promise<void>;
118
+ has(item: string): boolean | undefined;
119
+ getChildren(): string[];
120
+ dispose(): void;
121
+ }
122
+
123
+ declare type EmitArgs = [path: Path, stats?: Stats];
124
+
125
+ declare type EmitArgsWithName = [event: EventName, ...EmitArgs];
126
+
127
+ /** Emitted entry. Contains relative & absolute path, basename, and either stats or dirent. */
128
+ declare interface EntryInfo {
129
+ path: string;
130
+ fullPath: string;
131
+ stats?: Stats;
132
+ dirent?: Dirent;
133
+ basename: string;
134
+ }
135
+
136
+ declare type EntryType = (typeof EntryTypes)[keyof typeof EntryTypes];
137
+
138
+ declare const EntryTypes: {
139
+ readonly FILE_TYPE: "files";
140
+ readonly DIR_TYPE: "directories";
141
+ readonly FILE_DIR_TYPE: "files_directories";
142
+ readonly EVERYTHING_TYPE: "all";
143
+ };
144
+
145
+ declare type ErrorHandleFunction = (err: any, req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
146
+
147
+ declare type EventName = (typeof EVENTS)[keyof typeof EVENTS];
148
+
149
+ declare const EVENTS: {
150
+ readonly ALL: "all";
151
+ readonly READY: "ready";
152
+ readonly ADD: "add";
153
+ readonly CHANGE: "change";
154
+ readonly ADD_DIR: "addDir";
155
+ readonly UNLINK: "unlink";
156
+ readonly UNLINK_DIR: "unlinkDir";
157
+ readonly RAW: "raw";
158
+ readonly ERROR: "error";
159
+ };
160
+
161
+ declare type EXPECTED_ANY = any;
162
+
163
+ /**
164
+ * Watches files & directories for changes. Emitted events:
165
+ * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
166
+ *
167
+ * new FSWatcher()
168
+ * .add(directories)
169
+ * .on('add', path => log('File', path, 'was added'))
170
+ */
171
+ declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {
172
+ closed: boolean;
173
+ options: FSWInstanceOptions;
174
+ _closers: Map<string, Array<any>>;
175
+ _ignoredPaths: Set<Matcher>;
176
+ _throttled: Map<ThrottleType, Map<any, any>>;
177
+ _streams: Set<ReaddirpStream>;
178
+ _symlinkPaths: Map<Path, string | boolean>;
179
+ _watched: Map<string, DirEntry_2>;
180
+ _pendingWrites: Map<string, any>;
181
+ _pendingUnlinks: Map<string, EmitArgsWithName>;
182
+ _readyCount: number;
183
+ _emitReady: () => void;
184
+ _closePromise?: Promise<void>;
185
+ _userIgnored?: MatchFunction;
186
+ _readyEmitted: boolean;
187
+ _emitRaw: WatchHandlers['rawEmitter'];
188
+ _boundRemove: (dir: string, item: string) => void;
189
+ _nodeFsHandler: NodeFsHandler;
190
+ constructor(_opts?: ChokidarOptions);
191
+ _addIgnoredPath(matcher: Matcher): void;
192
+ _removeIgnoredPath(matcher: Matcher): void;
193
+ /**
194
+ * Adds paths to be watched on an existing FSWatcher instance.
195
+ * @param paths_ file or file list. Other arguments are unused
196
+ */
197
+ add(paths_: Path | Path[], _origAdd?: string, _internal?: boolean): FSWatcher;
198
+ /**
199
+ * Close watchers or start ignoring events from specified paths.
200
+ */
201
+ unwatch(paths_: Path | Path[]): FSWatcher;
202
+ /**
203
+ * Close watchers and remove all listeners from watched paths.
204
+ */
205
+ close(): Promise<void>;
206
+ /**
207
+ * Expose list of watched paths
208
+ * @returns for chaining
209
+ */
210
+ getWatched(): Record<string, string[]>;
211
+ emitWithAll(event: EventName, args: EmitArgs): void;
212
+ /**
213
+ * Normalize and emit events.
214
+ * Calling _emit DOES NOT MEAN emit() would be called!
215
+ * @param event Type of event
216
+ * @param path File or directory path
217
+ * @param stats arguments to be passed with event
218
+ * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
219
+ */
220
+ _emit(event: EventName, path: Path, stats?: Stats): Promise<this | undefined>;
221
+ /**
222
+ * Common handler for errors
223
+ * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
224
+ */
225
+ _handleError(error: Error): Error | boolean;
226
+ /**
227
+ * Helper utility for throttling
228
+ * @param actionType type being throttled
229
+ * @param path being acted upon
230
+ * @param timeout duration of time to suppress duplicate actions
231
+ * @returns tracking object or false if action should be suppressed
232
+ */
233
+ _throttle(actionType: ThrottleType, path: Path, timeout: number): Throttler | false;
234
+ _incrReadyCount(): number;
235
+ /**
236
+ * Awaits write operation to finish.
237
+ * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
238
+ * @param path being acted upon
239
+ * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
240
+ * @param event
241
+ * @param awfEmit Callback to be called when ready for event to be emitted.
242
+ */
243
+ _awaitWriteFinish(path: Path, threshold: number, event: EventName, awfEmit: (err?: Error, stat?: Stats) => void): void;
244
+ /**
245
+ * Determines whether user has asked to ignore this path.
246
+ */
247
+ _isIgnored(path: Path, stats?: Stats): boolean;
248
+ _isntIgnored(path: Path, stat?: Stats): boolean;
249
+ /**
250
+ * Provides a set of common helpers and properties relating to symlink handling.
251
+ * @param path file or directory pattern being watched
252
+ */
253
+ _getWatchHelpers(path: Path): WatchHelper;
254
+ /**
255
+ * Provides directory tracking objects
256
+ * @param directory path of the directory
257
+ */
258
+ _getWatchedDir(directory: string): DirEntry_2;
259
+ /**
260
+ * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
261
+ */
262
+ _hasReadPermissions(stats: Stats): boolean;
263
+ /**
264
+ * Handles emitting unlink events for
265
+ * files and directories, and via recursion, for
266
+ * files and directories within directories that are unlinked
267
+ * @param directory within which the following item is located
268
+ * @param item base path of item/directory
269
+ */
270
+ _remove(directory: string, item: string, isDirectory?: boolean): void;
271
+ /**
272
+ * Closes all watchers for a path
273
+ */
274
+ _closePath(path: Path): void;
275
+ /**
276
+ * Closes only file-specific watchers
277
+ */
278
+ _closeFile(path: Path): void;
279
+ _addPathCloser(path: Path, closer: () => void): void;
280
+ _readdirp(root: Path, opts?: Partial<ReaddirpOptions>): ReaddirpStream | undefined;
281
+ }
282
+
283
+ declare interface FSWatcherEventMap {
284
+ [EVENTS.READY]: [];
285
+ [EVENTS.RAW]: Parameters<WatchHandlers['rawEmitter']>;
286
+ [EVENTS.ERROR]: Parameters<WatchHandlers['errHandler']>;
287
+ [EVENTS.ALL]: [event: EventName, ...EmitArgs];
288
+ [EVENTS.ADD]: EmitArgs;
289
+ [EVENTS.CHANGE]: EmitArgs;
290
+ [EVENTS.ADD_DIR]: EmitArgs;
291
+ [EVENTS.UNLINK]: EmitArgs;
292
+ [EVENTS.UNLINK_DIR]: EmitArgs;
293
+ }
294
+
295
+ declare type FSWInstanceOptions = BasicOpts & {
296
+ ignored: Matcher[];
297
+ awaitWriteFinish: false | AWF;
298
+ };
299
+
300
+ declare type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
301
+
302
+ /**
303
+ * Public and internal Connect types.
304
+ */
305
+ declare interface IncomingMessage extends http.IncomingMessage {
306
+ originalUrl?: http.IncomingMessage['url'] | undefined;
307
+ }
308
+
309
+ /** https://github.com/microsoft/TypeScript/issues/29729 */
310
+ declare type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
311
+
312
+ declare type Matcher = string | RegExp | MatchFunction | MatcherObject;
313
+
314
+ declare interface MatcherObject {
315
+ path: string;
316
+ recursive?: boolean;
317
+ }
318
+
319
+ declare type MatchFunction = (val: string, stats?: Stats) => boolean;
320
+
321
+ declare type Middleware = MiddlewareObject | DevServerMiddlewareHandler | ErrorHandleFunction;
322
+
323
+ declare interface MiddlewareObject {
324
+ name?: string;
325
+ path?: string;
326
+ middleware: DevServerMiddlewareHandler | ErrorHandleFunction;
327
+ }
328
+
329
+ declare type NextFunction = (err?: any) => void;
330
+
331
+ declare type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
332
+
333
+ /**
334
+ * @mixin
335
+ */
336
+ declare class NodeFsHandler {
337
+ fsw: FSWatcher;
338
+ _boundHandleError: (error: unknown) => void;
339
+ constructor(fsW: FSWatcher);
340
+ /**
341
+ * Watch file for changes with fs_watchFile or fs_watch.
342
+ * @param path to file or dir
343
+ * @param listener on fs change
344
+ * @returns closer for the watcher instance
345
+ */
346
+ _watchWithNodeFs(path: string, listener: (path: string, newStats?: any) => void | Promise<void>): (() => void) | undefined;
347
+ /**
348
+ * Watch a file and emit add event if warranted.
349
+ * @returns closer for the watcher instance
350
+ */
351
+ _handleFile(file: Path, stats: Stats, initialAdd: boolean): (() => void) | undefined;
352
+ /**
353
+ * Handle symlinks encountered while reading a dir.
354
+ * @param entry returned by readdirp
355
+ * @param directory path of dir being read
356
+ * @param path of this item
357
+ * @param item basename of this item
358
+ * @returns true if no more processing is needed for this entry.
359
+ */
360
+ _handleSymlink(entry: EntryInfo, directory: string, path: Path, item: string): Promise<boolean | undefined>;
361
+ _handleRead(directory: string, initialAdd: boolean, wh: WatchHelper, target: Path | undefined, dir: Path, depth: number, throttler: Throttler): Promise<unknown> | undefined;
362
+ /**
363
+ * Read directory to add / remove files from `@watched` list and re-read it on change.
364
+ * @param dir fs path
365
+ * @param stats
366
+ * @param initialAdd
367
+ * @param depth relative to user-supplied path
368
+ * @param target child path targeted for watch
369
+ * @param wh Common watch helpers for this path
370
+ * @param realpath
371
+ * @returns closer for the watcher instance.
372
+ */
373
+ _handleDir(dir: string, stats: Stats, initialAdd: boolean, depth: number, target: string | undefined, wh: WatchHelper, realpath: string): Promise<(() => void) | undefined>;
374
+ /**
375
+ * Handle added file, directory, or glob pattern.
376
+ * Delegates call to _handleFile / _handleDir after checks.
377
+ * @param path to file or ir
378
+ * @param initialAdd was the file added at watch instantiation?
379
+ * @param priorWh depth relative to user-supplied path
380
+ * @param depth Child path actually targeted for watch
381
+ * @param target Child path actually targeted for watch
382
+ */
383
+ _addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
384
+ }
385
+
386
+ declare type Open = DevServerOpenOptions & {
387
+ target?: string | string[];
388
+ };
389
+
390
+ declare type Path = string;
391
+
392
+ /** Path in file system. */
393
+ declare type Path_2 = string;
394
+
395
+ /** Path or dir entries (files) */
396
+ declare type PathOrDirent = Dirent | Path_2;
397
+
398
+ declare type Port = number | LiteralUnion<'auto', string>;
399
+
400
+ declare type Predicate = string[] | string | Tester;
401
+
402
+ /**
403
+ * Options for readdirp.
404
+ * * type: files, directories, or both
405
+ * * lstat: whether to use symlink-friendly stat
406
+ * * depth: max depth
407
+ * * alwaysStat: whether to use stat (more resources) or dirent
408
+ * * highWaterMark: streaming param, specifies max amount of resources per entry
409
+ */
410
+ declare type ReaddirpOptions = {
411
+ root: string;
412
+ fileFilter?: Predicate;
413
+ directoryFilter?: Predicate;
414
+ type?: EntryType;
415
+ lstat?: boolean;
416
+ depth?: number;
417
+ alwaysStat?: boolean;
418
+ highWaterMark?: number;
419
+ };
420
+
421
+ /** Readable readdir stream, emitting new files as they're being listed. */
422
+ declare class ReaddirpStream extends Readable {
423
+ parents: any[];
424
+ reading: boolean;
425
+ parent?: DirEntry;
426
+ _stat: Function;
427
+ _maxDepth: number;
428
+ _wantsDir: boolean;
429
+ _wantsFile: boolean;
430
+ _wantsEverything: boolean;
431
+ _root: Path_2;
432
+ _isDirent: boolean;
433
+ _statsProp: 'dirent' | 'stats';
434
+ _rdOptions: {
435
+ encoding: 'utf8';
436
+ withFileTypes: boolean;
437
+ };
438
+ _fileFilter: Tester;
439
+ _directoryFilter: Tester;
440
+ constructor(options?: Partial<ReaddirpOptions>);
441
+ _read(batch: number): Promise<void>;
442
+ _exploreDir(path: Path_2, depth: number): Promise<{
443
+ files: string[] | undefined;
444
+ depth: number;
445
+ path: string;
446
+ }>;
447
+ _formatEntry(dirent: PathOrDirent, path: Path_2): Promise<EntryInfo | undefined>;
448
+ _onError(err: Error): void;
449
+ _getEntryType(entry: EntryInfo): Promise<void | '' | 'file' | 'directory'>;
450
+ _includeAsFile(entry: EntryInfo): boolean | undefined;
451
+ }
452
+
453
+ declare type Request_2<T extends BasicApplication = Server> = T extends Server ? IncomingMessage : IncomingMessage_2;
454
+
455
+ declare type Response_2 = ServerResponse;
456
+
457
+ export declare class RspackDevServer<A extends BasicApplication = Server, S extends BasicServer = Server_4> {
458
+ #private;
459
+ compiler: Compiler | MultiCompiler;
460
+ logger: ReturnType<Compiler['getInfrastructureLogger']>;
461
+ options: Configuration_2<A, S>;
462
+ staticWatchers: FSWatcher[];
463
+ listeners: {
464
+ name: string | symbol;
465
+ listener: (...args: EXPECTED_ANY[]) => void;
466
+ }[];
467
+ webSocketProxies: NextHandleFunction[];
468
+ sockets: Socket[];
469
+ currentHash: string | undefined;
470
+ isTlsServer: boolean;
471
+ webSocketServer: WebSocketServerImplementation | null | undefined;
472
+ middleware: API<Request_2, Response_2> | undefined;
473
+ server: S | undefined;
474
+ app: A | undefined;
475
+ stats: Stats_2 | MultiStats | undefined;
476
+ constructor(options: Configuration, compiler: Compiler | MultiCompiler);
477
+ static get DEFAULT_STATS(): StatsOptions;
478
+ static isAbsoluteURL(URL: string): boolean;
479
+ static findIp(gatewayOrFamily: string, isInternal: boolean): string | undefined;
480
+ static getHostname(hostname: DevServerHost): Promise<string>;
481
+ static getFreePort(port: string, host: string): Promise<string | number>;
482
+ static findCacheDir(): string;
483
+ getClientEntry(): string;
484
+ getClientHotEntry(): string | undefined;
485
+ isValidHost(headers: Record<string, string | undefined>, headerToCheck: string, validateHost?: boolean): boolean;
486
+ sendMessage(clients: ClientConnection[], type: string, data?: EXPECTED_ANY, params?: EXPECTED_ANY): void;
487
+ watchFiles(watchPath: string | string[], watchOptions?: ChokidarOptions): Promise<void>;
488
+ invalidate(callback?: Callback): void;
489
+ start(): Promise<void>;
490
+ startCallback(callback?: (err?: Error) => void): void;
491
+ stop(): Promise<void>;
492
+ stopCallback(callback?: (err?: Error) => void): void;
493
+ }
494
+
495
+ declare interface Server extends EventEmitter {
496
+ (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
497
+ route: string;
498
+ stack: ServerStackItem[];
499
+ handle(req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
500
+ use(fn: NextHandleFunction): Server;
501
+ use(fn: HandleFunction): Server;
502
+ use(fn: http.Server): Server;
503
+ use(route: string, fn: NextHandleFunction): Server;
504
+ use(route: string, fn: HandleFunction): Server;
505
+ use(route: string, fn: http.Server): Server;
506
+ listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
507
+ listen(port: number, hostname?: string, callback?: Function): http.Server;
508
+ listen(path: string, callback?: Function): http.Server;
509
+ listen(options: ListenOptions, callback?: Function): http.Server;
510
+ listen(handle: unknown, listeningListener?: Function): http.Server;
511
+ }
512
+
513
+ declare interface ServerConfiguration<A extends BasicApplication = Server, S extends BasicServer = Server_4> {
514
+ type?: ServerType<A, S>;
515
+ options?: ServerOptions;
516
+ }
517
+
518
+ declare type ServerHandle = HandleFunction | http.Server;
519
+
520
+ declare interface ServerStackItem {
521
+ route: string;
522
+ handle: ServerHandle;
523
+ }
524
+
525
+ declare type ServerType<A extends BasicApplication, S extends BasicServer> = LiteralUnion<'http' | 'https' | 'http2', string> | ((serverOptions: ServerOptions, application: A) => S);
526
+
527
+ declare type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void;
528
+
529
+ /** Filterer for files */
530
+ declare type Tester = (entryInfo: EntryInfo) => boolean;
531
+
532
+ declare type Throttler = {
533
+ timeoutObject: NodeJS.Timeout;
534
+ clear: () => void;
535
+ count: number;
536
+ };
537
+
538
+ declare type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
539
+
540
+ declare type UseFn = {
541
+ (fn: NextHandleFunction): BasicApplication;
542
+ (fn: HandleFunction): BasicApplication;
543
+ (route: string, fn: NextHandleFunction): BasicApplication;
544
+ (route: string, fn: HandleFunction): BasicApplication;
545
+ };
546
+
547
+ declare interface WatchFiles {
548
+ paths: string | string[];
549
+ options?: ChokidarOptions & {
550
+ aggregateTimeout?: number;
551
+ poll?: number | boolean;
552
+ };
553
+ }
554
+
555
+ declare interface WatchHandlers {
556
+ listener: (path: string) => void;
557
+ errHandler: (err: unknown) => void;
558
+ rawEmitter: (ev: WatchEventType, path: string, opts: unknown) => void;
559
+ }
560
+
561
+ declare class WatchHelper {
562
+ fsw: FSWatcher;
563
+ path: string;
564
+ watchPath: string;
565
+ fullWatchPath: string;
566
+ dirParts: string[][];
567
+ followSymlinks: boolean;
568
+ statMethod: 'stat' | 'lstat';
569
+ constructor(path: string, follow: boolean, fsw: FSWatcher);
570
+ entryPath(entry: EntryInfo): Path;
571
+ filterPath(entry: EntryInfo): boolean;
572
+ filterDir(entry: EntryInfo): boolean;
573
+ }
574
+
575
+ declare type WebSocketServer = WebSocketServer_2;
576
+
577
+ declare interface WebSocketServerConfiguration {
578
+ type?: LiteralUnion<'ws', string> | (() => WebSocketServerConfiguration);
579
+ options?: Record<string, EXPECTED_ANY>;
580
+ }
581
+
582
+ declare interface WebSocketServerImplementation {
583
+ implementation: WebSocketServer;
584
+ clients: ClientConnection[];
585
+ }
586
+
587
+ export { }
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { RspackDevServer } from "./831.js";
1
+ export { RspackDevServer } from "./108.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/dev-server",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.2",
4
4
  "description": "Development server for rspack",
5
5
  "homepage": "https://rspack.rs",
6
6
  "bugs": "https://github.com/rstackjs/rspack-dev-server/issues",
@@ -29,8 +29,9 @@
29
29
  "lint": "rslint",
30
30
  "lint:write": "rslint --fix",
31
31
  "prettier:ci": "prettier --check .",
32
- "test": "pnpm run test:install && pnpm run build && rstest",
33
- "test:install": "cross-env ./node_modules/.bin/puppeteer browsers install chrome"
32
+ "test": "pnpm run test:install && pnpm run test:type && rstest",
33
+ "test:install": "cross-env ./node_modules/.bin/puppeteer browsers install chrome",
34
+ "test:type": "pnpm run build && pnpm --dir tests run type-check"
34
35
  },
35
36
  "simple-git-hooks": {
36
37
  "pre-commit": "npx nano-staged"
@@ -45,32 +46,31 @@
45
46
  ]
46
47
  },
47
48
  "dependencies": {
48
- "@rspack/dev-middleware": "^2.0.0",
49
- "@types/ws": "^8.18.1",
50
- "chokidar": "^5.0.0",
51
- "connect-history-api-fallback": "^2.0.0",
52
- "connect-next": "^4.0.0",
53
- "http-proxy-middleware": "^3.0.5",
54
- "ws": "^8.20.0"
49
+ "@rspack/dev-middleware": "^2.0.0"
55
50
  },
56
51
  "devDependencies": {
57
52
  "@hono/node-server": "^1.19.12",
53
+ "@microsoft/api-extractor": "^7.58.0",
58
54
  "@rslib/core": "^0.20.2",
59
- "@rslint/core": "^0.3.3",
55
+ "@rslint/core": "^0.3.4",
60
56
  "@rspack/core": "2.0.0-rc.0",
61
57
  "@rspack/plugin-react-refresh": "1.6.1",
62
58
  "@rstest/core": "^0.9.5",
59
+ "@types/connect-history-api-fallback": "^1.5.4",
63
60
  "@types/mime-types": "3.0.1",
64
61
  "@types/node": "^24.12.0",
65
62
  "@types/serve-static": "^2.2.0",
66
63
  "@types/trusted-types": "^2.0.7",
67
64
  "@types/ws": "8.18.1",
65
+ "chokidar": "^5.0.0",
66
+ "connect-history-api-fallback": "^2.0.0",
67
+ "connect-next": "^4.0.1",
68
68
  "cross-env": "^10.1.0",
69
- "css-loader": "^7.1.4",
70
69
  "express": "^5.2.1",
71
70
  "hono": "^4.12.9",
72
71
  "http-compression": "^1.1.2",
73
72
  "http-proxy": "^1.18.1",
73
+ "http-proxy-middleware": "^3.0.5",
74
74
  "ipaddr.js": "^2.3.0",
75
75
  "launch-editor": "^2.13.2",
76
76
  "nano-staged": "^0.9.0",
@@ -83,8 +83,8 @@
83
83
  "selfsigned": "^5.5.0",
84
84
  "serve-static": "^2.2.1",
85
85
  "simple-git-hooks": "^2.13.1",
86
- "style-loader": "^4.0.0",
87
- "typescript": "^6.0.2"
86
+ "typescript": "^6.0.2",
87
+ "ws": "^8.20.0"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@rspack/core": "^2.0.0-0",
package/dist/config.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { DevServerClient, DevServerOpenOptions } from '@rspack/core';
2
- import type { ConnectHistoryApiFallbackOptions, DevServer, NormalizedStatic, ServerConfiguration, WatchFiles, WebSocketServerConfiguration } from './types.js';
3
- export interface ResolvedDevServer extends DevServer {
4
- port: number | string;
5
- static: false | Array<NormalizedStatic>;
6
- devMiddleware: DevServer['devMiddleware'];
7
- hot: boolean | 'only';
8
- host?: string;
9
- open: DevServerOpenOptions[];
10
- magicHtml: boolean;
11
- liveReload: boolean;
12
- webSocketServer: false | WebSocketServerConfiguration;
13
- proxy: Required<DevServer['proxy']>;
14
- client: DevServerClient;
15
- allowedHosts: 'auto' | string[] | 'all';
16
- compress: boolean;
17
- historyApiFallback: false | ConnectHistoryApiFallbackOptions;
18
- server: ServerConfiguration;
19
- ipc: string | undefined;
20
- setupExitSignals: boolean;
21
- watchFiles: WatchFiles[];
22
- }