@rspack/dev-server 0.3.12 → 0.3.13
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/middleware.js +7 -2
- package/dist/patch.js +3 -1
- package/dist/server.js +15 -3
- package/package.json +4 -5
package/dist/middleware.js
CHANGED
|
@@ -24,11 +24,15 @@ function getRspackMemoryAssets(compiler, rdm) {
|
|
|
24
24
|
return next();
|
|
25
25
|
}
|
|
26
26
|
// css hmr will append query string, so here need to remove query string
|
|
27
|
+
// @ts-expect-error
|
|
27
28
|
const path = (0, url_1.parse)(url).pathname;
|
|
28
29
|
// asset name is not start with /, so path need to slice 1
|
|
30
|
+
// @ts-expect-error
|
|
29
31
|
const filename = path.startsWith(publicPath)
|
|
30
|
-
?
|
|
31
|
-
|
|
32
|
+
? // @ts-expect-error
|
|
33
|
+
path.slice(publicPath.length)
|
|
34
|
+
: // @ts-expect-error
|
|
35
|
+
path.slice(1);
|
|
32
36
|
const buffer = (_a = compiler.getAsset(filename)) !== null && _a !== void 0 ? _a : (() => {
|
|
33
37
|
const { index } = rdm.context.options;
|
|
34
38
|
const indexValue = typeof index === "undefined" || typeof index === "boolean"
|
|
@@ -45,6 +49,7 @@ function getRspackMemoryAssets(compiler, rdm) {
|
|
|
45
49
|
}
|
|
46
50
|
else {
|
|
47
51
|
contentType =
|
|
52
|
+
// @ts-expect-error
|
|
48
53
|
mime_types_1.default.contentType((0, path_1.extname)(path)) || "text/plain; charset=utf-8";
|
|
49
54
|
}
|
|
50
55
|
const calcEtag = etag(buffer);
|
package/dist/patch.js
CHANGED
|
@@ -18,7 +18,9 @@ function applyDevServerPatch() {
|
|
|
18
18
|
// @ts-expect-error private API
|
|
19
19
|
old = webpack_dev_server_1.default.prototype.sendStats;
|
|
20
20
|
// @ts-expect-error private API
|
|
21
|
-
webpack_dev_server_1.default.prototype.sendStats = function sendStats__rspack_patched(
|
|
21
|
+
webpack_dev_server_1.default.prototype.sendStats = function sendStats__rspack_patched(
|
|
22
|
+
// @ts-expect-error
|
|
23
|
+
...args) {
|
|
22
24
|
let stats = args[1];
|
|
23
25
|
if (!stats) {
|
|
24
26
|
return;
|
package/dist/server.js
CHANGED
|
@@ -23,7 +23,9 @@ const patch_1 = require("./patch");
|
|
|
23
23
|
(0, patch_1.applyDevServerPatch)();
|
|
24
24
|
class RspackDevServer extends webpack_dev_server_1.default {
|
|
25
25
|
constructor(options, compiler) {
|
|
26
|
-
super(
|
|
26
|
+
super(
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
{
|
|
27
29
|
...options,
|
|
28
30
|
setupMiddlewares: (middlewares, devServer) => {
|
|
29
31
|
var _a;
|
|
@@ -37,7 +39,9 @@ class RspackDevServer extends webpack_dev_server_1.default {
|
|
|
37
39
|
return {
|
|
38
40
|
name: "rspack-memory-assets",
|
|
39
41
|
path: publicPath,
|
|
40
|
-
middleware: (0, middleware_1.getRspackMemoryAssets)(compiler,
|
|
42
|
+
middleware: (0, middleware_1.getRspackMemoryAssets)(compiler,
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
this.middleware)
|
|
41
45
|
};
|
|
42
46
|
});
|
|
43
47
|
});
|
|
@@ -45,6 +49,7 @@ class RspackDevServer extends webpack_dev_server_1.default {
|
|
|
45
49
|
middlewares.splice(webpackDevMiddlewareIndex, 0, ...memoryAssetsMiddlewares);
|
|
46
50
|
}
|
|
47
51
|
}
|
|
52
|
+
// @ts-expect-error
|
|
48
53
|
(_a = options.setupMiddlewares) === null || _a === void 0 ? void 0 : _a.call(this, middlewares, devServer);
|
|
49
54
|
return middlewares;
|
|
50
55
|
}
|
|
@@ -102,6 +107,7 @@ class RspackDevServer extends webpack_dev_server_1.default {
|
|
|
102
107
|
? "When you use custom web socket implementation you must explicitly specify client.webSocketTransport. "
|
|
103
108
|
: ""}client.webSocketTransport must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to a JS file via require.resolve(...) which exports a class `);
|
|
104
109
|
}
|
|
110
|
+
// @ts-expect-error
|
|
105
111
|
return clientImplementation;
|
|
106
112
|
}
|
|
107
113
|
async initialize() {
|
|
@@ -120,7 +126,9 @@ class RspackDevServer extends webpack_dev_server_1.default {
|
|
|
120
126
|
// enable hot by default
|
|
121
127
|
(_a = (_f = compiler.options).devServer) !== null && _a !== void 0 ? _a : (_f.devServer = {});
|
|
122
128
|
compiler.options.devServer.hot = true;
|
|
123
|
-
if (
|
|
129
|
+
if (
|
|
130
|
+
// @ts-expect-error
|
|
131
|
+
!compiler.options.experiments.rspackFuture.disableTransformByDefault) {
|
|
124
132
|
(_b = (_g = compiler.options.builtins).react) !== null && _b !== void 0 ? _b : (_g.react = {});
|
|
125
133
|
// enable react.development by default
|
|
126
134
|
(_c = (_h = compiler.options.builtins.react).development) !== null && _c !== void 0 ? _c : (_h.development = true);
|
|
@@ -236,6 +244,7 @@ class RspackDevServer extends webpack_dev_server_1.default {
|
|
|
236
244
|
compilers.forEach(compiler => {
|
|
237
245
|
if (compiler.options.experiments.lazyCompilation) {
|
|
238
246
|
middlewares.push({
|
|
247
|
+
// @ts-expect-error
|
|
239
248
|
middleware: (req, res) => {
|
|
240
249
|
if (req.url.indexOf("/lazy-compilation-web/") > -1) {
|
|
241
250
|
const path = req.url.replace("/lazy-compilation-web/", "");
|
|
@@ -256,12 +265,15 @@ class RspackDevServer extends webpack_dev_server_1.default {
|
|
|
256
265
|
});
|
|
257
266
|
middlewares.forEach(middleware => {
|
|
258
267
|
if (typeof middleware === "function") {
|
|
268
|
+
// @ts-expect-error
|
|
259
269
|
this.app.use(middleware);
|
|
260
270
|
}
|
|
261
271
|
else if (typeof middleware.path !== "undefined") {
|
|
272
|
+
// @ts-expect-error
|
|
262
273
|
this.app.use(middleware.path, middleware.middleware);
|
|
263
274
|
}
|
|
264
275
|
else {
|
|
276
|
+
// @ts-expect-error
|
|
265
277
|
this.app.use(middleware.middleware);
|
|
266
278
|
}
|
|
267
279
|
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/dev-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Development server for rspack",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
10
|
"default": "./dist/index.js"
|
|
12
11
|
},
|
|
13
12
|
"./package.json": "./package.json"
|
|
@@ -29,8 +28,8 @@
|
|
|
29
28
|
"@types/ws": "8.5.3",
|
|
30
29
|
"fs-extra": "11.1.0",
|
|
31
30
|
"puppeteer": "19.4.0",
|
|
32
|
-
"@rspack/
|
|
33
|
-
"@rspack/
|
|
31
|
+
"@rspack/core": "0.3.13",
|
|
32
|
+
"@rspack/dev-server": "0.3.13"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
35
|
"chokidar": "3.5.3",
|
|
@@ -42,7 +41,7 @@
|
|
|
42
41
|
"webpack-dev-middleware": "6.0.2",
|
|
43
42
|
"webpack-dev-server": "4.13.1",
|
|
44
43
|
"ws": "8.8.1",
|
|
45
|
-
"@rspack/plugin-react-refresh": "0.3.
|
|
44
|
+
"@rspack/plugin-react-refresh": "0.3.13"
|
|
46
45
|
},
|
|
47
46
|
"peerDependencies": {
|
|
48
47
|
"@rspack/core": "*"
|