@rspack/dev-server 1.2.1 → 2.0.0-beta.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.
Files changed (47) hide show
  1. package/README.md +17 -17
  2. package/client/clients/WebSocketClient.d.ts +17 -0
  3. package/client/clients/WebSocketClient.js +28 -28
  4. package/client/index.d.ts +17 -0
  5. package/client/index.js +224 -363
  6. package/client/modules/logger/Logger.d.ts +40 -0
  7. package/client/modules/logger/Logger.js +123 -0
  8. package/client/modules/logger/createConsoleLogger.d.ts +12 -0
  9. package/client/modules/logger/createConsoleLogger.js +119 -0
  10. package/client/modules/logger/index.d.ts +18 -0
  11. package/client/modules/logger/index.js +20 -712
  12. package/client/modules/types.d.ts +45 -0
  13. package/client/modules/types.js +17 -0
  14. package/client/overlay.d.ts +44 -0
  15. package/client/overlay.js +243 -292
  16. package/client/progress.d.ts +11 -0
  17. package/client/progress.js +178 -111
  18. package/client/socket.d.ts +15 -0
  19. package/client/socket.js +19 -46
  20. package/client/utils/ansiHTML.d.ts +30 -0
  21. package/client/utils/ansiHTML.js +98 -145
  22. package/client/utils/log.d.ts +13 -0
  23. package/client/utils/log.js +7 -17
  24. package/{dist/servers/SockJSServer.d.ts → client/utils/sendMessage.d.ts} +2 -1
  25. package/client/utils/sendMessage.js +6 -15
  26. package/dist/0~launch-editor.js +618 -0
  27. package/dist/0~open.js +547 -0
  28. package/dist/0~p-retry.js +158 -0
  29. package/dist/131.js +1398 -0
  30. package/dist/config.d.ts +1 -3
  31. package/dist/getPort.d.ts +4 -1
  32. package/dist/index.js +1 -5
  33. package/dist/rslib-runtime.js +66 -0
  34. package/dist/server.d.ts +7 -18
  35. package/dist/servers/WebsocketServer.d.ts +8 -1
  36. package/dist/types.d.ts +14 -29
  37. package/package.json +74 -103
  38. package/client/clients/SockJSClient.js +0 -34
  39. package/client/modules/sockjs-client/index.js +0 -4506
  40. package/dist/config.js +0 -2
  41. package/dist/getPort.js +0 -131
  42. package/dist/options.json +0 -1034
  43. package/dist/server.js +0 -2222
  44. package/dist/servers/BaseServer.js +0 -20
  45. package/dist/servers/SockJSServer.js +0 -110
  46. package/dist/servers/WebsocketServer.js +0 -72
  47. package/dist/types.js +0 -5
package/README.md CHANGED
@@ -9,7 +9,10 @@
9
9
 
10
10
  Use Rspack with a development server that provides live reloading. This should be used for development only.
11
11
 
12
- > `@rspack/dev-server` is based on `webpack-dev-server@5`
12
+ ## Versions
13
+
14
+ - `2.x`: For Rspack v2
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.
13
16
 
14
17
  ## Installation
15
18
 
@@ -17,16 +20,16 @@ First of all, install `@rspack/dev-server` and `@rspack/core` by your favorite p
17
20
 
18
21
  ```bash
19
22
  # npm
20
- $ npm install @rspack/dev-server @rspack/core --save-dev
23
+ $ npm install -D @rspack/dev-server @rspack/core
21
24
 
22
25
  # yarn
23
- $ yarn add @rspack/dev-server @rspack/core --dev
26
+ $ yarn add -D @rspack/dev-server @rspack/core
24
27
 
25
28
  # pnpm
26
- $ pnpm add @rspack/dev-server @rspack/core --save-dev
29
+ $ pnpm add -D @rspack/dev-server @rspack/core
27
30
 
28
31
  # bun
29
- $ bun add @rspack/dev-server @rspack/core -D
32
+ $ bun add -D @rspack/dev-server @rspack/core
30
33
  ```
31
34
 
32
35
  ## Usage
@@ -41,16 +44,16 @@ You can install it in your project by:
41
44
 
