@rspack/dev-server 2.2.1 → 2.2.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 CHANGED
@@ -165,7 +165,7 @@ const reloadApp = ({ hot, liveReload }, currentStatus)=>{
165
165
  log_js_log.info('App hot update...');
166
166
  emitter.emit('webpackHotUpdate', currentStatus.currentHash);
167
167
  if ("u" > typeof self && self.window) self.postMessage(`webpackHotUpdate${currentStatus.currentHash}`, '*');
168
- } else if (liveReload && allowToLiveReload) {
168
+ } else if (liveReload && allowToLiveReload && "u" > typeof document) {
169
169
  let rootWindow = self;
170
170
  const intervalId = self.setInterval(()=>{
171
171
  if ('about:' !== rootWindow.location.protocol) applyReload(rootWindow, intervalId);
@@ -246,6 +246,7 @@ const onSocketMessage = {
246
246
  reloadApp(options, client_src_status);
247
247
  },
248
248
  'static-changed': function(file) {
249
+ if ("u" < typeof document) return;
249
250
  log_js_log.info(`${file ? `"${file}"` : 'Content'} from static directory was changed. Reloading...`);
250
251
  self.location.reload();
251
252
  },
@@ -326,20 +327,21 @@ const formatURL = (objURL)=>{
326
327
  return `${protocol}${host}${pathname}${search}${hash}`;
327
328
  };
328
329
  const createSocketURL = (parsedURL)=>{
330
+ const pageLocation = 'blob:' === self.location.protocol && self.location.origin && 'null' !== self.location.origin ? new URL(self.location.origin) : self.location;
329
331
  let { hostname } = parsedURL;
330
332
  const isInAddrAny = '0.0.0.0' === hostname || '::' === hostname || '[::]' === hostname;
331
- if (isInAddrAny && self.location.hostname && 0 === self.location.protocol.indexOf('http')) hostname = self.location.hostname;
332
- let socketURLProtocol = parsedURL.protocol || self.location.protocol;
333
- if ('auto:' === socketURLProtocol || hostname && isInAddrAny && 'https:' === self.location.protocol) socketURLProtocol = self.location.protocol;
333
+ if (isInAddrAny && pageLocation.hostname && 0 === pageLocation.protocol.indexOf('http')) hostname = pageLocation.hostname;
334
+ let socketURLProtocol = parsedURL.protocol || pageLocation.protocol;
335
+ if ('auto:' === socketURLProtocol || hostname && isInAddrAny && 'https:' === pageLocation.protocol) socketURLProtocol = pageLocation.protocol;
334
336
  socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, 'ws');
335
337
  let socketURLAuth = '';
336
338
  if (parsedURL.username) {
337
339
  socketURLAuth = parsedURL.username;
338
340
  if (parsedURL.password) socketURLAuth = socketURLAuth.concat(':', parsedURL.password);
339
341
  }
340
- const socketURLHostname = (hostname || self.location.hostname || 'localhost').replace(/^\[(.*)\]$/, '$1');
342
+ const socketURLHostname = (hostname || pageLocation.hostname || 'localhost').replace(/^\[(.*)\]$/, '$1');
341
343
  let socketURLPort = parsedURL.port;
342
- if (!socketURLPort || '0' === socketURLPort) socketURLPort = self.location.port;
344
+ if (!socketURLPort || '0' === socketURLPort) socketURLPort = pageLocation.port;
343
345
  let socketURLPathname = '/ws';
344
346
  if (parsedURL.pathname && !parsedURL.fromCurrentScript) socketURLPathname = parsedURL.pathname;
345
347
  return formatURL({
@@ -1,5 +1,5 @@
1
- /*! LICENSE: 0~chokidar.js.LICENSE.txt */
2
- import { __webpack_require__ } from "./619.js";
1
+ /*! LICENSE: chokidar~0.js.LICENSE.txt */
2
+ import { __webpack_require__ } from "./t~0.js";
3
3
  import { EventEmitter } from "node:events";
4
4
  import { stat as external_node_fs_stat, unwatchFile, watch, watchFile } from "node:fs";
5
5
  import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "node:fs/promises";
@@ -965,7 +965,7 @@ const toUnix = (string)=>{
965
965
  const normalizePathToUnix = (path)=>toUnix(__rspack_external_node_path_806ed179.normalize(toUnix(path)));
966
966
  const normalizeIgnored = (cwd = '')=>(path)=>{
967
967
  if ('string' == typeof path) return normalizePathToUnix(__rspack_external_node_path_806ed179.isAbsolute(path) ? path : __rspack_external_node_path_806ed179.join(cwd, path));
968
- return path;
968
+ else return path;
969
969
  };
970
970
  const getAbsolutePath = (path, cwd)=>{
971
971
  if (__rspack_external_node_path_806ed179.isAbsolute(path)) return path;
@@ -1,8 +1,9 @@
1
- import { __webpack_require__ } from "./619.js";
2
- import "./619.js";
1
+ import { __webpack_require__ } from "./t~0.js";
2
+ import { createRequire as __rspack_createRequire } from "node:module";
3
+ const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
3
4
  __webpack_require__.add({
4
- "./node_modules/.pnpm/connect-history-api-fallback@2.0.0/node_modules/connect-history-api-fallback/lib/index.js" (module, exports, __webpack_require__) {
5
- var url = __webpack_require__("url?b918");
5
+ "./node_modules/.pnpm/connect-history-api-fallback@2.0.0/node_modules/connect-history-api-fallback/lib/index.js" (module, exports) {
6
+ var url = __rspack_createRequire_require("url");
6
7
  module.exports = function(options) {
7
8
  options = options || {};
8
9
  var logger = getLogger(options);
@@ -11,8 +12,7 @@ __webpack_require__.add({
11
12
  if ('GET' !== req.method && 'HEAD' !== req.method) {
12
13
  logger('Not rewriting', req.method, req.url, 'because the method is not GET or HEAD.');
13
14
  return next();
14
- }
15
- if (headers && 'string' == typeof headers.accept) {
15
+ } else if (headers && 'string' == typeof headers.accept) {
16
16
  if (0 === headers.accept.indexOf('application/json')) {
17
17
  logger('Not rewriting', req.method, req.url, 'because the client prefers JSON.');
18
18
  return next();
@@ -51,7 +51,7 @@ __webpack_require__.add({
51
51
  };
52
52
  function evaluateRewriteRule(parsedUrl, match, rule, req) {
53
53
  if ('string' == typeof rule) return rule;
54
- if ('function' != typeof rule) throw new Error('Rewrite rule can only be of type string or function.');
54
+ else if ('function' != typeof rule) throw new Error('Rewrite rule can only be of type string or function.');
55
55
  return rule({
56
56
  parsedUrl: parsedUrl,
57
57
  match: match,
@@ -68,7 +68,7 @@ __webpack_require__.add({
68
68
  }
69
69
  function getLogger(options) {
70
70
  if (options && options.logger) return options.logger;
71
- if (options && options.verbose) return console.log.bind(console);
71
+ else if (options && options.verbose) return console.log.bind(console);
72
72
  return function() {};
73
73
  }
74
74
  }
@@ -1,4 +1,4 @@
1
- /*! LICENSE: 0~connect-next.js.LICENSE.txt */
1
+ /*! LICENSE: connect-next~0.js.LICENSE.txt */
2
2
  import { EventEmitter } from "node:events";
3
3
  import { createRequire } from "node:module";
4
4
  import * as __rspack_external_node_http_e245b239 from "node:http";
@@ -1,5 +1,6 @@
1
- import { __webpack_require__ } from "./619.js";
2
- import "./619.js";
1
+ import { __webpack_require__ } from "./t~0.js";
2
+ import { createRequire as __rspack_createRequire } from "node:module";
3
+ const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
3
4
  __webpack_require__.add({
4
5
  "./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js" (module, exports, __webpack_require__) {
5
6
  exports.formatArgs = formatArgs;
@@ -291,8 +292,8 @@ __webpack_require__.add({
291
292
  else module.exports = __webpack_require__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js");
292
293
  },
293
294
  "./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js" (module, exports, __webpack_require__) {
294
- const tty = __webpack_require__("tty");
295
- const util = __webpack_require__("util");
295
+ const tty = __rspack_createRequire_require("tty");
296
+ const util = __rspack_createRequire_require("util");
296
297
  exports.init = init;
297
298
  exports.log = log;
298
299
  exports.formatArgs = formatArgs;
@@ -458,7 +459,7 @@ __webpack_require__.add({
458
459
  options = options || {};
459
460
  var type = typeof val;
460
461
  if ('string' === type && val.length > 0) return parse(val);
461
- if ('number' === type && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
462
+ else if ('number' === type && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
462
463
  throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
463
464
  };
464
465
  function parse(str) {
@@ -533,8 +534,8 @@ __webpack_require__.add({
533
534
  }
534
535
  },
535
536
  "./node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js" (module, __unused_rspack_exports, __webpack_require__) {
536
- const os = __webpack_require__("os");
537
- const tty = __webpack_require__("tty");
537
+ const os = __rspack_createRequire_require("os");
538
+ const tty = __rspack_createRequire_require("tty");
538
539
  const hasFlag = __webpack_require__("./node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
539
540
  const { env } = process;
540
541
  let flagForceColor;
@@ -1,4 +1,4 @@
1
- /*! LICENSE: 0~http-proxy-middleware.js.LICENSE.txt */
1
+ /*! LICENSE: http-proxy-middleware~0.js.LICENSE.txt */
2
2
  import node_http from "node:http";
3
3
  import node_https from "node:https";
4
4
  import node_http2 from "node:http2";
@@ -6,13 +6,13 @@ import { EventEmitter } from "node:events";
6
6
  import "node:net";
7
7
  import "node:stream";
8
8
  import { styleText } from "node:util";
9
- import { URL as external_node_url_URL } from "node:url";
10
9
  import { URL as external_url_URL } from "url";
11
10
  import "node:zlib";
12
11
  import "node:querystring";
13
- import { __webpack_require__ } from "./619.js";
14
- import "./0~debug.js";
15
- import "./619.js";
12
+ import { __webpack_require__ } from "./t~0.js";
13
+ import "./debug~0.js";
14
+ import { createRequire as __rspack_createRequire } from "node:module";
15
+ const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
16
16
  __webpack_require__.add({
17
17
  "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js" (module, __unused_rspack_exports, __webpack_require__) {
18
18
  const stringify = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
@@ -560,7 +560,7 @@ __webpack_require__.add({
560
560
  *
561
561
  * Copyright (c) 2014-present, Jon Schlinkert.
562
562
  * Licensed under the MIT License.
563
- */ const util = __webpack_require__("util");
563
+ */ const util = __rspack_createRequire_require("util");
564
564
  const toRegexRange = __webpack_require__("./node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js");
565
565
  const isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
566
566
  const transform = (toNumber)=>(value)=>true === toNumber ? Number(value) : String(value);
@@ -848,7 +848,7 @@ __webpack_require__.add({
848
848
  };
849
849
  },
850
850
  "./node_modules/.pnpm/micromatch@4.0.8/node_modules/micromatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
851
- const util = __webpack_require__("util");
851
+ const util = __rspack_createRequire_require("util");
852
852
  const braces = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js");
853
853
  const picomatch = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js");
854
854
  const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
@@ -993,8 +993,8 @@ __webpack_require__.add({
993
993
  "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
994
994
  module.exports = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js");
995
995
  },
996
- "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js" (module, __unused_rspack_exports, __webpack_require__) {
997
- const path = __webpack_require__("path");
996
+ "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js" (module) {
997
+ const path = __rspack_createRequire_require("path");
998
998
  const WIN_SLASH = '\\\\/';
999
999
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1000
1000
  const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
@@ -2157,7 +2157,7 @@ __webpack_require__.add({
2157
2157
  module.exports = parse;
2158
2158
  },
2159
2159
  "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
2160
- const path = __webpack_require__("path");
2160
+ const path = __rspack_createRequire_require("path");
2161
2161
  const scan = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/scan.js");
2162
2162
  const parse = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/parse.js");
2163
2163
  const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
@@ -2559,7 +2559,7 @@ __webpack_require__.add({
2559
2559
  module.exports = scan;
2560
2560
  },
2561
2561
  "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
2562
- const path = __webpack_require__("path");
2562
+ const path = __rspack_createRequire_require("path");
2563
2563
  const win32 = 'win32' === process.platform;
2564
2564
  const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
2565
2565
  exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
@@ -3513,7 +3513,14 @@ function createUrl({ protocol, host, port, path }) {
3513
3513
  const base = `${protocol || 'undefined:'}//${ipv6Host || '[::]'}`;
3514
3514
  const url = new external_url_URL(base);
3515
3515
  if (port) url.port = port;
3516
- if (path) url.pathname = path;
3516
+ if (path) {
3517
+ const queryIndex = path.indexOf('?');
3518
+ if (-1 === queryIndex) url.pathname = path;
3519
+ else {
3520
+ url.pathname = path.slice(0, queryIndex);
3521
+ url.search = path.slice(queryIndex);
3522
+ }
3523
+ }
3517
3524
  return url;
3518
3525
  }
3519
3526
  function logger_plugin_getPort(sockets) {
@@ -3541,14 +3548,12 @@ const loggerPlugin = definePlugin((proxyServer, options)=>{
3541
3548
  port,
3542
3549
  path
3543
3550
  });
3551
+ const targetUrl = target.toString();
3552
+ const exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
3553
+ logger.info(exchange);
3544
3554
  } catch (err) {
3545
3555
  console.error('[HPM] Unexpected error while creating target URL', err);
3546
- target = new external_node_url_URL(options.target);
3547
- target.pathname = proxyRes.req.path;
3548
3556
  }
3549
- const targetUrl = target.toString();
3550
- const exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
3551
- logger.info(exchange);
3552
3557
  });
3553
3558
  proxyServer.on('open', (socket)=>{
3554
3559
  logger.info('[HPM] Client connected: %o', socket.address());
@@ -3646,9 +3651,10 @@ function createPathRewriter(rewriteConfig) {
3646
3651
  if ('function' == typeof rewriteConfig) {
3647
3652
  const customRewriteFn = rewriteConfig;
3648
3653
  return customRewriteFn;
3654
+ } else {
3655
+ rulesCache = parsePathRewriteRules(rewriteConfig);
3656
+ return rewritePath;
3649
3657
  }
3650
- rulesCache = parsePathRewriteRules(rewriteConfig);
3651
- return rewritePath;
3652
3658
  function rewritePath(path) {
3653
3659
  let result = path;
3654
3660
  for (const rule of rulesCache)if (rule.regex.test(path)) {
@@ -3661,9 +3667,9 @@ function createPathRewriter(rewriteConfig) {
3661
3667
  }
3662
3668
  function isValidRewriteConfig(rewriteConfig) {
3663
3669
  if ('function' == typeof rewriteConfig) return true;
3664
- if (isPlainObject(rewriteConfig)) return 0 !== Object.keys(rewriteConfig).length;
3665
- if (null == rewriteConfig) return false;
3666
- throw new errors_HttpProxyMiddlewareError('[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function', 'HPM_INVALID_PATH_REWRITER_CONFIG');
3670
+ else if (isPlainObject(rewriteConfig)) return 0 !== Object.keys(rewriteConfig).length;
3671
+ else if (null == rewriteConfig) return false;
3672
+ else throw new errors_HttpProxyMiddlewareError('[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function', 'HPM_INVALID_PATH_REWRITER_CONFIG');
3667
3673
  }
3668
3674
  function parsePathRewriteRules(rewriteConfig) {
3669
3675
  const rules = [];
@@ -3809,8 +3815,10 @@ class HttpProxyMiddleware {
3809
3815
  Debug('server close signal received.');
3810
3816
  this.activeServers.delete(server);
3811
3817
  if (this.activeServers.size > 0) return void Debug(`proxy server not closed: ${this.activeServers.size} server(s) still active`);
3812
- Debug('closing proxy server');
3813
- this.proxy.close(()=>Debug('proxy server closed'));
3818
+ else {
3819
+ Debug('closing proxy server');
3820
+ this.proxy.close(()=>Debug('proxy server closed'));
3821
+ }
3814
3822
  });
3815
3823
  }
3816
3824
  if (true === this.proxyOptions.ws && server) this.catchUpgradeRequest(server);
package/dist/index.d.ts CHANGED
@@ -895,6 +895,8 @@ declare namespace WebSocket_2 {
895
895
  allowSynchronousEvents?: boolean | undefined;
896
896
  autoPong?: boolean | undefined;
897
897
  maxPayload?: number | undefined;
898
+ maxBufferedChunks?: number | undefined;
899
+ maxFragments?: number | undefined;
898
900
  skipUTF8Validation?: boolean | undefined;
899
901
  createConnection?: typeof createConnection | undefined;
900
902
  finishRequest?: FinishRequestCallback | undefined;
@@ -980,6 +982,8 @@ declare namespace WebSocket_2 {
980
982
  clientTracking?: boolean | undefined;
981
983
  perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
982
984
  maxPayload?: number | undefined;
985
+ maxBufferedChunks?: number | undefined;
986
+ maxFragments?: number | undefined;
983
987
  skipUTF8Validation?: boolean | undefined;
984
988
  WebSocket?: U | undefined;
985
989
  }
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { RspackDevServer } from "./619.js";
1
+ export { RspackDevServer } from "./t~0.js";