@rspack/dev-server 2.0.0-beta.4 → 2.0.0-beta.6

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,11 +10,6 @@ function __webpack_require__(moduleId) {
10
10
  return module.exports;
11
11
  }
12
12
  __webpack_require__.m = __webpack_modules__;
13
- (()=>{
14
- __webpack_require__.add = function(modules) {
15
- Object.assign(__webpack_require__.m, modules);
16
- };
17
- })();
18
13
  (()=>{
19
14
  __webpack_require__.n = (module)=>{
20
15
  var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
@@ -59,6 +54,11 @@ __webpack_require__.m = __webpack_modules__;
59
54
  });
60
55
  };
61
56
  })();
57
+ (()=>{
58
+ __webpack_require__.add = function(modules) {
59
+ Object.assign(__webpack_require__.m, modules);
60
+ };
61
+ })();
62
62
  (()=>{
63
63
  __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
64
64
  })();
package/dist/server.d.ts CHANGED
@@ -7,11 +7,12 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
9
9
  */
10
- import type { BasicApplication, ClientConfiguration, ClientConnection, Compiler, ConnectHistoryApiFallbackOptions, DevMiddlewareContext, DevMiddlewareOptions, DevServer, EXPECTED_ANY, FSWatcher, HTTPServer, Headers, Host, LiteralUnion, Middleware, MultiCompiler, MultiStats, NextFunction, Open, Port, ProxyConfigArray, Request, RequestHandler, Response, ServerConfiguration, ServerType, Socket, Static, Stats, StatsCompilation, StatsOptions, WatchFiles, WatchOptions, WebSocketServerConfiguration, WebSocketServerImplementation } from './types';
10
+ import type { DevServerClient, DevServerHeaders, DevServerHost, DevServerProxyConfigArray, DevServerStatic } from '@rspack/core';
11
+ import type { BasicApplication, BasicServer, ClientConnection, Compiler, ConnectHistoryApiFallbackOptions, DevMiddlewareContext, DevMiddlewareOptions, DevServer, EXPECTED_ANY, FSWatcher, HTTPServer, LiteralUnion, Middleware, MultiCompiler, MultiStats, Open, Port, Request, RequestHandler, Response, ServerConfiguration, ServerType, Socket, Stats, StatsOptions, WatchFiles, WatchOptions, WebSocketServerConfiguration, WebSocketServerImplementation } from './types';
11
12
  import type { ConnectApplication } from './types';
12
- export interface Configuration<A extends BasicApplication = ConnectApplication, S extends HTTPServer = HTTPServer> {
13
+ export interface Configuration<A extends BasicApplication = ConnectApplication, S extends BasicServer = HTTPServer> {
13
14
  ipc?: boolean | string;
14
- host?: Host;
15
+ host?: DevServerHost;
15
16
  port?: Port;
16
17
  hot?: boolean | 'only';
17
18
  liveReload?: boolean;
@@ -20,19 +21,20 @@ export interface Configuration<A extends BasicApplication = ConnectApplication,
20
21
  allowedHosts?: LiteralUnion<'auto' | 'all', string> | string[];
21
22
  historyApiFallback?: boolean | ConnectHistoryApiFallbackOptions;
22
23
  watchFiles?: string | string[] | WatchFiles | Array<string | WatchFiles>;
23
- static?: boolean | string | Static | Array<string | Static>;
24
+ static?: DevServerStatic;
24
25
  server?: ServerType<A, S> | ServerConfiguration<A, S>;
25
26
  app?: () => Promise<A>;
26
27
  webSocketServer?: boolean | LiteralUnion<'ws', string> | WebSocketServerConfiguration;
27
- proxy?: ProxyConfigArray;
28
+ proxy?: DevServerProxyConfigArray;
28
29
  open?: boolean | string | Open | Array<string | Open>;
29
30
  setupExitSignals?: boolean;
30
- client?: boolean | ClientConfiguration;
31
- headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response> | undefined) => Headers);
31
+ client?: boolean | DevServerClient;
32
+ headers?: DevServerHeaders | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response> | undefined) => DevServerHeaders);
32
33
  onListening?: (devServer: Server<A, S>) => void;
33
34
  setupMiddlewares?: (middlewares: Middleware[], devServer: Server<A, S>) => Middleware[];
34
35
  }
