@rsbuild/core 1.4.2 → 1.4.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.
@@ -298,6 +298,28 @@ export type PublicDirOptions = {
298
298
  watch?: boolean;
299
299
  };
300
300
  export type PublicDir = false | PublicDirOptions | PublicDirOptions[];
301
+ /**
302
+ * The options for `server.compress`.
303
+ */
304
+ export type CompressOptions = {
305
+ /**
306
+ * A function that determines whether a response should be compressed.
307
+ * @param req - The incoming HTTP request
308
+ * @param res - The outgoing HTTP response
309
+ * @returns `true` to compress the response, `false` to skip compression
310
+ */
311
+ filter?: (req: IncomingMessage, res: ServerResponse) => boolean;
312
+ /**
313
+ * The level of zlib compression to apply to responses.
314
+ * A higher level will result in better compression, but will take longer to complete.
315
+ * A lower level will result in less compression, but will be much faster.
316
+ * This is an integer in the range of 0 (no compression) to 9 (maximum compression).
317
+ * @default
318
+ * - 1 (fastest) for dev server (also known as `zlib.constants.Z_BEST_SPEED`)
319
+ * - 6 for preview server (also known as `zlib.constants.Z_DEFAULT_COMPRESSION`)
320
+ */
321
+ level?: number;
322
+ };
301
323
  export interface ServerConfig {
302
324
  /**
303
325
  * Configure the base path of the server.
@@ -306,9 +328,10 @@ export interface ServerConfig {
306
328
  base?: string;
307
329
  /**
308
330
  * Whether to enable gzip compression for served static assets.
331
+ * Pass an object to customize the compression behavior.
309
332
  * @default true
310
333
  */
311
- compress?: boolean;
334
+ compress?: boolean | CompressOptions;
312
335
  /**
313
336
  * Serving static files from the directory (by default 'public' directory)
314
337
  */
@@ -157,6 +157,12 @@ export type EnvironmentContext = {
157
157
  * `onDevCompileDone` and `onAfterEnvironmentCompile` or via the environment API
158
158
  */
159
159
  manifest?: Record<string, unknown> | ManifestData;
160
+ /**
161
+ * WebSocket authentication token, used to authenticate WebSocket connections and
162
+ * prevent unauthorized access. Only available in the development mode, and is
163
+ * an empty string in the production mode.
164
+ */
165
+ webSocketToken: string;
160
166
  };
161
167
  export type ModifyChainUtils = {
162
168
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -46,17 +46,17 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.4.1",
49
+ "@rspack/core": "1.4.2",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.17",
52
52
  "core-js": "~3.43.0",
53
53
  "jiti": "^2.4.2"
54
54
  },
55
55
  "devDependencies": {
56
- "@rslib/core": "0.10.3",
56
+ "@rslib/core": "0.10.4",
57
57
  "@types/connect": "3.4.38",
58
58
  "@types/cors": "^2.8.19",
59
- "@types/node": "^22.15.33",
59
+ "@types/node": "^22.16.0",
60
60
  "@types/on-finished": "2.3.5",
61
61
  "@types/webpack-bundle-analyzer": "4.7.0",
62
62
  "@types/ws": "^8.18.1",
@@ -82,7 +82,7 @@
82
82
  "prebundle": "1.3.4",
83
83
  "reduce-configs": "^1.1.0",
84
84
  "rsbuild-dev-middleware": "0.3.0",
85
- "rslog": "^1.2.8",
85
+ "rslog": "^1.2.9",
86
86
  "rspack-chain": "^1.2.6",
87
87
  "rspack-manifest-plugin": "5.0.3",
88
88
  "sirv": "^3.0.1",
@@ -92,7 +92,7 @@
92
92
  "webpack": "^5.99.9",
93
93
  "webpack-bundle-analyzer": "^4.10.2",
94
94
  "webpack-merge": "6.0.1",
95
- "ws": "^8.18.2"
95
+ "ws": "^8.18.3"
96
96
  },
97
97
  "engines": {
98
98
  "node": ">=16.10.0"
package/types.d.ts CHANGED
@@ -233,6 +233,9 @@ declare module '*?url' {
233
233
  * @example
234
234
  * import logo from './logo.svg?inline'
235
235
  * console.log(logo) // 'data:image/svg+xml;base64,...'
236
+ *
237
+ * import inlineCss from './style.css?inline';
238
+ * console.log(inlineCss); // Compiled CSS content
236
239
  */
237
240
  declare module '*?inline' {
238
241
  const content: string;
@@ -241,10 +244,17 @@ declare module '*?inline' {
241
244
 
242
245
  /**
243
246
  * Imports the raw content of the file as a string.
244
- * @note Only works for static assets and CSS files by default.
247
+ * @note Only works for static assets, CSS files, and scripts
248
+ * (JS, TS, JSX, TSX) by default.
245
249
  * @example
246
250
  * import raw from './logo.svg?raw'
247
251
  * console.log(raw) // '<svg viewBox="0 0 24 24">...</svg>'
252
+ *
253
+ * import rawJs from './script.js?raw'
254
+ * console.log(rawJs) // 'console.log("Hello world");'
255
+ *
256
+ * import rawCss from './style.css?raw'
257
+ * console.log(rawCss) // 'body { background: red; }'
248
258
  */
249
259
  declare module '*?raw' {
250
260
  const content: string;