@rsbuild/core 2.0.7 → 2.0.9

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 (91) hide show
  1. package/compiled/css-loader/index.js +2 -2
  2. package/compiled/html-rspack-plugin/index.js +14 -14
  3. package/compiled/postcss/index.js +1 -1
  4. package/compiled/postcss/package.json +1 -1
  5. package/compiled/postcss-loader/index.js +6 -6
  6. package/dist/1~rslib-runtime.js +8 -5
  7. package/dist/{753.js → 756.js} +157 -128
  8. package/dist/client/hmr.js +1 -1
  9. package/dist/client/overlay.js +1 -1
  10. package/dist/http-proxy-middleware.js +2 -5
  11. package/dist/index.js +1 -1
  12. package/dist/launch-editor-middleware.js +1 -1
  13. package/dist/manifest-plugin.js +7 -7
  14. package/dist/memfs.js +5 -5
  15. package/dist/ws.js +45 -31
  16. package/dist-types/build.d.ts +1 -1
  17. package/dist-types/cli/init.d.ts +1 -1
  18. package/dist-types/configChain.d.ts +59 -118
  19. package/dist-types/constants.d.ts +35 -31
  20. package/dist-types/createContext.d.ts +1 -2
  21. package/dist-types/createRsbuild.d.ts +1 -2
  22. package/dist-types/defaultConfig.d.ts +2 -4
  23. package/dist-types/helpers/exitHook.d.ts +1 -1
  24. package/dist-types/helpers/format.d.ts +2 -1
  25. package/dist-types/helpers/fs.d.ts +2 -4
  26. package/dist-types/helpers/index.d.ts +1 -2
  27. package/dist-types/helpers/packageJson.d.ts +1 -1
  28. package/dist-types/helpers/path.d.ts +4 -8
  29. package/dist-types/helpers/stats.d.ts +3 -5
  30. package/dist-types/helpers/url.d.ts +1 -0
  31. package/dist-types/helpers/vendors.d.ts +2 -3
  32. package/dist-types/helpers/version.d.ts +2 -3
  33. package/dist-types/hooks.d.ts +6 -8
  34. package/dist-types/index.d.ts +10 -5
  35. package/dist-types/initConfigs.d.ts +2 -3
  36. package/dist-types/initPlugins.d.ts +1 -1
  37. package/dist-types/inspectConfig.d.ts +1 -1
  38. package/dist-types/loadConfig.d.ts +24 -32
  39. package/dist-types/loadEnv.d.ts +48 -57
  40. package/dist-types/loader/transformRawLoader.d.ts +1 -0
  41. package/dist-types/logger.d.ts +1 -2
  42. package/dist-types/mergeConfig.d.ts +1 -2
  43. package/dist-types/pluginHelper.d.ts +1 -2
  44. package/dist-types/pluginManager.d.ts +4 -7
  45. package/dist-types/plugins/basic.d.ts +1 -2
  46. package/dist-types/plugins/css.d.ts +5 -1
  47. package/dist-types/plugins/externals.d.ts +1 -1
  48. package/dist-types/plugins/fileSize.d.ts +6 -5
  49. package/dist-types/plugins/rspackProfile.d.ts +2 -0
  50. package/dist-types/plugins/server.d.ts +1 -0
  51. package/dist-types/plugins/swc.d.ts +1 -2
  52. package/dist-types/restart.d.ts +4 -5
  53. package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +2 -3
  54. package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +2 -3
  55. package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +3 -4
  56. package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +1 -2
  57. package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +2 -3
  58. package/dist-types/rspackConfig.d.ts +1 -1
  59. package/dist-types/server/ansiHTML.d.ts +1 -2
  60. package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +1 -2
  61. package/dist-types/server/assets-middleware/index.d.ts +3 -5
  62. package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +1 -2
  63. package/dist-types/server/browserLogs.d.ts +1 -2
  64. package/dist-types/server/buildManager.d.ts +4 -6
  65. package/dist-types/server/cliShortcuts.d.ts +3 -1
  66. package/dist-types/server/devMiddlewares.d.ts +2 -3
  67. package/dist-types/server/devServer.d.ts +18 -23
  68. package/dist-types/server/gracefulShutdown.d.ts +2 -4
  69. package/dist-types/server/gzipMiddleware.d.ts +1 -1
  70. package/dist-types/server/helper.d.ts +39 -47
  71. package/dist-types/server/historyApiFallback.d.ts +8 -1
  72. package/dist-types/server/httpServer.d.ts +1 -1
  73. package/dist-types/server/middlewares.d.ts +4 -8
  74. package/dist-types/server/open.d.ts +1 -1
  75. package/dist-types/server/runner/basic.d.ts +4 -5
  76. package/dist-types/server/runner/index.d.ts +3 -1
  77. package/dist-types/server/socketServer.d.ts +24 -18
  78. package/dist-types/server/watchFiles.d.ts +1 -1
  79. package/dist-types/types/config.d.ts +1197 -1457
  80. package/dist-types/types/context.d.ts +63 -92
  81. package/dist-types/types/hooks.d.ts +106 -150
  82. package/dist-types/types/plugin.d.ts +359 -444
  83. package/dist-types/types/rsbuild.d.ts +156 -191
  84. package/dist-types/types/thirdParty.d.ts +101 -132
  85. package/dist-types/types/utils.d.ts +2 -5
  86. package/package.json +10 -10
  87. package/dist-types/client/hmr.d.ts +0 -3
  88. package/dist-types/client/log.d.ts +0 -13
  89. package/dist-types/client/overlay.d.ts +0 -1
  90. /package/dist/{753.js.LICENSE.txt → 756.js.LICENSE.txt} +0 -0
  91. /package/dist/client/{797.js → 60.js} +0 -0