35
- declare class Server<A extends BasicApplication = ConnectApplication, S extends import('http').Server = HTTPServer> {
36
+ declare class Server<A extends BasicApplication = ConnectApplication, S extends BasicServer = HTTPServer> {
37
+ #private;
36
38
  compiler: Compiler | MultiCompiler;
37
39
  logger: ReturnType<Compiler['getInfrastructureLogger']>;
38
40
  options: Configuration<A, S>;
@@ -54,52 +56,14 @@ declare class Server<A extends BasicApplication = ConnectApplication, S extends
54
56
  static get DEFAULT_STATS(): StatsOptions;
55
57
  static isAbsoluteURL(URL: string): boolean;
56
58
  static findIp(gatewayOrFamily: string, isInternal: boolean): string | undefined;
57
- static getHostname(hostname: Host): Promise<string>;
59
+ static getHostname(hostname: DevServerHost): Promise<string>;
58
60
  static getFreePort(port: string, host: string): Promise<string | number>;
59
61
  static findCacheDir(): string;
60
- addAdditionalEntries(compiler: Compiler): void;
61
- /**
62
- * @private
63
- * @returns {Compiler["options"]} compiler options
64
- */
65
- getCompilerOptions(): import("@rspack/core").RspackOptionsNormalized;
66
- shouldLogInfrastructureInfo(): boolean;
67
- normalizeOptions(): Promise<void>;
68
- /**
69
- * @private
70
- * @returns {string} client transport
71
- */
72
- getClientTransport(): string;
73
- getServerTransport(): unknown;
74
62
  getClientEntry(): string;
75
63
  getClientHotEntry(): string | undefined;
76
- setupProgressPlugin(): void;
77
- /**
78
- * @private
79
- * @returns {Promise<void>}
80
- */
81
- initialize(): Promise<void>;
82
- setupApp(): Promise<void>;
83
- getStats(statsObj: Stats | MultiStats): StatsCompilation;
84
- setupHooks(): void;
85
- setupWatchStaticFiles(): void;
86
- setupWatchFiles(): void;
87
- setupMiddlewares(): Promise<void>;
88
- /**
89
- * @private
90
- * @returns {Promise<void>}
91
- */
92
- createServer(): Promise<void>;
93
- createWebSocketServer(): void;
94
- openBrowser(defaultOpenTarget: string): Promise<void>;
95
- logStatus(): Promise<void>;
96
- setHeaders(req: Request, res: Response, next: NextFunction): void;
97
- isHostAllowed(value: string): boolean;
98
64
  isValidHost(headers: Record<string, string | undefined>, headerToCheck: string, validateHost?: boolean): boolean;
99
- isSameOrigin(headers: Record<string, string | undefined>): boolean;
100
65
  sendMessage(clients: ClientConnection[], type: string, data?: EXPECTED_ANY, params?: EXPECTED_ANY): void;
101
- sendStats(clients: ClientConnection[], stats: StatsCompilation, force?: boolean): void;
102
- watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): void;
66
+ watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): Promise<void>;
103
67
  invalidate(callback?: import('webpack-dev-middleware').Callback): void;
104
68
  start(): Promise<void>;
105
69
  startCallback(callback?: (err?: Error) => void): void;
package/dist/types.d.ts CHANGED
@@ -1,64 +1,40 @@
1
1
  import type { Server as HTTPServer, IncomingMessage, ServerResponse } from 'node:http';
2
- export type { HTTPServer, IncomingMessage };
2
+ import type { ServerOptions } from 'node:https';
3
+ import type { DevServer, DevServerMiddlewareHandler, DevServerOpenOptions, DevServerStaticItem } from '@rspack/core';
4
+ import type { FSWatcher, ChokidarOptions as WatchOptions } from 'chokidar';
5
+ import type { Server as ConnectApplication, IncomingMessage as ConnectIncomingMessage, ErrorHandleFunction, HandleFunction, NextHandleFunction } from 'connect-next';
6
+ import type { RequestHandler } from 'http-proxy-middleware';
7
+ export type { FSWatcher, WatchOptions, RequestHandler, BasicServer, HTTPServer, ServerOptions, IncomingMessage, ConnectApplication, };
8
+ export type { IPv6 } from 'ipaddr.js';
3
9
  export type { Socket } from 'node:net';
4
10
  export type { AddressInfo } from 'node:net';
5
11
  export type { NetworkInterfaceInfo } from 'node:os';
6
12
  export type { Compiler, DevServer, MultiCompiler, MultiStats, Stats, StatsCompilation, StatsOptions, } from '@rspack/core';
7
- import type { FSWatcher, WatchOptions } from 'chokidar';
8
- export type { FSWatcher, WatchOptions };
9
- import type { Server as ConnectApplication, IncomingMessage as ConnectIncomingMessage } from 'connect-next';
10
- export type { ConnectApplication };
11
- import type { Options as ConnectHistoryApiFallbackOptions } from 'connect-history-api-fallback';
12
- export type { ConnectHistoryApiFallbackOptions };
13
- import type { Options as HttpProxyMiddlewareOptions, Filter as HttpProxyMiddlewareOptionsFilter, RequestHandler } from 'http-proxy-middleware';
14
- export type { RequestHandler };
15
- export type { IPv6 } from 'ipaddr.js';
16
- import type { Options as ServeIndexOptions } from 'serve-index';
17
- export type { ServeIndexOptions };
18
- import type { ServeStaticOptions } from 'serve-static';
19
13
  export type EXPECTED_ANY = any;
