@rsbuild/core 2.0.0-rc.0 → 2.0.0-rc.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 (58) hide show
  1. package/compiled/connect-next/package.json +1 -1
  2. package/compiled/css-loader/index.js +2 -2
  3. package/compiled/html-rspack-plugin/index.js +14 -14
  4. package/compiled/http-proxy-middleware/index.d.ts +180 -386
  5. package/compiled/http-proxy-middleware/package.json +1 -1
  6. package/compiled/postcss/index.js +1 -1
  7. package/compiled/postcss/lib/at-rule.d.ts +0 -1
  8. package/compiled/postcss/lib/comment.d.ts +0 -1
  9. package/compiled/postcss/lib/container.d.ts +1 -6
  10. package/compiled/postcss/lib/css-syntax-error.d.ts +0 -1
  11. package/compiled/postcss/lib/declaration.d.ts +0 -1
  12. package/compiled/postcss/lib/document.d.ts +0 -1
  13. package/compiled/postcss/lib/fromJSON.d.ts +1 -1
  14. package/compiled/postcss/lib/input.d.ts +0 -1
  15. package/compiled/postcss/lib/lazy-result.d.ts +3 -4
  16. package/compiled/postcss/lib/list.d.ts +1 -1
  17. package/compiled/postcss/lib/no-work-result.d.ts +0 -1
  18. package/compiled/postcss/lib/node.d.ts +0 -1
  19. package/compiled/postcss/lib/parse.d.ts +1 -1
  20. package/compiled/postcss/lib/postcss.d.ts +1 -3
  21. package/compiled/postcss/lib/previous-map.d.ts +0 -1
  22. package/compiled/postcss/lib/processor.d.ts +0 -1
  23. package/compiled/postcss/lib/result.d.ts +0 -1
  24. package/compiled/postcss/lib/root.d.ts +0 -1
  25. package/compiled/postcss/lib/rule.d.ts +12 -12
  26. package/compiled/postcss/lib/stringifier.d.ts +0 -1
  27. package/compiled/postcss/lib/stringify.d.ts +1 -1
  28. package/compiled/postcss/lib/warning.d.ts +0 -1
  29. package/compiled/postcss/license +1 -1
  30. package/compiled/postcss/package.json +1 -1
  31. package/compiled/postcss-loader/index.js +6 -6
  32. package/compiled/rspack-chain/package.json +1 -1
  33. package/compiled/rspack-chain/types/index.d.ts +38 -115
  34. package/dist/1~rslib-runtime.js +1 -1
  35. package/dist/{552.js → 753.js} +143 -196
  36. package/dist/client/hmr.js +23 -10
  37. package/dist/connect-next.js +636 -26
  38. package/dist/connect-next.js.LICENSE.txt +14 -1
  39. package/dist/http-proxy-middleware.js +1169 -1226
  40. package/dist/http-proxy-middleware.js.LICENSE.txt +0 -35
  41. package/dist/index.js +1 -1
  42. package/dist/launch-editor-middleware.js +6 -6
  43. package/dist/manifest-plugin.js +8 -8
  44. package/dist/memfs.js +16 -56
  45. package/dist/tinyglobby.js +279 -127
  46. package/dist/ws.js +2 -2
  47. package/dist-types/client/hmr.d.ts +1 -1
  48. package/dist-types/helpers/index.d.ts +1 -1
  49. package/dist-types/helpers/url.d.ts +1 -1
  50. package/dist-types/pluginHelper.d.ts +1 -8
  51. package/dist-types/server/devServer.d.ts +9 -7
  52. package/dist-types/server/socketServer.d.ts +16 -4
  53. package/dist-types/types/config.d.ts +9 -3
  54. package/dist-types/types/rspack.d.ts +1 -1
  55. package/package.json +11 -11
  56. package/dist/debug.js +0 -503
  57. package/dist-types/plugins/esm.d.ts +0 -2
  58. /package/dist/{552.js.LICENSE.txt → 753.js.LICENSE.txt} +0 -0
@@ -25,18 +25,19 @@ const registerOverlay = (createFn, clearFn)=>{
25
25
  createOverlay = createFn;
26
26
  clearOverlay = clearFn;
27
27
  };
28
- function init(token, config, serverHost, serverPort, liveReload, browserLogs, logLevel) {
28
+ function init(token, config, serverHost, serverPort, serverBase, liveReload, browserLogs, logLevel) {
29
29
  logger.level = logLevel;
30
30
  const queuedMessages = [];
31
31
  const clientErrors = [];
32
32
  const customListenersMap = new Map();
33
33
  let lastHash;
34
34
  let hasBuildErrors = false;
35
+ const base = serverBase.endsWith('/') ? serverBase : `${serverBase}/`;
35
36
  function formatURL(fallback) {
36
- const { location } = self;
37
- const hostname = (fallback ? serverHost : config.host) || location.hostname;
38
- const port = (fallback ? serverPort : config.port) || location.port;
39
- const protocol = config.protocol || ('https:' === location.protocol ? 'wss' : 'ws');
37
+ const { location: location1 } = self;
38
+ const hostname = (fallback ? serverHost : config.host) || location1.hostname;
39
+ const port = (fallback ? serverPort : config.port) || location1.port;
40
+ const protocol = config.protocol || ('https:' === location1.protocol ? 'wss' : 'ws');
40
41
  const pathname = config.path;
41
42
  if ("u" > typeof URL) {
42
43
  const url = new URL('http://localhost');
@@ -85,7 +86,7 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
85
86
  const forcedReload = err || !updatedModules;
86
87
  if (forcedReload) {
87
88
  if (err) logger.error('[rsbuild] HMR update failed, performing full reload:', err);
88
- reloadPage();
89
+ fullReload();
89
90
  return;
90
91
  }
91
92
  tryApplyUpdates();
@@ -101,7 +102,7 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
101
102
  });
102
103
  return;
103
104
  }
104
- reloadPage();
105
+ fullReload();
105
106
  }
106
107
  let socket = null;
107
108
  let reconnectCount = 0;
@@ -133,8 +134,11 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
133
134
  case 'ok':
134
135
  handleSuccess();
135
136
  break;
137
+ case 'full-reload':
138
+ fullReload(message.data);
139
+ break;
136
140
  case 'static-changed':
137
- reloadPage();
141
+ fullReload();
138
142
  break;
139
143
  case 'warnings':
140
144
  handleWarnings(message.data);
@@ -223,8 +227,17 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
223
227
  socket.removeEventListener('error', onSocketError);
224
228
  }
225
229
  }
226
- function reloadPage() {
227
- if (liveReload) window.location.reload();
230
+ function fullReload(data) {
231
+ if (!liveReload) return;
232
+ const path = null == data ? void 0 : data.path;
233
+ if (null == path ? void 0 : path.endsWith('.html')) {
234
+ const pathname = decodeURI(location.pathname);
235
+ const targetPath = base + path.slice(1);
236
+ const targetPathWithoutExt = targetPath.slice(0, -5);
237
+ if (pathname === targetPath || pathname === targetPathWithoutExt || pathname.endsWith('/') && `${pathname}index.html` === targetPath) location.reload();
238
+ return;
239
+ }
240
+ location.reload();
228
241
  }
229
242
  if (browserLogs && "u" > typeof window) {
230
243
  window.addEventListener('error', ({ message, error })=>{