@rspack/dev-server 1.1.4 → 1.2.0
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 +14 -17
- package/client/clients/SockJSClient.js +34 -0
- package/client/clients/WebSocketClient.js +32 -0
- package/client/index.js +131 -214
- package/client/modules/logger/index.js +725 -0
- package/client/modules/sockjs-client/index.js +4506 -0
- package/client/overlay.js +503 -0
- package/client/progress.js +130 -0
- package/client/socket.js +60 -0
- package/client/utils/ansiHTML.js +63 -64
- package/client/utils/log.js +21 -0
- package/client/utils/sendMessage.js +17 -0
- package/dist/config.d.ts +14 -15
- package/dist/getPort.d.ts +10 -0
- package/dist/getPort.js +131 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -1
- package/dist/options.json +1034 -0
- package/dist/server.d.ts +106 -23
- package/dist/server.js +2195 -46
- package/dist/servers/BaseServer.d.ts +17 -0
- package/dist/servers/BaseServer.js +20 -0
- package/dist/servers/SockJSServer.d.ts +10 -0
- package/dist/servers/SockJSServer.js +110 -0
- package/dist/servers/WebsocketServer.d.ts +10 -0
- package/dist/servers/WebsocketServer.js +72 -0
- package/dist/types.d.ts +158 -0
- package/dist/types.js +5 -0
- package/package.json +66 -29
- package/dist/patch.d.ts +0 -3
- package/dist/patch.js +0 -32
package/README.md
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
<picture>
|
|
2
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://assets.rspack.dev/rspack/rspack-banner-plain-dark.png">
|
|
3
|
-
<img alt="Rspack Banner" src="https://assets.rspack.dev/rspack/rspack-banner-plain-light.png">
|
|
4
|
-
</picture>
|
|
5
|
-
|
|
6
1
|
# @rspack/dev-server
|
|
7
2
|
|
|
8
3
|
<p>
|
|
9
4
|
<a href="https://npmjs.com/package/@rspack/dev-server?activeTab=readme"><img src="https://img.shields.io/npm/v/@rspack/dev-server?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /></a>
|
|
10
5
|
<a href="https://npmcharts.com/compare/@rspack/dev-server?minimal=true"><img src="https://img.shields.io/npm/dm/@rspack/dev-server.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
11
6
|
<a href="https://nodejs.org/en/about/previous-releases"><img src="https://img.shields.io/node/v/@rspack/dev-server.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="node version"></a>
|
|
12
|
-
<a href="https://github.com/
|
|
7
|
+
<a href="https://github.com/rstackjs/rspack-dev-server/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" /></a>
|
|
13
8
|
</p>
|
|
14
9
|
|
|
15
10
|
Use Rspack with a development server that provides live reloading. This should be used for development only.
|
|
@@ -68,37 +63,37 @@ $ rspack serve
|
|
|
68
63
|
$ rspack serve -c ./your.config.js
|
|
69
64
|
```
|
|
70
65
|
|
|
71
|
-
> See [CLI](https://rspack.
|
|
66
|
+
> See [CLI](https://rspack.rs/api/cli) for more details.
|
|
72
67
|
|
|
73
68
|
While starting the development server, you can specify the configuration by the `devServer` field of your Rspack config file:
|
|
74
69
|
|
|
75
70
|
```js
|
|
76
|
-
// rspack.config.
|
|
77
|
-
|
|
71
|
+
// rspack.config.mjs
|
|
72
|
+
export default {
|
|
78
73
|
// ...
|
|
79
74
|
devServer: {
|
|
80
75
|
// the configuration of the development server
|
|
81
|
-
port: 8080
|
|
76
|
+
port: 8080,
|
|
82
77
|
},
|
|
83
78
|
};
|
|
84
79
|
```
|
|
85
80
|
|
|
86
|
-
> See [DevServer](https://rspack.
|
|
81
|
+
> See [DevServer](https://rspack.rs/config/dev-server) for all configuration options.
|
|
87
82
|
|
|
88
83
|
### With the API
|
|
89
84
|
|
|
90
85
|
While it's recommended to run `@rspack/dev-server` via the CLI, you may also choose to start a server via the API.
|
|
91
86
|
|
|
92
87
|
```js
|
|
93
|
-
import { RspackDevServer } from
|
|
94
|
-
import rspack from
|
|
95
|
-
import rspackConfig from './rspack.config.
|
|
88
|
+
import { RspackDevServer } from '@rspack/dev-server';
|
|
89
|
+
import rspack from '@rspack/core';
|
|
90
|
+
import rspackConfig from './rspack.config.mjs';
|
|
96
91
|
|
|
97
92
|
const compiler = rspack(rspackConfig);
|
|
98
93
|
const devServerOptions = {
|
|
99
94
|
...rspackConfig.devServer,
|
|
100
95
|
// override
|
|
101
|
-
port: 8888
|
|
96
|
+
port: 8888,
|
|
102
97
|
};
|
|
103
98
|
|
|
104
99
|
const server = new RspackDevServer(devServerOptions, compiler);
|
|
@@ -112,8 +107,10 @@ server.startCallback(() => {
|
|
|
112
107
|
|
|
113
108
|
## Credits
|
|
114
109
|
|
|
115
|
-
|
|
110
|
+
This plugin is forked from [webpack-dev-server](https://github.com/webpack/webpack-dev-server), and is used to smooth out some differences between rspack and webpack, while also providing rspack-specific new features.
|
|
111
|
+
|
|
112
|
+
> Thanks to the [webpack-dev-server](https://github.com/webpack/webpack-dev-server) project created by [@sokra](https://github.com/sokra)
|
|
116
113
|
|
|
117
114
|
## License
|
|
118
115
|
|
|
119
|
-
[MIT licensed](https://github.com/
|
|
116
|
+
[MIT licensed](https://github.com/rstackjs/rspack-dev-server/blob/main/LICENSE).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The following code is modified based on
|
|
3
|
+
* https://github.com/webpack/webpack-dev-server
|
|
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/main/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
import SockJS from '../modules/sockjs-client/index.js';
|
|
11
|
+
import { log } from '../utils/log.js';
|
|
12
|
+
var SockJSClient = /** @class */ (function () {
|
|
13
|
+
function SockJSClient(url) {
|
|
14
|
+
// SockJS requires `http` and `https` protocols
|
|
15
|
+
this.sock = new SockJS(url.replace(/^ws:/i, 'http:').replace(/^wss:/i, 'https:'));
|
|
16
|
+
this.sock.onerror = function (error) {
|
|
17
|
+
log.error(error);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
SockJSClient.prototype.onOpen = function (fn) {
|
|
21
|
+
this.sock.onopen = fn;
|
|
22
|
+
};
|
|
23
|
+
SockJSClient.prototype.onClose = function (fn) {
|
|
24
|
+
this.sock.onclose = fn;
|
|
25
|
+
};
|
|
26
|
+
// call f with the message string as the first argument
|
|
27
|
+
SockJSClient.prototype.onMessage = function (fn) {
|
|
28
|
+
this.sock.onmessage = function (err) {
|
|
29
|
+
fn(err.data);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
return SockJSClient;
|
|
33
|
+
}());
|
|
34
|
+
export default SockJSClient;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The following code is modified based on
|
|
3
|
+
* https://github.com/webpack/webpack-dev-server
|
|
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/main/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
import { log } from '../utils/log.js';
|
|
11
|
+
var WebSocketClient = /** @class */ (function () {
|
|
12
|
+
function WebSocketClient(url) {
|
|
13
|
+
this.client = new WebSocket(url);
|
|
14
|
+
this.client.onerror = function (error) {
|
|
15
|
+
log.error(error);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
WebSocketClient.prototype.onOpen = function (fn) {
|
|
19
|
+
this.client.onopen = fn;
|
|
20
|
+
};
|
|
21
|
+
WebSocketClient.prototype.onClose = function (fn) {
|
|
22
|
+
this.client.onclose = fn;
|
|
23
|
+
};
|
|
24
|
+
// call fn with the message string as the first argument
|
|
25
|
+
WebSocketClient.prototype.onMessage = function (fn) {
|
|
26
|
+
this.client.onmessage = function (event) {
|
|
27
|
+
fn(event.data);
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
return WebSocketClient;
|
|
31
|
+
}());
|
|
32
|
+
export default WebSocketClient;
|