14
+ type BasicServer = import('node:net').Server | import('node:tls').Server;
20
15
  /** https://github.com/microsoft/TypeScript/issues/29729 */
21
16
  export type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
22
- export type NextFunction = (err?: EXPECTED_ANY) => void;
23
- export type SimpleHandleFunction = (req: IncomingMessage, res: ServerResponse) => void;
24
- export type NextHandleFunction = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
25
- export type ErrorHandleFunction = (err: EXPECTED_ANY, req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
26
- export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
27
- export type ServerOptions = import('https').ServerOptions;
17
+ export type ConnectHistoryApiFallbackOptions = Exclude<NonNullable<DevServer['historyApiFallback']>, boolean>;
28
18
  export type Request<T extends BasicApplication = ConnectApplication> = T extends ConnectApplication ? ConnectIncomingMessage : IncomingMessage;
29
19
  export type Response = ServerResponse;
30
20
  export type DevMiddlewareOptions<T extends Request, U extends Response> = import('webpack-dev-middleware').Options<T, U>;
31
21
  export type DevMiddlewareContext<T extends Request, U extends Response> = import('webpack-dev-middleware').Context<T, U>;
32
- export type Host = LiteralUnion<'local-ip' | 'local-ipv4' | 'local-ipv6', string>;
33
22
  export type Port = number | LiteralUnion<'auto', string>;
34
23
  export interface WatchFiles {
35
24
  paths: string | string[];
36
25
  options?: WatchOptions & {
37
26
  aggregateTimeout?: number;
38
- ignored?: WatchOptions['ignored'];
39
27
  poll?: number | boolean;
40
28
  };
41
29
  }
42
- export interface Static {
43
- directory?: string;
44
- publicPath?: string | string[];
45
- serveIndex?: boolean | ServeIndexOptions;
46
- staticOptions?: ServeStaticOptions;
47
- watch?: boolean | (WatchOptions & {
48
- aggregateTimeout?: number;
49
- ignored?: WatchOptions['ignored'];
50
- poll?: number | boolean;
51
- });
52
- }
53
30
  export interface NormalizedStatic {
54
31
  directory: string;
55
32
  publicPath: string[];
56
- serveIndex: false | ServeIndexOptions;
57
- staticOptions: ServeStaticOptions;
33
+ staticOptions: DevServerStaticItem['staticOptions'];
58
34
  watch: false | WatchOptions;
59
35
  }
60
- export type ServerType<A extends BasicApplication = ConnectApplication, S extends import('http').Server = import('http').Server> = LiteralUnion<'http' | 'https' | 'http2', string> | ((serverOptions: ServerOptions, application: A) => S);
61
- export interface ServerConfiguration<A extends BasicApplication = ConnectApplication, S extends import('http').Server = import('http').Server> {
36
+ export type ServerType<A extends BasicApplication, S extends BasicServer> = LiteralUnion<'http' | 'https' | 'http2', string> | ((serverOptions: ServerOptions, application: A) => S);
37
+ export interface ServerConfiguration<A extends BasicApplication = ConnectApplication, S extends BasicServer = HTTPServer> {
62
38
  type?: ServerType<A, S>;
63
39
  options?: ServerOptions;
64
40
  }
@@ -74,58 +50,19 @@ export interface WebSocketServerImplementation {
74
50
  implementation: WebSocketServer;
75
51
  clients: ClientConnection[];
76
52
  }
77
- export type ProxyConfigArrayItem = {
78
- /**
79
- * Alias for `pathFilter` in `http-proxy-middleware` options.
80
- * When both `context` and `pathFilter` are provided, `pathFilter` takes precedence.
81
- */
82
- context?: HttpProxyMiddlewareOptionsFilter;
83
- } & HttpProxyMiddlewareOptions;
84
- export type ProxyConfigArray = Array<ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem)>;
85
- export interface OpenApp {
86
- name?: string;
87
- arguments?: string[];
88
- }
89
- export interface Open {
90
- app?: string | string[] | OpenApp;
53
+ export type Open = DevServerOpenOptions & {
91
54
  target?: string | string[];
92
- }
55
+ };
93
56
  export interface NormalizedOpen {
94
57
  target: string;
95
- options: OpenOptions;
96
- }
97
- export interface WebSocketURL {
98
- hostname?: string;
99
- password?: string;
100
- pathname?: string;
101
- port?: number | string;
102
- protocol?: string;
103
- username?: string;
58
+ options: DevServerOpenOptions;
104
59
  }
105
- export interface ClientConfiguration {
106
- logging?: 'log' | 'info' | 'warn' | 'error' | 'none' | 'verbose';
107
- overlay?: boolean | {
108
- warnings?: OverlayMessageOptions;
109
- errors?: OverlayMessageOptions;
110
- runtimeErrors?: OverlayMessageOptions;
111
- };
112
- progress?: boolean;
113
- reconnect?: boolean | number;
114
- webSocketTransport?: LiteralUnion<'ws', string>;
115
- webSocketURL?: string | WebSocketURL;
116
- }
117
- export type Headers = Array<{
118
- key: string;
119
- value: string;
120
- }> | Record<string, string | string[]>;
121
- export type MiddlewareHandler = (...args: EXPECTED_ANY[]) => EXPECTED_ANY;
122
60
  export interface MiddlewareObject {
123
61
  name?: string;
124
62
  path?: string;
125
- middleware: MiddlewareHandler;
63
+ middleware: DevServerMiddlewareHandler | ErrorHandleFunction;
126
64
  }
127
- export type Middleware = MiddlewareObject | MiddlewareHandler;
128
- export type BasicServer = import('net').Server | import('tls').Server;
65
+ export type Middleware = MiddlewareObject | DevServerMiddlewareHandler | ErrorHandleFunction;
129
66
  export type OverlayMessageOptions = boolean | ((error: Error) => void);
130
67
  declare function useFn(fn: NextHandleFunction): BasicApplication;
131
68
  declare function useFn(fn: HandleFunction): BasicApplication;
@@ -134,10 +71,3 @@ declare function useFn(route: string, fn: HandleFunction): BasicApplication;
134
71
  export type BasicApplication = {
135
72
  use: typeof useFn;
136
73
  };
137
- export type OpenOptions = {
138
- readonly wait?: boolean;
139
- readonly background?: boolean;
140
- readonly newInstance?: boolean;
141
- readonly app?: OpenApp | readonly OpenApp[];
142
- readonly allowNonzeroExitCode?: boolean;
143
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/dev-server",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.6",
4
4
  "description": "Development server for rspack",
5
5
  "homepage": "https://rspack.rs",
6
6
  "bugs": "https://github.com/rstackjs/rspack-dev-server/issues",
@@ -45,16 +45,12 @@
45
45
  ]
46
46
  },