@@ -5,12 +5,11 @@ export type ServerMessageFullReload = {
5
5
  type: 'full-reload';
6
6
  data?: {
7
7
  /**
8
- * If `path` ends with `.html`, only the matching page will reload.
9
- * The HTML path should be relative to the dev server root and should not
10
- * include `server.base`. Use `'*'` to reload all pages.
11
- * @example `/foo.html`
12
- */
13
- path?: string;
8
+ * If `path` ends with `.html`, only the matching page will reload.
9
+ * The HTML path should be relative to the dev server root and should not
10
+ * include `server.base`. Use `'*'` to reload all pages.
11
+ * @example `/foo.html`
12
+ */ path?: string;
14
13
  };
15
14
  };
16
15
  export type ServerMessageStaticChanged = {
@@ -73,32 +72,39 @@ export declare class SocketServer {
73
72
  private reportedBrowserLogs;
74
73
  private currentHash;
75
74
  constructor(context: InternalContext, options: DevConfig, getOutputFileSystem: () => Rspack.OutputFileSystem);
75
+ // subscribe upgrade event to handle socket
76
76
  upgrade: (req: IncomingMessage, socket: Socket, head: Buffer) => void;
77
+ // detect and close broken connections
78
+ // https://github.com/websockets/ws/blob/8.18.0/README.md#how-to-detect-and-close-broken-connections
77
79
  private checkSockets;
78
80
  private clearHeartbeatTimer;
81
+ // create socket, install socket handler, bind socket event
79
82
  prepare(): Promise<void>;
80
83
  onBuildDone(): void;
81
84
  /**
82
- * Send error messages to the client.
83
- */
84
- sendError(errors: Rspack.StatsError[], token: string): void;
85
+ * Send error messages to the client.
86
+ */ sendError(errors: Rspack.StatsError[], token: string): void;
85
87
  /**
86
- * Send warning messages to the client
87
- */
88
- sendWarning(warnings: Rspack.StatsError[], token: string): void;
88
+ * Send warning messages to the client
89
+ */ sendWarning(warnings: Rspack.StatsError[], token: string): void;
89
90
  /**
90
- * Send a server message to matching client sockets.
91
- * @param message - The message to send
92
- * @param token - The token of the socket to send the message to,
93
- * if not provided, the message will be sent to all sockets
94
- */
95
- sendMessage(message: ServerMessage, token?: string): void;
91
+ * Send a server message to matching client sockets.
92
+ * @param message - The message to send
93
+ * @param token - The token of the socket to send the message to,
94
+ * if not provided, the message will be sent to all sockets
95
+ */ sendMessage(message: ServerMessage, token?: string): void;
96
96
  close(): Promise<void>;
97
97
  private onConnect;
98
98
  private getEnvironmentByToken;
99
99
  private getInitialChunks;
100
+ // Cache initial chunks for environments that have no baseline yet.
101
+ // This keeps comparison stable even when no client socket is connected
102
+ // during the first completed build.
100
103
  private ensureInitialChunks;
104
+ // Only use stats when environment is matched
101
105
  private getStats;
106
+ // determine what message should send by stats
102
107
  private sendStats;
108
+ // send a serialized message to a specific socket
103
109
  private sendRawMessage;
104
110
  }
@@ -11,4 +11,4 @@ export type WatchFilesResult = {
11
11
  };
12
12
  export declare function setupWatchFiles(options: WatchFilesOptions): Promise<WatchFilesResult | undefined>;
13
13
  export declare function createChokidar(pathOrGlobs: string[], root: string, options: ChokidarOptions): Promise<FSWatcher>;
14
- export {};
14
+ export { };