@rspack/dev-server 2.0.0-beta.2 → 2.0.0-beta.3
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/README.md +1 -1
- package/client/type.d.ts +15 -0
- package/client/type.js +0 -0
- package/dist/131.js +10 -6
- package/dist/server.d.ts +4 -3
- package/dist/types.d.ts +10 -10
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Use Rspack with a development server that provides live reloading. This should b
|
|
|
11
11
|
|
|
12
12
|
## Versions
|
|
13
13
|
|
|
14
|
-
- `2.x`: For Rspack v2
|
|
14
|
+
- `2.x`: For Rspack v2, see [v1 -> v2](./docs/migrate-v1-to-v2.md) for migration guide.
|
|
15
15
|
- `1.x`: For Rspack v1, see [v1.x - README](https://github.com/rstackjs/rspack-dev-server/tree/v1.x#rspackdev-server) for usage guide.
|
|
16
16
|
|
|
17
17
|
## Installation
|
package/client/type.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type LogLevel = false | true | 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
|
|
2
|
+
export type EXPECTED_ANY = any;
|
|
3
|
+
declare global {
|
|
4
|
+
const __resourceQuery: string;
|
|
5
|
+
const BUILD_HASH: string;
|
|
6
|
+
const RESOURCE_QUERY: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CommunicationClient {
|
|
9
|
+
onOpen(fn: (...args: unknown[]) => void): void;
|
|
10
|
+
onClose(fn: (...args: unknown[]) => void): void;
|
|
11
|
+
onMessage(fn: (...args: unknown[]) => void): void;
|
|
12
|
+
}
|
|
13
|
+
export interface CommunicationClientConstructor {
|
|
14
|
+
new (url: string): CommunicationClient;
|
|
15
|
+
}
|
package/client/type.js
ADDED
|
File without changes
|
package/dist/131.js
CHANGED
|
@@ -142,7 +142,11 @@ const memoize = (fn)=>{
|
|
|
142
142
|
return result;
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
|
-
const
|
|
145
|
+
const getConnect = async ()=>{
|
|
146
|
+
const { connect } = await import("connect-next");
|
|
147
|
+
return connect;
|
|
148
|
+
};
|
|
149
|
+
const getServeStatic = memoize(()=>server_require('serve-static'));
|
|
146
150
|
const encodeOverlaySettings = (setting)=>'function' == typeof setting ? encodeURIComponent(setting.toString()) : setting;
|
|
147
151
|
const DEFAULT_ALLOWED_PROTOCOLS = /^(file|.+-extension):/i;
|
|
148
152
|
function parseHostnameFromHeader(header) {
|
|
@@ -840,7 +844,7 @@ class Server {
|
|
|
840
844
|
for (const webSocketProxy of webSocketProxies)this.server.on('upgrade', webSocketProxy.upgrade);
|
|
841
845
|
}
|
|
842
846
|
async setupApp() {
|
|
843
|
-
this.app = 'function' == typeof this.options.app ? await this.options.app() :
|
|
847
|
+
this.app = 'function' == typeof this.options.app ? await this.options.app() : (await getConnect())();
|
|
844
848
|
}
|
|
845
849
|
getStats(statsObj) {
|
|
846
850
|
const stats = Server.DEFAULT_STATS;
|
|
@@ -1030,9 +1034,9 @@ class Server {
|
|
|
1030
1034
|
}
|
|
1031
1035
|
const staticOptions = this.options.static;
|
|
1032
1036
|
if (staticOptions.length > 0) for (const staticOption of staticOptions)for (const publicPath of staticOption.publicPath)middlewares.push({
|
|
1033
|
-
name: '
|
|
1037
|
+
name: 'serve-static',
|
|
1034
1038
|
path: publicPath,
|
|
1035
|
-
middleware:
|
|
1039
|
+
middleware: getServeStatic()(staticOption.directory, staticOption.staticOptions)
|
|
1036
1040
|
});
|
|
1037
1041
|
if (this.options.historyApiFallback) {
|
|
1038
1042
|
const connectHistoryApiFallback = server_require('connect-history-api-fallback');
|
|
@@ -1047,9 +1051,9 @@ class Server {
|
|
|
1047
1051
|
middleware: this.middleware
|
|
1048
1052
|
});
|
|
1049
1053
|
if (staticOptions.length > 0) for (const staticOption of staticOptions)for (const publicPath of staticOption.publicPath)middlewares.push({
|
|
1050
|
-
name: '
|
|
1054
|
+
name: 'serve-static',
|
|
1051
1055
|
path: publicPath,
|
|
1052
|
-
middleware:
|
|
1056
|
+
middleware: getServeStatic()(staticOption.directory, staticOption.staticOptions)
|
|
1053
1057
|
});
|
|
1054
1058
|
}
|
|
1055
1059
|
if (staticOptions.length > 0) {
|
package/dist/server.d.ts
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
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,
|
|
11
|
-
|
|
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';
|
|
11
|
+
import type { ConnectApplication } from './types';
|
|
12
|
+
export interface Configuration<A extends BasicApplication = ConnectApplication, S extends HTTPServer = HTTPServer> {
|
|
12
13
|
ipc?: boolean | string;
|
|
13
14
|
host?: Host;
|
|
14
15
|
port?: Port;
|
|
@@ -31,7 +32,7 @@ export interface Configuration<A extends BasicApplication = ExpressApplication,
|
|
|
31
32
|
onListening?: (devServer: Server<A, S>) => void;
|
|
32
33
|
setupMiddlewares?: (middlewares: Middleware[], devServer: Server<A, S>) => Middleware[];
|
|
33
34
|
}
|
|
34
|
-
declare class Server<A extends BasicApplication =
|
|
35
|
+
declare class Server<A extends BasicApplication = ConnectApplication, S extends import('http').Server = HTTPServer> {
|
|
35
36
|
compiler: Compiler | MultiCompiler;
|
|
36
37
|
logger: ReturnType<Compiler['getInfrastructureLogger']>;
|
|
37
38
|
options: Configuration<A, S>;
|
package/dist/types.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export type { NetworkInterfaceInfo } from 'node:os';
|
|
|
6
6
|
export type { Compiler, DevServer, MultiCompiler, MultiStats, Stats, StatsCompilation, StatsOptions, } from '@rspack/core';
|
|
7
7
|
import type { FSWatcher, WatchOptions } from 'chokidar';
|
|
8
8
|
export type { FSWatcher, WatchOptions };
|
|
9
|
+
import type { Server as ConnectApplication, IncomingMessage as ConnectIncomingMessage } from 'connect-next';
|
|
10
|
+
export type { ConnectApplication };
|
|
9
11
|
import type { Options as ConnectHistoryApiFallbackOptions } from 'connect-history-api-fallback';
|
|
10
12
|
export type { ConnectHistoryApiFallbackOptions };
|
|
11
|
-
import type { Application as ExpressApplication, ErrorRequestHandler as ExpressErrorRequestHandler, Request as ExpressRequest, RequestHandler as ExpressRequestHandler, Response as ExpressResponse } from 'express';
|
|
12
|
-
export type { ExpressApplication };
|
|
13
13
|
import type { Options as HttpProxyMiddlewareOptions, Filter as HttpProxyMiddlewareOptionsFilter, RequestHandler } from 'http-proxy-middleware';
|
|
14
14
|
export type { RequestHandler };
|
|
15
15
|
export type { IPv6 } from 'ipaddr.js';
|
|
@@ -25,8 +25,8 @@ export type NextHandleFunction = (req: IncomingMessage, res: ServerResponse, nex
|
|
|
25
25
|
export type ErrorHandleFunction = (err: EXPECTED_ANY, req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
|
|
26
26
|
export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
|
|
27
27
|
export type ServerOptions = import('https').ServerOptions;
|
|
28
|
-
export type Request<T extends BasicApplication =
|
|
29
|
-
export type Response
|
|
28
|
+
export type Request<T extends BasicApplication = ConnectApplication> = T extends ConnectApplication ? ConnectIncomingMessage : IncomingMessage;
|
|
29
|
+
export type Response = ServerResponse;
|
|
30
30
|
export type DevMiddlewareOptions<T extends Request, U extends Response> = import('webpack-dev-middleware').Options<T, U>;
|
|
31
31
|
export type DevMiddlewareContext<T extends Request, U extends Response> = import('webpack-dev-middleware').Context<T, U>;
|
|
32
32
|
export type Host = LiteralUnion<'local-ip' | 'local-ipv4' | 'local-ipv6', string>;
|
|
@@ -57,8 +57,8 @@ export interface NormalizedStatic {
|
|
|
57
57
|
staticOptions: ServeStaticOptions;
|
|
58
58
|
watch: false | WatchOptions;
|
|
59
59
|
}
|
|
60
|
-
export type ServerType<A extends BasicApplication =
|
|
61
|
-
export interface ServerConfiguration<A extends BasicApplication =
|
|
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> {
|
|
62
62
|
type?: ServerType<A, S>;
|
|
63
63
|
options?: ServerOptions;
|
|
64
64
|
}
|
|
@@ -118,13 +118,13 @@ export type Headers = Array<{
|
|
|
118
118
|
key: string;
|
|
119
119
|
value: string;
|
|
120
120
|
}> | Record<string, string | string[]>;
|
|
121
|
-
export type MiddlewareHandler
|
|
122
|
-
export interface MiddlewareObject
|
|
121
|
+
export type MiddlewareHandler = (...args: EXPECTED_ANY[]) => EXPECTED_ANY;
|
|
122
|
+
export interface MiddlewareObject {
|
|
123
123
|
name?: string;
|
|
124
124
|
path?: string;
|
|
125
|
-
middleware: MiddlewareHandler
|
|
125
|
+
middleware: MiddlewareHandler;
|
|
126
126
|
}
|
|
127
|
-
export type Middleware
|
|
127
|
+
export type Middleware = MiddlewareObject | MiddlewareHandler;
|
|
128
128
|
export type BasicServer = import('net').Server | import('tls').Server;
|
|
129
129
|
export type OverlayMessageOptions = boolean | ((error: Error) => void);
|
|
130
130
|
declare function useFn(fn: NextHandleFunction): BasicApplication;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/dev-server",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Development server for rspack",
|
|
5
5
|
"homepage": "https://rspack.rs",
|
|
6
6
|
"bugs": "https://github.com/rstackjs/rspack-dev-server/issues",
|
|
@@ -50,40 +50,40 @@
|
|
|
50
50
|
"@types/serve-static": "^2.2.0",
|
|
51
51
|
"@types/ws": "^8.18.1",
|
|
52
52
|
"chokidar": "^3.6.0",
|
|
53
|
+
"connect-next": "^4.0.0",
|
|
53
54
|
"connect-history-api-fallback": "^2.0.0",
|
|
54
|
-
"express": "^5.2.1",
|
|
55
55
|
"http-proxy-middleware": "^3.0.5",
|
|
56
56
|
"ipaddr.js": "^2.3.0",
|
|
57
|
+
"serve-static": "^2.2.1",
|
|
57
58
|
"serve-index": "^1.9.2",
|
|
58
59
|
"webpack-dev-middleware": "^7.4.5",
|
|
59
60
|
"ws": "^8.19.0"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@biomejs/biome": "^1.9.4",
|
|
63
|
-
"@hono/node-server": "^1.19.
|
|
64
|
+
"@hono/node-server": "^1.19.11",
|
|
64
65
|
"@rslib/core": "^0.19.6",
|
|
65
66
|
"@rspack/core": "2.0.0-beta.5",
|
|
66
67
|
"@rspack/plugin-react-refresh": "1.6.1",
|
|
67
|
-
"@rstest/core": "^0.
|
|
68
|
+
"@rstest/core": "^0.9.0",
|
|
68
69
|
"@types/compression": "^1.8.1",
|
|
69
|
-
"@types/express": "5.0.6",
|
|
70
70
|
"@types/mime-types": "3.0.1",
|
|
71
|
-
"@types/node": "^24.
|
|
71
|
+
"@types/node": "^24.12.0",
|
|
72
72
|
"@types/node-forge": "^1.3.14",
|
|
73
73
|
"@types/trusted-types": "^2.0.7",
|
|
74
74
|
"@types/ws": "8.18.1",
|
|
75
|
+
"express": "^5.2.1",
|
|
75
76
|
"compression": "^1.8.1",
|
|
76
|
-
"connect": "^3.7.0",
|
|
77
77
|
"cross-env": "^10.1.0",
|
|
78
78
|
"css-loader": "^7.1.4",
|
|
79
|
-
"hono": "^4.12.
|
|
79
|
+
"hono": "^4.12.5",
|
|
80
80
|
"http-proxy": "^1.18.1",
|
|
81
81
|
"launch-editor": "^2.13.1",
|
|
82
82
|
"nano-staged": "^0.9.0",
|
|
83
83
|
"open": "^11.0.0",
|
|
84
84
|
"p-retry": "^7.1.1",
|
|
85
85
|
"prettier": "3.8.1",
|
|
86
|
-
"puppeteer": "^24.
|
|
86
|
+
"puppeteer": "^24.38.0",
|
|
87
87
|
"react-refresh": "0.18.0",
|
|
88
88
|
"require-from-string": "^2.0.2",
|
|
89
89
|
"selfsigned": "^5.5.0",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"optional": true
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
|
-
"packageManager": "pnpm@10.
|
|
104
|
+
"packageManager": "pnpm@10.31.0",
|
|
105
105
|
"engines": {
|
|
106
106
|
"node": "^20.19.0 || >=22.12.0"
|
|
107
107
|
},
|