@rsbuild/core 1.2.11 → 1.2.13

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 (40) hide show
  1. package/compiled/chokidar/index.d.ts +61 -23
  2. package/compiled/chokidar/index.js +71 -56
  3. package/compiled/css-loader/index.js +309 -195
  4. package/compiled/html-rspack-plugin/index.js +14 -14
  5. package/compiled/http-proxy-middleware/index.d.ts +1 -1
  6. package/compiled/launch-editor-middleware/index.js +9 -6
  7. package/compiled/mrmime/index.js +4 -0
  8. package/compiled/mrmime/package.json +1 -1
  9. package/compiled/postcss/index.js +194 -194
  10. package/compiled/postcss/package.json +1 -1
  11. package/compiled/postcss-load-config/index.js +11 -11
  12. package/compiled/postcss-loader/index.js +9 -9
  13. package/compiled/rsbuild-dev-middleware/index.js +56 -46
  14. package/compiled/rsbuild-dev-middleware/package.json +1 -1
  15. package/compiled/rspack-manifest-plugin/index.js +4 -4
  16. package/compiled/sirv/index.js +8 -4
  17. package/compiled/sirv/package.json +1 -1
  18. package/compiled/style-loader/index.js +10 -10
  19. package/compiled/tinyglobby/index.d.ts +1 -0
  20. package/compiled/tinyglobby/index.js +266 -142
  21. package/compiled/tinyglobby/package.json +1 -1
  22. package/compiled/webpack-bundle-analyzer/index.js +6 -2
  23. package/compiled/ws/index.js +50 -49
  24. package/compiled/ws/package.json +1 -1
  25. package/dist/client/hmr.js +2 -2
  26. package/dist/index.cjs +146 -93
  27. package/dist/index.js +142 -89
  28. package/dist-types/helpers/index.d.ts +4 -3
  29. package/dist-types/index.d.ts +1 -1
  30. package/dist-types/loadEnv.d.ts +16 -4
  31. package/dist-types/logger.d.ts +14 -0
  32. package/dist-types/server/devServer.d.ts +2 -1
  33. package/dist-types/server/socketServer.d.ts +4 -2
  34. package/dist-types/types/config.d.ts +79 -43
  35. package/dist-types/types/rspack.d.ts +1 -1
  36. package/package.json +12 -12
  37. package/compiled/jiti/index.d.ts +0 -1
  38. package/compiled/jiti/index.js +0 -416
  39. package/compiled/jiti/license +0 -21
  40. package/compiled/jiti/package.json +0 -1
