@rspack/dev-server 2.0.0-beta.3 → 2.0.0-beta.4
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/131.js +95 -7
- package/dist/rslib-runtime.js +9 -0
- package/package.json +5 -6
package/dist/131.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as __rspack_external_zlib from "zlib";
|
|
1
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
3
|
import node_fs, { lstatSync, promises, readFileSync, realpathSync, statSync, unlinkSync } from "node:fs";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
@@ -8,6 +9,94 @@ import { deprecate, promisify, styleText } from "node:util";
|
|
|
8
9
|
import ipaddr from "ipaddr.js";
|
|
9
10
|
import { createServer } from "node:net";
|
|
10
11
|
import { WebSocketServer } from "ws";
|
|
12
|
+
__webpack_require__.add({
|
|
13
|
+
"./node_modules/.pnpm/http-compression@1.1.2/node_modules/http-compression/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
14
|
+
const zlib = __webpack_require__("zlib");
|
|
15
|
+
const MIMES = /text|javascript|\/json|xml/i;
|
|
16
|
+
const noop = ()=>{};
|
|
17
|
+
const getChunkSize = (chunk, enc)=>chunk ? Buffer.byteLength(chunk, enc) : 0;
|
|
18
|
+
module.exports = ({ threshold = 1024, level = {
|
|
19
|
+
brotli: 0,
|
|
20
|
+
gzip: 1
|
|
21
|
+
}, brotli = true, gzip = true, mimes = MIMES } = {})=>{
|
|
22
|
+
const brotliOpts = 'object' == typeof brotli && brotli || {};
|
|
23
|
+
const gzipOpts = 'object' == typeof gzip && gzip || {};
|
|
24
|
+
if (brotli && !zlib.createBrotliCompress) brotli = false;
|
|
25
|
+
return (req, res, next = noop)=>{
|
|
26
|
+
const accept = req.headers['accept-encoding'];
|
|
27
|
+
const encoding = accept && (brotli && accept.match(/\bbr\b/) || gzip && accept.match(/\bgzip\b/) || [])[0];
|
|
28
|
+
if ('HEAD' === req.method || !encoding) return next();
|
|
29
|
+
let compress;
|
|
30
|
+
let pendingStatus;
|
|
31
|
+
let pendingListeners = [];
|
|
32
|
+
let started = false;
|
|
33
|
+
let size = 0;
|
|
34
|
+
function start() {
|
|
35
|
+
started = true;
|
|
36
|
+
size = 0 | res.getHeader('Content-Length') || size;
|
|
37
|
+
const compressible = mimes.test(String(res.getHeader('Content-Type') || 'text/plain'));
|
|
38
|
+
const cleartext = !res.getHeader('Content-Encoding');
|
|
39
|
+
const listeners = pendingListeners || [];
|
|
40
|
+
if (compressible && cleartext && size >= threshold) {
|
|
41
|
+
res.setHeader('Content-Encoding', encoding);
|
|
42
|
+
res.removeHeader('Content-Length');
|
|
43
|
+
compress = 'br' === encoding ? zlib.createBrotliCompress({
|
|
44
|
+
params: Object.assign({
|
|
45
|
+
[zlib.constants.BROTLI_PARAM_QUALITY]: level.brotli,
|
|
46
|
+
[zlib.constants.BROTLI_PARAM_SIZE_HINT]: size
|
|
47
|
+
}, brotliOpts)
|
|
48
|
+
}) : zlib.createGzip(Object.assign({
|
|
49
|
+
level: level.gzip
|
|
50
|
+
}, gzipOpts));
|
|
51
|
+
compress.on('data', (chunk)=>false === write.call(res, chunk) && compress.pause());
|
|
52
|
+
on.call(res, 'drain', ()=>compress.resume());
|
|
53
|
+
compress.on('end', ()=>end.call(res));
|
|
54
|
+
listeners.forEach((p)=>compress.on.apply(compress, p));
|
|
55
|
+
} else {
|
|
56
|
+
pendingListeners = null;
|
|
57
|
+
listeners.forEach((p)=>on.apply(res, p));
|
|
58
|
+
}
|
|
59
|
+
writeHead.call(res, pendingStatus || res.statusCode);
|
|
60
|
+
}
|
|
61
|
+
const { end, write, on, writeHead } = res;
|
|
62
|
+
res.writeHead = function(status, reason, headers) {
|
|
63
|
+
if ('string' != typeof reason) [headers, reason] = [
|
|
64
|
+
reason,
|
|
65
|
+
headers
|
|
66
|
+
];
|
|
67
|
+
if (headers) for(const i in headers)res.setHeader(i, headers[i]);
|
|
68
|
+
pendingStatus = status;
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
res.write = function(chunk, enc) {
|
|
72
|
+
size += getChunkSize(chunk, enc);
|
|
73
|
+
if (!started) start();
|
|
74
|
+
if (!compress) return write.apply(this, arguments);
|
|
75
|
+
return compress.write.apply(compress, arguments);
|
|
76
|
+
};
|
|
77
|
+
res.end = function(chunk, enc) {
|
|
78
|
+
if (arguments.length > 0 && 'function' != typeof chunk) size += getChunkSize(chunk, enc);
|
|
79
|
+
if (!started) start();
|
|
80
|
+
if (!compress) return end.apply(this, arguments);
|
|
81
|
+
return compress.end.apply(compress, arguments);
|
|
82
|
+
};
|
|
83
|
+
res.on = function(type, listener) {
|
|
84
|
+
if (pendingListeners && 'drain' === type) if (compress) compress.on(type, listener);
|
|
85
|
+
else pendingListeners.push([
|
|
86
|
+
type,
|
|
87
|
+
listener
|
|
88
|
+
]);
|
|
89
|
+
else on.call(this, type, listener);
|
|
90
|
+
return this;
|
|
91
|
+
};
|
|
92
|
+
next();
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
zlib (module) {
|
|
97
|
+
module.exports = __rspack_external_zlib;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
11
100
|
var external_node_util_namespaceObject = {};
|
|
12
101
|
__webpack_require__.r(external_node_util_namespaceObject);
|
|
13
102
|
__webpack_require__.d(external_node_util_namespaceObject, {
|
|
@@ -127,6 +216,8 @@ class WebsocketServer extends servers_BaseServer {
|
|
|
127
216
|
});
|
|
128
217
|
}
|
|
129
218
|
}
|
|
219
|
+
const src = __webpack_require__("./node_modules/.pnpm/http-compression@1.1.2/node_modules/http-compression/src/index.js");
|
|
220
|
+
var src_default = /*#__PURE__*/ __webpack_require__.n(src);
|
|
130
221
|
const { styleText: server_styleText } = external_node_util_namespaceObject;
|
|
131
222
|
const server_require = createRequire(import.meta.url);
|
|
132
223
|
if (!process.env.WEBPACK_SERVE) process.env.WEBPACK_SERVE = 'true';
|
|
@@ -910,13 +1001,10 @@ class Server {
|
|
|
910
1001
|
next();
|
|
911
1002
|
}
|
|
912
1003
|
});
|
|
913
|
-
if (this.options.compress) {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
middleware: compression()
|
|
918
|
-
});
|
|
919
|
-
}
|
|
1004
|
+
if (this.options.compress) middlewares.push({
|
|
1005
|
+
name: 'compression',
|
|
1006
|
+
middleware: src_default()()
|
|
1007
|
+
});
|
|
920
1008
|
if (void 0 !== this.options.headers) middlewares.push({
|
|
921
1009
|
name: 'set-headers',
|
|
922
1010
|
middleware: this.setHeaders.bind(this)
|
package/dist/rslib-runtime.js
CHANGED
|
@@ -15,6 +15,15 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
15
15
|
Object.assign(__webpack_require__.m, modules);
|
|
16
16
|
};
|
|
17
17
|
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.n = (module)=>{
|
|
20
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
21
|
+
__webpack_require__.d(getter, {
|
|
22
|
+
a: getter
|
|
23
|
+
});
|
|
24
|
+
return getter;
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
18
27
|
(()=>{
|
|
19
28
|
var getProto = Object.getPrototypeOf ? (obj)=>Object.getPrototypeOf(obj) : (obj)=>obj.__proto__;
|
|
20
29
|
var leafPrototypes;
|
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.4",
|
|
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,12 +50,12 @@
|
|
|
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",
|
|
54
53
|
"connect-history-api-fallback": "^2.0.0",
|
|
54
|
+
"connect-next": "^4.0.0",
|
|
55
55
|
"http-proxy-middleware": "^3.0.5",
|
|
56
56
|
"ipaddr.js": "^2.3.0",
|
|
57
|
-
"serve-static": "^2.2.1",
|
|
58
57
|
"serve-index": "^1.9.2",
|
|
58
|
+
"serve-static": "^2.2.1",
|
|
59
59
|
"webpack-dev-middleware": "^7.4.5",
|
|
60
60
|
"ws": "^8.19.0"
|
|
61
61
|
},
|
|
@@ -66,17 +66,16 @@
|
|
|
66
66
|
"@rspack/core": "2.0.0-beta.5",
|
|
67
67
|
"@rspack/plugin-react-refresh": "1.6.1",
|
|
68
68
|
"@rstest/core": "^0.9.0",
|
|
69
|
-
"@types/compression": "^1.8.1",
|
|
70
69
|
"@types/mime-types": "3.0.1",
|
|
71
70
|
"@types/node": "^24.12.0",
|
|
72
71
|
"@types/node-forge": "^1.3.14",
|
|
73
72
|
"@types/trusted-types": "^2.0.7",
|
|
74
73
|
"@types/ws": "8.18.1",
|
|
75
|
-
"express": "^5.2.1",
|
|
76
|
-
"compression": "^1.8.1",
|
|
77
74
|
"cross-env": "^10.1.0",
|
|
78
75
|
"css-loader": "^7.1.4",
|
|
76
|
+
"express": "^5.2.1",
|
|
79
77
|
"hono": "^4.12.5",
|
|
78
|
+
"http-compression": "^1.1.2",
|
|
80
79
|
"http-proxy": "^1.18.1",
|
|
81
80
|
"launch-editor": "^2.13.1",
|
|
82
81
|
"nano-staged": "^0.9.0",
|