@rspack/dev-server 1.1.0 → 1.1.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.
- package/client/index.js +1 -2
- package/dist/config.d.ts +1 -1
- package/dist/server.d.ts +1 -0
- package/package.json +6 -7
- package/dist/middleware.d.ts +0 -4
- package/dist/middleware.js +0 -77
package/client/index.js
CHANGED
|
@@ -18,7 +18,6 @@ import webpackHotLog from "@rspack/core/hot/log.js";
|
|
|
18
18
|
import { createOverlay, formatProblem, } from "webpack-dev-server/client/overlay.js";
|
|
19
19
|
import socket from "webpack-dev-server/client/socket.js";
|
|
20
20
|
import { defineProgressElement, isProgressSupported, } from "webpack-dev-server/client/progress.js";
|
|
21
|
-
import socket from "webpack-dev-server/client/socket.js";
|
|
22
21
|
import { log, setLogLevel } from "webpack-dev-server/client/utils/log.js";
|
|
23
22
|
import sendMessage from "webpack-dev-server/client/utils/sendMessage.js";
|
|
24
23
|
/**
|
|
@@ -157,7 +156,7 @@ if (parsedResourceQuery.overlay) {
|
|
|
157
156
|
options.overlay = __assign({ errors: true, warnings: true, runtimeErrors: true }, options.overlay);
|
|
158
157
|
decodeOverlayOptions(options.overlay);
|
|
159
158
|
}
|
|
160
|
-
enabledFeatures.Overlay =
|
|
159
|
+
enabledFeatures.Overlay = options.overlay !== false;
|
|
161
160
|
}
|
|
162
161
|
if (parsedResourceQuery.logging) {
|
|
163
162
|
options.logging = parsedResourceQuery.logging;
|
package/dist/config.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface ResolvedDevServer extends DevServer {
|
|
|
11
11
|
magicHtml: boolean;
|
|
12
12
|
liveReload: boolean;
|
|
13
13
|
webSocketServer: false | WebpackDevServer.WebSocketServerConfiguration;
|
|
14
|
-
proxy:
|
|
14
|
+
proxy: Required<DevServer["proxy"]>;
|
|
15
15
|
client: WebpackDevServer.ClientConfiguration;
|
|
16
16
|
allowedHosts: "auto" | string[] | "all";
|
|
17
17
|
bonjour: false | Record<string, never> | WebpackDevServer.BonjourOptions;
|
package/dist/server.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare class RspackDevServer extends WebpackDevServer {
|
|
|
20
20
|
/**
|
|
21
21
|
* resolved after `normalizedOptions`
|
|
22
22
|
*/
|
|
23
|
+
/** @ts-ignore: types of path data of rspack is not compatible with webpack */
|
|
23
24
|
options: ResolvedDevServer;
|
|
24
25
|
staticWatchers: FSWatcher[];
|
|
25
26
|
sockets: Socket[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/dev-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Development server for rspack",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -76,17 +76,16 @@
|
|
|
76
76
|
"ts-jest": "29.1.2",
|
|
77
77
|
"typescript": "5.0.2",
|
|
78
78
|
"wait-for-expect": "^3.0.2",
|
|
79
|
-
"webpack": "^5.94.0"
|
|
79
|
+
"webpack": "^5.94.0",
|
|
80
|
+
"webpack-dev-middleware": "^7.4.2",
|
|
81
|
+
"express": "^4.21.2"
|
|
80
82
|
},
|
|
81
83
|
"dependencies": {
|
|
82
84
|
"chokidar": "^3.6.0",
|
|
83
|
-
"
|
|
84
|
-
"http-proxy-middleware": "^2.0.6",
|
|
85
|
-
"mime-types": "^2.1.35",
|
|
85
|
+
"http-proxy-middleware": "^2.0.7",
|
|
86
86
|
"p-retry": "^6.2.0",
|
|
87
|
-
"webpack-dev-middleware": "^7.4.2",
|
|
88
87
|
"webpack-dev-server": "5.2.0",
|
|
89
|
-
"ws": "^8.
|
|
88
|
+
"ws": "^8.18.0"
|
|
90
89
|
},
|
|
91
90
|
"peerDependencies": {
|
|
92
91
|
"@rspack/core": "*"
|
package/dist/middleware.d.ts
DELETED
package/dist/middleware.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getRspackMemoryAssets = void 0;
|
|
7
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
|
-
const node_path_1 = require("node:path");
|
|
9
|
-
const node_url_1 = require("node:url");
|
|
10
|
-
const mime_types_1 = __importDefault(require("mime-types"));
|
|
11
|
-
// biome-ignore lint/suspicious/noExplicitAny: _
|
|
12
|
-
function etag(buf) {
|
|
13
|
-
const hash = node_crypto_1.default.createHash("sha256").update(buf).digest("hex");
|
|
14
|
-
const etag = hash;
|
|
15
|
-
return etag;
|
|
16
|
-
}
|
|
17
|
-
function createPublicPathGetter(compiler) {
|
|
18
|
-
const raw = compiler.options.output.publicPath || "/";
|
|
19
|
-
if (typeof raw === "function") {
|
|
20
|
-
return (compilation) => compilation ? compilation.getPath(raw) : raw({ hash: "XXXX" }, undefined);
|
|
21
|
-
}
|
|
22
|
-
if (/\[(hash|fullhash)[:\]]/.test(raw)) {
|
|
23
|
-
return (compilation) => compilation ? compilation.getPath(raw) : `${raw.replace(/\/$/, "")}/`;
|
|
24
|
-
}
|
|
25
|
-
return () => `${raw.replace(/\/$/, "")}/`;
|
|
26
|
-
}
|
|
27
|
-
function getRspackMemoryAssets(compiler, rdm) {
|
|
28
|
-
const getPublicPath = createPublicPathGetter(compiler);
|
|
29
|
-
return (req, res, next) => {
|
|
30
|
-
const { method, url } = req;
|
|
31
|
-
if (method !== "GET") {
|
|
32
|
-
return next();
|
|
33
|
-
}
|
|
34
|
-
// css hmr will append query string, so here need to remove query string
|
|
35
|
-
// @ts-expect-error
|
|
36
|
-
const path = (0, node_url_1.parse)(url).pathname;
|
|
37
|
-
const publicPath = getPublicPath(compiler._lastCompilation);
|
|
38
|
-
// asset name is not start with /, so path need to slice 1
|
|
39
|
-
// @ts-expect-error
|
|
40
|
-
const filename = path.startsWith(publicPath)
|
|
41
|
-
? // @ts-expect-error
|
|
42
|
-
path.slice(publicPath.length)
|
|
43
|
-
: // @ts-expect-error
|
|
44
|
-
path.slice(1);
|
|
45
|
-
const buffer = compiler._lastCompilation?.getAsset(filename) ??
|
|
46
|
-
(() => {
|
|
47
|
-
const { index } = rdm.context.options;
|
|
48
|
-
const indexValue = typeof index === "undefined" || typeof index === "boolean"
|
|
49
|
-
? "index.html"
|
|
50
|
-
: index;
|
|
51
|
-
return compiler._lastCompilation?.getAsset(filename + indexValue);
|
|
52
|
-
})();
|
|
53
|
-
if (!buffer) {
|
|
54
|
-
return next();
|
|
55
|
-
}
|
|
56
|
-
let contentType;
|
|
57
|
-
if (filename === "") {
|
|
58
|
-
contentType = "text/html; charset=utf-8";
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
contentType =
|
|
62
|
-
// @ts-expect-error
|
|
63
|
-
mime_types_1.default.contentType((0, node_path_1.extname)(path)) || "text/plain; charset=utf-8";
|
|
64
|
-
}
|
|
65
|
-
const calcEtag = etag(buffer);
|
|
66
|
-
const oldEtag = req.headers["if-none-match"];
|
|
67
|
-
res.setHeader("Content-Type", contentType);
|
|
68
|
-
res.setHeader("ETag", calcEtag);
|
|
69
|
-
if (calcEtag === oldEtag) {
|
|
70
|
-
res.status(304).send();
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
res.send(buffer);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
exports.getRspackMemoryAssets = getRspackMemoryAssets;
|