@@ -11,7 +11,8 @@ export type RsbuildDevServer = {
11
11
  middlewares: Connect.Server;
12
12
  /**
13
13
  * The Node.js HTTP server instance.
14
- * Will be `Http2SecureServer` if `server.https` config is used.
14
+ * - Will be `Http2SecureServer` if `server.https` config is used.
15
+ * - Will be `null` if `server.middlewareMode` is enabled.
15
16
  */
16
17
  httpServer: import('node:http').Server | import('node:http2').Http2SecureServer | null;
17
18
  /**
@@ -12,14 +12,16 @@ export declare class SocketServer {
12
12
  private readonly options;
13
13
  private stats;
14
14
  private initialChunks;
15
- private timer;
15
+ private heartbeatTimer;
16
16
  constructor(options: DevConfig);
17
17
  upgrade(req: IncomingMessage, sock: Socket, head: any): void;
18
+ private checkSockets;
19
+ private clearHeartbeatTimer;
18
20
  prepare(): Promise<void>;
19
21
  updateStats(stats: Rspack.Stats): void;
20
22
  sockWrite({ type, compilationId, data }: SocketMessage): void;
21
23
  private singleWrite;
22
- close(): void;
24
+ close(): Promise<void>;
23
25
  private onConnect;
24
26
  private getStats;
25
27
  private sendStats;
@@ -115,17 +115,31 @@ export interface SourceConfig {
115
115
  */
116
116
  assetsInclude?: Rspack.RuleSetCondition;
117
117
  /**
118
- * Specify directories or modules that need additional compilation.
119
- * In order to maintain faster compilation speed, Rsbuild will not compile files under node_modules through
120
- * `babel-loader` or `ts-loader` by default, as will as the files outside the current project directory.
118
+ * Specify additional JavaScript files that need to be compiled by SWC.
119
+ * Through the `source.include` config, you can specify directories or modules
120
+ * that need to be compiled by Rsbuild. The usage of `source.include` is
121
+ * consistent with [Rule.include](https://rspack.dev/config/module#ruleinclude)
122
+ * in Rspack, which supports passing in strings or regular expressions to match
123
+ * the module path.
124
+ * @default
125
+ * [
126
+ * { and: [rootPath, { not: /[\\/]node_modules[\\/]/ }], },
127
+ * /\.(?:ts|tsx|jsx|mts|cts)$/,
128
+ * ];
121
129
  */
122
130
  include?: RuleSetCondition[];
123
131
  /**
124
132
  * Set the entry modules.
133
+ * @default
134
+ * {
135
+ * // Rsbuild also supports other suffixes by default, such as ts,
136
+ * // tsx, jsx, mts, cts, mjs, cjs
137
+ * index: './src/index.js',
138
+ * }
125
139
  */
126
140
  entry?: RsbuildEntry;
127
141
  /**
128
- * Specifies that certain files that will be excluded from compilation.
142
+ * Exclude JavaScript or TypeScript files that do not need to be compiled by SWC.
129
143
  */
130
144
  exclude?: RuleSetCondition[];
131
145
  /**
@@ -238,12 +252,12 @@ export type PublicDir = false | PublicDirOptions | PublicDirOptions[];
238
252
  export interface ServerConfig {
239
253
  /**
240
254
  * Configure the base path of the server.
241
- *
242
255
  * @default '/'
243
256
  */
244
257
  base?: string;
245
258
  /**
246
- * Whether to enable gzip compression
259
+ * Whether to enable gzip compression for served static assets.
260
+ * @default true
247
261
  */
248
262
  compress?: boolean;
249
263
  /**
@@ -251,15 +265,19 @@ export interface ServerConfig {
251
265
  */
252
266
  publicDir?: PublicDir;
253
267
  /**
254
- * Specify a port number for Rsbuild Server to listen.
268
+ * Specify a port number for Rsbuild server to listen.
269
+ * @default 3000
255
270
  */
256
271
  port?: number;
257
272
  /**
258
- * After configuring this option, you can enable HTTPS Server, and disabling the HTTP Server.
273
+ * Configure HTTPS options to enable HTTPS server.
274
+ * When enabled, HTTP server will be disabled.
275
+ * @default undefined
259
276
  */
260
277
  https?: HttpsServerOptions | SecureServerSessionOptions;
261
278
  /**
262
- * Used to set the host of Rsbuild Server.
279
+ * Specify the host that the Rsbuild server listens to.
280
+ * @default '0.0.0.0'
263
281
  */
264
282
  host?: string;
265
283
  /**
@@ -267,7 +285,8 @@ export interface ServerConfig {
267
285
  */
268
286
  headers?: Record<string, string | string[]>;
269
287
  /**
270
- * Whether to support html fallback.
288
+ * Whether to enable HTML fallback.
289
+ * @default 'index'
271
290
  */
272
291
  htmlFallback?: HtmlFallback;
273
292
  /**
@@ -277,6 +296,7 @@ export interface ServerConfig {
277
296
  historyApiFallback?: boolean | HistoryApiFallbackOptions;
278
297
  /**
279
298
  * Set the page URL to open when the server starts.
299
+ * @default false
280
300
  */
281
301
  open?: boolean | string | string[] | {
282
302
  target?: string | string[];
@@ -292,19 +312,28 @@ export interface ServerConfig {
292
312
  */
293
313
  cors?: boolean | cors.CorsOptions;
294
314
  /**
295
- * Configure proxy rules for the dev server or preview server to proxy requests to the specified service.
315
+ * Configure proxy rules for the dev server or preview server to proxy requests to
316
+ * the specified service.
296
317
  */
297
318
  proxy?: ProxyConfig;
298
319
  /**
299
320
  * Whether to throw an error when the port is occupied.
321
+ * @default false
300
322
  */
301
323
  strictPort?: boolean;
302
324
  /**
303
- * Whether to print the server urls when the server is started.
325
+ * Controls whether and how server URLs are printed when the server starts.
326
+ * @default true
304
327
  */
305
328
  printUrls?: PrintUrls;
329
+ /**
330
+ * Whether to create Rsbuild's server in middleware mode, which is useful for
331
+ * integrating with other servers.
332
+ * @default false
333
+ */
334
+ middlewareMode?: boolean;
306
335
  }
307
- export type NormalizedServerConfig = ServerConfig & Required<Pick<ServerConfig, 'htmlFallback' | 'port' | 'host' | 'compress' | 'strictPort' | 'printUrls' | 'open' | 'base' | 'cors'>>;
336
+ export type NormalizedServerConfig = ServerConfig & Required<Pick<ServerConfig, 'htmlFallback' | 'port' | 'host' | 'compress' | 'strictPort' | 'printUrls' | 'open' | 'base' | 'cors' | 'middlewareMode'>>;
308
337
  export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
309
338
  export type SriOptions = {
310
339
  algorithm?: SriAlgorithm;
@@ -317,8 +346,9 @@ export interface SecurityConfig {
317
346
  */
318
347
  nonce?: string;
319
348
  /**
320
- * Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML allows the browser to
321
- * verify the integrity of the introduced resource, thus preventing tampering with the downloaded resource.
349
+ * Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML
350
+ * allows the browser to verify the integrity of the introduced resource, thus preventing
351
+ * tampering with the downloaded resource.
322
352
  */
323
353
  sri?: SriOptions;
324
354
  }
@@ -441,13 +471,15 @@ export interface PerformanceConfig {
441
471
  /**
442
472
  * Used to control resource `DnsPrefetch`.
443
473
  *
444
- * Specifies that the user agent should preemptively perform DNS resolution for the target resource's origin.
474
+ * Specifies that the user agent should preemptively perform DNS resolution for the target
475
+ * resource's origin.
445
476
  */
446
477
  dnsPrefetch?: DnsPrefetch;
447
478
  /**
448
479
  * Used to control resource `Preload`.
449
480
  *
450
- * Specifies that the user agent must preemptively fetch and cache the target resource for current navigation.
481
+ * Specifies that the user agent must preemptively fetch and cache the target resource for
482
+ * current navigation.
451
483
  */
452
484
  preload?: true | PreloadOption;
453
485
  /**
@@ -459,7 +491,7 @@ export interface PerformanceConfig {
459
491
  prefetch?: true | PrefetchOption;
460
492
  /**
461
493
  * Whether capture timing information for each module,
462
- * same as the [profile](https://webpack.js.org/configuration/other-options/#profile) config of webpack.
494
+ * same as the [profile](https://rspack.dev/config/other-options#profile) config of Rspack.
463
495
  */
464
496
  profile?: boolean;
465
497
  }
@@ -554,50 +586,50 @@ export type DistPathConfig = {
554
586
  assets?: string;
555
587
  };
556
588
  export type FilenameConfig = {
589
+ /**
590
+ * The name of HTML files.
591
+ * @default `[name].html`
592
+ */
593
+ html?: string;
557
594
  /**
558
595
  * The name of the JavaScript files.
559
596
  * @default
560
597
  * - dev: '[name].js'
561
598
  * - prod: '[name].[contenthash:8].js'
562
599
  */
563
- js?: NonNullable<Rspack.Configuration['output']>['filename'];
600
+ js?: Rspack.Filename;
564
601
  /**
565
602
  * The name of the CSS files.
566
603
  * @default
567
604
  * - dev: '[name].css'
568
605
  * - prod: '[name].[contenthash:8].css'
569
606
  */
570
- css?: NonNullable<Rspack.Configuration['output']>['cssFilename'];
607
+ css?: Rspack.CssFilename;
571
608
  /**
572
609
  * The name of the SVG images.
573
610
  * @default '[name].[contenthash:8].svg'
574
611
  */
575
- svg?: string;
576
- /**
577
- * The name of HTML files.
578
- * @default `[name].html`
579
- */
580
- html?: string;
612
+ svg?: Rspack.AssetModuleFilename;
581
613
  /**
582
614
  * The name of the font files.
583
615
  * @default '[name].[contenthash:8][ext]'
584
616
  */
585
- font?: string;
617
+ font?: Rspack.AssetModuleFilename;
586
618
  /**
587
619
  * The name of non-SVG images.
588
620
  * @default '[name].[contenthash:8][ext]'
589
621
  */
590
- image?: string;
622
+ image?: Rspack.AssetModuleFilename;
591
623
  /**
592
624
  * The name of media assets, such as video.
593
625
  * @default '[name].[contenthash:8][ext]'
594
626
  */
595
- media?: string;
627
+ media?: Rspack.AssetModuleFilename;
596
628
  /**
597
629
  * the name of other assets, except for above (image, svg, font, html, wasm...)
598
630
  * @default '[name].[contenthash:8][ext]'
599
631
  */
600
- assets?: string;
632
+ assets?: Rspack.AssetModuleFilename;
601
633
  };
602
634
  export type DataUriLimit = {
603
635
  /**
@@ -739,7 +771,8 @@ export type ManifestObjectConfig = {
739
771
  }) => Record<string, unknown>;
740
772
  /**
741
773
  * Allows you to filter the files included in the manifest.
742
- * The function receives a `file` parameter and returns `true` to keep the file, or `false` to exclude it.
774
+ * The function receives a `file` parameter and returns `true` to keep the file,
775
+ * or `false` to exclude it.
743
776
  * @default (file: FileDescriptor) => !file.name.endsWith('.LICENSE.txt')
744
777
  */
745
778
  filter?: (file: FileDescriptor) => boolean;
@@ -753,7 +786,8 @@ export type CleanDistPathObject = {
753
786
  enable?: boolean | 'auto';
754
787
  /**
755
788
  * Specify the files to keep in the output directory.
756
- * If the file's absolute path matches the regular expression in `keep`, the file will not be removed.
789
+ * If the file's absolute path matches the regular expression in `keep`, the file
790
+ * will not be removed.
757
791
  * @default undefined
758
792
  */
759
793
  keep?: RegExp[];
@@ -773,12 +807,12 @@ export interface OutputConfig {
773
807
  */
774
808
  externals?: Externals;
775
809
  /**
776
- * Set the directory of the dist files.
777
- * Rsbuild will output files to the corresponding subdirectory according to the file type.
810
+ * Set the directory of the output files.
811
+ * Rsbuild will emit files to the specified subdirectory according to the file type.
778
812
  */
779
813
  distPath?: DistPathConfig;
780
814
  /**
781
- * Sets the filename of dist files.
815
+ * Sets the filename of output files.
782
816
  */
783
817
  filename?: FilenameConfig;
784
818
  /**
@@ -795,13 +829,14 @@ export interface OutputConfig {
795
829
  /**
796
830
  * When using CDN in the production,
797
831
  * you can use this option to set the URL prefix of static assets,
798
- * similar to the output.publicPath config of webpack.
832
+ * similar to the `output.publicPath` config of Rspack.
799
833
  * @default `server.base`
800
834
  */
801
835
  assetPrefix?: string;
802
836
  /**
803
837
  * Set the size threshold to inline static assets such as images and fonts.
804
- * By default, static assets will be Base64 encoded and inline into the page if the size is less than 4KiB.
838
+ * By default, static assets will be Base64 encoded and inline into the page if
839
+ * the size is less than 4KiB.
805
840
  */
806
841
  dataUriLimit?: number | DataUriLimit;
807
842
  /**
@@ -871,8 +906,9 @@ export interface OutputConfig {
871
906
  /**
872
907
  * Specifies the range of target browsers that the project is compatible with.
873
908
  * This value will be used by [SWC](https://github.com/swc-project/swc) and
874
- * [Lightning CSS](https://github.com/parcel-bundler/lightningcss) to identify the JavaScript syntax that
875
- * need to be transformed and the CSS browser prefixes that need to be added.
909
+ * [Lightning CSS](https://github.com/parcel-bundler/lightningcss) to identify
910
+ * the JavaScript syntax that need to be transformed and the CSS browser prefixes
911
+ * that need to be added.
876
912
  * @default undefined
877
913
  */
878
914
  overrideBrowserslist?: string[];
@@ -1183,7 +1219,7 @@ export interface DevConfig {
1183
1219
  liveReload?: boolean;
1184
1220
  /**
1185
1221
  * Set the URL prefix of static assets in development mode,
1186
- * similar to the [output.publicPath](https://rspack.dev/config/output#outputpublicpath) config of webpack.
1222
+ * similar to the [output.publicPath](https://rspack.dev/config/output#outputpublicpath) config of Rspack.
1187
1223
  */
1188
1224
  assetPrefix?: string | boolean;
1189
1225
  /**
@@ -1239,8 +1275,8 @@ export interface ResolveConfig {
1239
1275
  */
1240
1276
  dedupe?: string[];
1241
1277
  /**
1242
- * Create aliases to import or require certain modules,
1243
- * same as the [resolve.alias](https://rspack.dev/config/resolve) config of Rspack.
1278
+ * Set the alias for the module path, which is used to simplify the import path or redirect the module reference.
1279
+ * Similar to the [resolve.alias](https://rspack.dev/config/resolve) config of Rspack.
1244
1280
  */
1245
1281
  alias?: ConfigChain<Alias>;
1246
1282
  /**
@@ -1330,7 +1366,7 @@ export interface RsbuildConfig extends EnvironmentConfig {
1330
1366
  */
1331
1367
  dev?: DevConfig;
1332
1368
  /**
1333
- * Options for the Rsbuild Server,
1369
+ * Options for the Rsbuild server,
1334
1370
  * will take effect during local development and preview.
1335
1371
  */
1336
1372
  server?: ServerConfig;
@@ -13,4 +13,4 @@ export interface BundlerPluginInstance {
13
13
  }
14
14
  /** T[] => T */
15
15
  type GetElementType<T extends any[]> = T extends (infer U)[] ? U : never;
16
- export type RspackRule = GetElementType<NonNullable<NonNullable<Rspack.Configuration['module']>['rules']>>;
16
+ export type RspackRule = GetElementType<Rspack.RuleSetRules>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,15 +46,16 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.2.3",
49
+ "@rspack/core": "1.2.6",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.15",
52
- "core-js": "~3.40.0"
52
+ "core-js": "~3.40.0",
53
+ "jiti": "^2.4.2"
53
54
  },
54
55
  "devDependencies": {
55
- "@rslib/core": "0.4.1",
56
+ "@rslib/core": "0.5.1",
56
57
  "@types/connect": "3.4.38",
57
- "@types/node": "^22.13.4",
58
+ "@types/node": "^22.13.5",
58
59
  "@types/on-finished": "2.3.4",
59
60
  "@types/webpack-bundle-analyzer": "4.7.0",
60
61
  "@types/ws": "^8.5.14",
@@ -70,29 +71,28 @@
70
71
  "dotenv-expand": "12.0.1",
71
72
  "html-rspack-plugin": "6.0.2",
72
73
  "http-proxy-middleware": "^2.0.6",
73
- "jiti": "^1.21.7",
74
74
  "launch-editor-middleware": "^2.10.0",
75
- "mrmime": "^2.0.0",
75
+ "mrmime": "^2.0.1",
76
76
  "on-finished": "2.4.1",
77
77
  "open": "^8.4.0",
78
78
  "picocolors": "^1.1.1",
79
- "postcss": "^8.5.2",
79
+ "postcss": "^8.5.3",
80
80
  "postcss-load-config": "6.0.1",
81
81
  "postcss-loader": "8.1.1",
82
82
  "prebundle": "1.2.7",
83
83
  "reduce-configs": "^1.1.0",
84
- "rsbuild-dev-middleware": "0.1.2",
84
+ "rsbuild-dev-middleware": "0.2.0",
85
85
  "rslog": "^1.2.3",
86
86
  "rspack-chain": "^1.2.1",
87
87
  "rspack-manifest-plugin": "5.0.3",
88
- "sirv": "^3.0.0",
88
+ "sirv": "^3.0.1",
89
89
  "style-loader": "3.3.4",
90
- "tinyglobby": "^0.2.10",
90
+ "tinyglobby": "^0.2.12",
91
91
  "typescript": "^5.7.3",
92
92
  "webpack": "^5.98.0",
93
93
  "webpack-bundle-analyzer": "^4.10.2",
94
94
  "webpack-merge": "6.0.1",
95
- "ws": "^8.18.0"
95
+ "ws": "^8.18.1"
96
96
  },
97
97
  "engines": {
98
98
  "node": ">=16.7.0"
@@ -1 +0,0 @@
1
- export = any;