42
45
  ```bash
43
46
  # npm
44
- $ npm install @rspack/cli --save-dev
47
+ $ npm install -D @rspack/cli
45
48
 
46
49
  # yarn
47
- $ yarn add @rspack/cli --dev
50
+ $ yarn add -D @rspack/cli
48
51
 
49
52
  # pnpm
50
- $ pnpm add @rspack/cli --save-dev
53
+ $ pnpm add -D @rspack/cli
51
54
 
52
55
  # bun
53
- $ bun add @rspack/cli -D
56
+ $ bun add -D @rspack/cli
54
57
  ```
55
58
 
56
59
  And then start the development server by:
@@ -70,7 +73,6 @@ While starting the development server, you can specify the configuration by the
70
73
  ```js
71
74
  // rspack.config.mjs
72
75
  export default {
73
- // ...
74
76
  devServer: {
75
77
  // the configuration of the development server
76
78
  port: 8080,
@@ -78,7 +80,7 @@ export default {
78
80
  };
79
81
  ```
80
82
 
81
- > See [DevServer](https://rspack.rs/config/dev-server) for all configuration options.
83
+ > See [Rspack - devServer](https://rspack.rs/config/dev-server) for all configuration options.
82
84
 
83
85
  ### With the API
84
86
 
@@ -86,12 +88,12 @@ While it's recommended to run `@rspack/dev-server` via the CLI, you may also cho
86
88
 
87
89
  ```js
88
90
  import { RspackDevServer } from '@rspack/dev-server';
89
- import rspack from '@rspack/core';
90
- import rspackConfig from './rspack.config.mjs';
91
+ import { rspack } from '@rspack/core';
92
+ import config from './rspack.config.mjs';
91
93
 
92
- const compiler = rspack(rspackConfig);
94
+ const compiler = rspack(config);
93
95
  const devServerOptions = {
94
- ...rspackConfig.devServer,
96
+ ...config.devServer,
95
97
  // override
96
98
  port: 8888,
97
99
  };
@@ -103,8 +105,6 @@ server.startCallback(() => {
103
105
  });
104
106
  ```
105
107
 
106
- > Cause `@rspack/dev-server` is based on `webpack-dev-server@5`, you can see the [webpack-dev-server API](https://webpack.js.org/api/webpack-dev-server/) for more methods of the server instance.
107
-
108
108
  ## Credits
109
109
 
110
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.
@@ -0,0 +1,17 @@
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 { CommunicationClient } from '../type.js';
11
+ export default class WebSocketClient implements CommunicationClient {
12
+ private client;
13
+ constructor(url: string);
14
+ onOpen(fn: (...args: unknown[]) => void): void;
15
+ onClose(fn: (...args: unknown[]) => void): void;
16
+ onMessage(fn: (...args: unknown[]) => void): void;
17
+ }
@@ -1,32 +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) {
1
+ import { log } from "../utils/log.js";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ else obj[key] = value;
10
+ return obj;
11
+ }
12
+ class WebSocketClient {
13
+ onOpen(fn) {
19
14
  this.client.onopen = fn;
20
- };
21
- WebSocketClient.prototype.onClose = function (fn) {
15
+ }
16
+ onClose(fn) {
22
17
  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) {
18
+ }
19
+ onMessage(fn) {
20
+ this.client.onmessage = (event)=>{
27
21
  fn(event.data);
28
22
  };
29
- };
30
- return WebSocketClient;
31
- }());
32
- export default WebSocketClient;
23
+ }
24
+ constructor(url){
25
+ _define_property(this, "client", void 0);
26
+ this.client = new WebSocket(url);
27
+ this.client.onerror = (error)=>{
28
+ log.error(error);
29
+ };
30
+ }
31
+ }
32
+ export { WebSocketClient as default };
@@ -0,0 +1,17 @@
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
+ declare const parseURL: (resourceQuery: string) => {
11
+ [key: string]: string;
12
+ };
13
+ declare const getCurrentScriptSource: () => string;
14
+ declare const createSocketURL: (parsedURL: URL & {
15
+ fromCurrentScript?: boolean;
16
+ }) => string;
17
+ export { getCurrentScriptSource, parseURL, createSocketURL };