@rsbuild/core 2.0.6 → 2.0.7

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.
@@ -1104,6 +1104,28 @@ export type CleanDistPathObject = {
1104
1104
  keep?: RegExp[];
1105
1105
  };
1106
1106
  export type CleanDistPath = boolean | 'auto' | CleanDistPathObject;
1107
+ export type AutoExternal = boolean | {
1108
+ /**
1109
+ * Whether to automatically externalize dependencies of type `dependencies`.
1110
+ * @default true
1111
+ */
1112
+ dependencies?: boolean;
1113
+ /**
1114
+ * Whether to automatically externalize dependencies of type `optionalDependencies`.
1115
+ * @default true
1116
+ */
1117
+ optionalDependencies?: boolean;
1118
+ /**
1119
+ * Whether to automatically externalize dependencies of type `peerDependencies`.
1120
+ * @default true
1121
+ */
1122
+ peerDependencies?: boolean;
1123
+ /**
1124
+ * Whether to automatically externalize dependencies of type `devDependencies`.
1125
+ * @default false
1126
+ */
1127
+ devDependencies?: boolean;
1128
+ };
1107
1129
  export interface OutputConfig {
1108
1130
  /**
1109
1131
  * Setting the build target for Rsbuild.
@@ -1117,6 +1139,12 @@ export interface OutputConfig {
1117
1139
  * @default undefined
1118
1140
  */
1119
1141
  externals?: Externals;
1142
+ /**
1143
+ * Automatically externalize dependencies declared in the root package.json.
1144
+ * This option will generate `externals` rules for matching dependencies and their subpath imports.
1145
+ * @default false
1146
+ */
1147
+ autoExternal?: AutoExternal;
1120
1148
  /**
1121
1149
  * Set the directory of the output files.
1122
1150
  * Rsbuild will emit files to the specified subdirectory according to the file type.
@@ -452,7 +452,7 @@ export type RsbuildPluginAPI = Readonly<{
452
452
  */
453
453
  onAfterBuild: PluginHook<OnAfterBuildFn>;
454
454
  /**
455
- * A callback function that is triggered after the compiler instance has been
455
+ * A callback function that is triggered after the Rspack Compiler instance has been
456
456
  * created, but before the build process. This hook is called when you run
457
457
  * `rsbuild.startDevServer`, `rsbuild.build`, or `rsbuild.createCompiler`.
458
458
  */
@@ -488,8 +488,8 @@ export type RsbuildPluginAPI = Readonly<{
488
488
  */
489
489
  onBeforeDevCompile: PluginHook<OnBeforeDevCompileFn>;
490
490
  /**
491
- * A callback function that is triggered after the Compiler instance has been
492
- * created, but before the build process begins. This hook is called when you
491
+ * A callback function that is triggered before the Rspack Compiler instance is
492
+ * created. This hook is called when you
493
493
  * run `rsbuild.startDevServer`, `rsbuild.build`, or `rsbuild.createCompiler`.
494
494
  */
495
495
  onBeforeCreateCompiler: PluginHook<OnBeforeCreateCompilerFn>;
@@ -190,7 +190,7 @@ export type RsbuildInstance = {
190
190
  * Remove the plugin in the specified environment.
191
191
  * If environment is not specified, remove it in all environments.
192
192
  */
193
- environment: string;
193
+ environment?: string;
194
194
  }) => void;
195
195
  /**
196
196
  * Perform a production mode build. This method will generate optimized
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -36,7 +36,7 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rspack/core": "~2.0.3",
39
+ "@rspack/core": "~2.0.4",
40
40
  "@swc/helpers": "^0.5.21"
41
41
  },
42
42
  "peerDependencies": {
@@ -50,9 +50,9 @@
50
50
  "devDependencies": {
51
51
  "@jridgewell/remapping": "^2.3.5",
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
- "@rslib/core": "0.21.4",
53
+ "@rslib/core": "0.21.5",
54
54
  "@types/cors": "^2.8.19",
55
- "@types/node": "^24.12.3",
55
+ "@types/node": "^24.12.4",
56
56
  "@types/on-finished": "2.3.5",
57
57
  "@types/range-parser": "^1.2.7",
58
58
  "@types/ws": "^8.18.1",
@@ -60,6 +60,7 @@
60
60
  "cac": "^7.0.0",
61
61
  "chokidar": "^5.0.0",
62
62
  "connect-next": "4.0.1",
63
+ "core-js": "^3.49.0",
63
64
  "cors": "^2.8.6",
64
65
  "css-loader": "7.1.4",
65
66
  "deepmerge": "^4.3.1",
@@ -85,10 +86,9 @@
85
86
  "sirv": "^3.0.2",
86
87
  "stacktrace-parser": "^0.1.11",
87
88
  "style-loader": "^4.0.0",
88
- "supports-color": "^10.2.2",
89
89
  "tinyglobby": "^0.2.16",
90
90
  "typescript": "^6.0.3",
91
- "ws": "^8.20.0"
91
+ "ws": "^8.20.1"
92
92
  },
93
93
  "engines": {
94
94
  "node": "^20.19.0 || >=22.12.0"
package/types.d.ts CHANGED
@@ -45,6 +45,15 @@ interface ImportMetaEnv extends Record<ImportMetaEnvFallbackKey, any> {
45
45
  * }
46
46
  */
47
47
  PROD: boolean;
48
+ /**
49
+ * Whether the current build is for the server (SSR).
50
+ * If `output.target` is `'node'`, the value is `true`; otherwise, it is `false`.
51
+ * @example
52
+ * if (import.meta.env.SSR) {
53
+ * console.log('SSR build');
54
+ * }
55
+ */
56
+ SSR: boolean;
48
57
  /**
49
58
  * The value of the `server.base` configuration.
50
59
  * @example
@@ -252,6 +261,39 @@ declare module '*?url' {
252
261
  export default content;
253
262
  }
254
263
 
264
+ /**
265
+ * Imports the file as a Web Worker constructor.
266
+ * @example
267
+ * import MyWorker from './worker.ts?worker';
268
+ * const worker = new MyWorker();
269
+ */
270
+ declare module '*?worker' {
271
+ const WorkerConstructor: {
272
+ new (options?: { name?: string }): Worker;
273
+ };
274
+ export default WorkerConstructor;
275
+ }
276
+
277
+ /**
278
+ * Imports the file as an inline Web Worker constructor.
279
+ * @example
280
+ * import MyWorker from './worker.ts?worker&inline';
281
+ * const worker = new MyWorker();
282
+ */
283
+ declare module '*?worker&inline' {
284
+ const WorkerConstructor: {
285
+ new (options?: { name?: string }): Worker;
286
+ };
287
+ export default WorkerConstructor;
288
+ }
289
+
290
+ declare module '*?inline&worker' {
291
+ const WorkerConstructor: {
292
+ new (options?: { name?: string }): Worker;
293
+ };
294
+ export default WorkerConstructor;
295
+ }
296
+
255
297
  /**
256
298
  * Imports the file content as a base64 encoded string.
257
299
  * @note Only works for static assets and CSS files by default.