47
47
  "dependencies": {
48
- "@types/connect-history-api-fallback": "^1.5.4",
49
- "@types/serve-index": "^1.9.4",
50
- "@types/serve-static": "^2.2.0",
51
48
  "@types/ws": "^8.18.1",
52
- "chokidar": "^3.6.0",
49
+ "chokidar": "^5.0.0",
53
50
  "connect-history-api-fallback": "^2.0.0",
54
51
  "connect-next": "^4.0.0",
55
52
  "http-proxy-middleware": "^3.0.5",
56
53
  "ipaddr.js": "^2.3.0",
57
- "serve-index": "^1.9.2",
58
54
  "serve-static": "^2.2.1",
59
55
  "webpack-dev-middleware": "^7.4.5",
60
56
  "ws": "^8.19.0"
@@ -62,13 +58,13 @@
62
58
  "devDependencies": {
63
59
  "@biomejs/biome": "^1.9.4",
64
60
  "@hono/node-server": "^1.19.11",
65
- "@rslib/core": "^0.19.6",
66
- "@rspack/core": "2.0.0-beta.5",
61
+ "@rslib/core": "^0.20.0",
62
+ "@rspack/core": "2.0.0-beta.6",
67
63
  "@rspack/plugin-react-refresh": "1.6.1",
68
- "@rstest/core": "^0.9.0",
64
+ "@rstest/core": "^0.9.2",
69
65
  "@types/mime-types": "3.0.1",
70
66
  "@types/node": "^24.12.0",
71
- "@types/node-forge": "^1.3.14",
67
+ "@types/serve-static": "^2.2.0",
72
68
  "@types/trusted-types": "^2.0.7",
73
69
  "@types/ws": "8.18.1",
74
70
  "cross-env": "^10.1.0",
@@ -82,7 +78,7 @@
82
78
  "open": "^11.0.0",
83
79
  "p-retry": "^7.1.1",
84
80
  "prettier": "3.8.1",
85
- "puppeteer": "^24.38.0",
81
+ "puppeteer": "^24.39.0",
86
82
  "react-refresh": "0.18.0",
87
83
  "require-from-string": "^2.0.2",
88
84
  "selfsigned": "^5.5.0",
@@ -100,7 +96,7 @@
100
96
  "optional": true
101
97
  }
102
98
  },
103
- "packageManager": "pnpm@10.31.0",
99
+ "packageManager": "pnpm@10.32.1",
104
100
  "engines": {
105
101
  "node": "^20.19.0 || >=22.12.0"
106
102
  },