@rsbuild/core 1.5.12 → 1.5.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 (47) hide show
  1. package/compiled/@jridgewell/remapping/index.js +5 -848
  2. package/compiled/@jridgewell/trace-mapping/index.d.ts +194 -0
  3. package/compiled/@jridgewell/trace-mapping/index.js +1408 -0
  4. package/compiled/@jridgewell/trace-mapping/license +19 -0
  5. package/compiled/@jridgewell/trace-mapping/package.json +1 -0
  6. package/compiled/css-loader/index.js +22 -22
  7. package/compiled/html-rspack-plugin/index.js +14 -14
  8. package/compiled/launch-editor-middleware/index.js +3 -3
  9. package/compiled/memfs/index.d.ts +6 -1
  10. package/compiled/memfs/index.js +662 -636
  11. package/compiled/memfs/package.json +1 -1
  12. package/compiled/postcss/index.js +4 -4
  13. package/compiled/postcss-loader/index.js +6 -6
  14. package/compiled/rspack-manifest-plugin/index.js +4 -4
  15. package/dist/client/hmr.js +58 -19
  16. package/dist/index.cjs +426 -373
  17. package/dist/index.js +420 -369
  18. package/dist-types/configChain.d.ts +0 -4
  19. package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +9 -0
  20. package/dist-types/server/assets-middleware/index.d.ts +48 -0
  21. package/dist-types/server/assets-middleware/middleware.d.ts +3 -0
  22. package/dist-types/server/assets-middleware/setupOutputFileSystem.d.ts +4 -0
  23. package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
  24. package/dist-types/server/browserLogs.d.ts +7 -0
  25. package/dist-types/server/{compilationManager.d.ts → buildManager.d.ts} +11 -11
  26. package/dist-types/server/devMiddlewares.d.ts +2 -2
  27. package/dist-types/server/devServer.d.ts +3 -3
  28. package/dist-types/server/middlewares.d.ts +3 -3
  29. package/dist-types/server/socketServer.d.ts +22 -11
  30. package/dist-types/server/watchFiles.d.ts +2 -2
  31. package/dist-types/types/config.d.ts +13 -6
  32. package/dist-types/types/context.d.ts +14 -4
  33. package/dist-types/types/plugin.d.ts +1 -1
  34. package/dist-types/types/rsbuild.d.ts +8 -1
  35. package/package.json +5 -3
  36. package/dist-types/dev-middleware/index.d.ts +0 -53
  37. package/dist-types/dev-middleware/middleware.d.ts +0 -3
  38. package/dist-types/dev-middleware/utils/getFilenameFromUrl.d.ts +0 -7
  39. package/dist-types/dev-middleware/utils/getPaths.d.ts +0 -7
  40. package/dist-types/dev-middleware/utils/ready.d.ts +0 -2
  41. package/dist-types/dev-middleware/utils/setupHooks.d.ts +0 -3
  42. package/dist-types/dev-middleware/utils/setupOutputFileSystem.d.ts +0 -3
  43. package/dist-types/dev-middleware/utils/setupWriteToDisk.d.ts +0 -7
  44. package/dist-types/server/compilationMiddleware.d.ts +0 -36
  45. /package/dist-types/{dev-middleware/utils → server/assets-middleware}/escapeHtml.d.ts +0 -0
  46. /package/dist-types/{dev-middleware/utils → server/assets-middleware}/memorize.d.ts +0 -0
  47. /package/dist-types/{dev-middleware/utils → server/assets-middleware}/parseTokenList.d.ts +0 -0
@@ -48,8 +48,6 @@ export declare const CHAIN_ID: {
48
48
  readonly STYLUS_INLINE: "stylus-inline";
49
49
  /** Rule for svg */
50
50
  readonly SVG: "svg";
51
- /** Rule for pug */
52
- readonly PUG: "pug";
53
51
  /** Rule for Vue */
54
52
  readonly VUE: "vue";
55
53
  /** Rule for wasm */
@@ -80,8 +78,6 @@ export declare const CHAIN_ID: {
80
78
  readonly STYLUS: "stylus";
81
79
  /** url-loader */
82
80
  readonly URL: "url";
83
- /** pug-loader */
84
- readonly PUG: "pug";
85
81
  /** vue-loader */
86
82
  readonly VUE: "vue";
87
83
  /** swc-loader */
@@ -0,0 +1,9 @@
1
+ import type { Stats as FSStats } from 'node:fs';
2
+ import type { EnvironmentContext } from '../../types';
3
+ import type { OutputFileSystem } from './index';
4
+ export declare function getFileFromUrl(url: string, outputFileSystem: OutputFileSystem, environments: Record<string, EnvironmentContext>): {
5
+ filename: string;
6
+ fsStats: FSStats;
7
+ } | {
8
+ errorCode: number;
9
+ } | undefined;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The assets middleware is modified based on
3
+ * https://github.com/webpack/webpack-dev-middleware
4
+ *
5
+ * MIT Licensed
6
+ * Copyright JS Foundation and other contributors
7
+ * https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
8
+ */
9
+ import type { Stats as FSStats, ReadStream } from 'node:fs';
10
+ import type { Compiler, MultiCompiler } from '@rspack/core';
11
+ import type { InternalContext, NormalizedConfig, RequestHandler } from '../../types';
12
+ import type { SocketServer } from '../socketServer';
13
+ export type MultiWatching = ReturnType<MultiCompiler['watch']>;
14
+ export type OutputFileSystem = {
15
+ createReadStream?: (p: string, opts: {
16
+ start: number;
17
+ end: number;
18
+ }) => ReadStream;
19
+ statSync?: (p: string) => FSStats;
20
+ readFileSync?: (p: string) => Buffer;
21
+ };
22
+ export type Options = {
23
+ writeToDisk?: boolean | ((targetPath: string, compilationName?: string) => boolean);
24
+ };
25
+ export type AssetsMiddlewareClose = (callback: (err?: Error | null) => void) => void;
26
+ export type AssetsMiddleware = RequestHandler & {
27
+ watch: () => void;
28
+ close: AssetsMiddlewareClose;
29
+ };
30
+ export declare const isClientCompiler: (compiler: Compiler) => boolean;
31
+ export declare const setupServerHooks: ({ compiler, token, socketServer, }: {
32
+ compiler: Compiler;
33
+ token: string;
34
+ socketServer: SocketServer;
35
+ }) => void;
36
+ /**
37
+ * The assets middleware handles compiler setup for development:
38
+ * - Call `compiler.watch`
39
+ * - Inject the HMR client path into page
40
+ * - Notify server when compiler hooks are triggered
41
+ */
42
+ export declare const assetsMiddleware: ({ config, compiler, context, socketServer, resolvedPort, }: {
43
+ config: NormalizedConfig;
44
+ compiler: Compiler | MultiCompiler;
45
+ context: InternalContext;
46
+ socketServer: SocketServer;
47
+ resolvedPort: number;
48
+ }) => Promise<AssetsMiddleware>;
@@ -0,0 +1,3 @@
1
+ import type { InternalContext, RequestHandler } from '../../types';
2
+ import type { OutputFileSystem } from './index';
3
+ export declare function createMiddleware(context: InternalContext, ready: (callback: () => void) => void, outputFileSystem: OutputFileSystem): RequestHandler;
@@ -0,0 +1,4 @@
1
+ import type { Compiler } from '@rspack/core';
2
+ import type { OutputFileSystem } from './index';
3
+ import type { ResolvedWriteToDisk } from './setupWriteToDisk';
4
+ export declare function setupOutputFileSystem(writeToDisk: ResolvedWriteToDisk, compilers: Compiler[]): Promise<OutputFileSystem>;
@@ -0,0 +1,15 @@
1
+ import type { Compiler } from '@rspack/core';
2
+ import type { EnvironmentContext, NormalizedDevConfig } from '../../types';
3
+ declare module '@rspack/core' {
4
+ interface Compiler {
5
+ __hasRsbuildAssetEmittedCallback?: boolean;
6
+ }
7
+ }
8
+ export type ResolvedWriteToDisk = boolean | ((filePath: string, name?: string) => boolean);
9
+ /**
10
+ * Resolve writeToDisk config across multiple environments.
11
+ * Returns the unified config if all environments have the same value,
12
+ * otherwise returns a function that resolves config based on compilation.
13
+ */
14
+ export declare const resolveWriteToDiskConfig: (config: NormalizedDevConfig, environments: Record<string, EnvironmentContext>) => ResolvedWriteToDisk;
15
+ export declare function setupWriteToDisk(compilers: Compiler[], writeToDisk: ResolvedWriteToDisk): void;
@@ -0,0 +1,7 @@
1
+ import type { InternalContext, Rspack } from '../types';
2
+ import type { ClientMessageError } from './socketServer';
3
+ /**
4
+ * Formats error messages received from the browser into a log string with
5
+ * source location information.
6
+ */
7
+ export declare const formatBrowserErrorLog: (message: ClientMessageError, context: InternalContext, fs: Rspack.OutputFileSystem) => Promise<string>;
@@ -1,28 +1,28 @@
1
- import type { EnvironmentContext, NormalizedConfig, Rspack } from '../types';
2
- import { type CompilationMiddleware } from './compilationMiddleware';
1
+ import type { InternalContext, NormalizedConfig, Rspack } from '../types';
2
+ import { type AssetsMiddleware } from './assets-middleware';
3
3
  import { SocketServer } from './socketServer';
4
4
  type Options = {
5
+ context: InternalContext;
5
6
  config: NormalizedConfig;
6
7
  compiler: Rspack.Compiler | Rspack.MultiCompiler;
7
8
  publicPaths: string[];
8
9
  resolvedPort: number;
9
- environments: Record<string, EnvironmentContext>;
10
10
  };
11
11
  /**
12
- * Setup compiler-related logic:
13
- * 1. setup rsbuild-dev-middleware
12
+ * Setup compiler related logic:
13
+ * 1. setup assets middleware
14
14
  * 2. establish webSocket connect
15
15
  */
16
- export declare class CompilationManager {
17
- middleware: CompilationMiddleware;
16
+ export declare class BuildManager {
17
+ middleware: AssetsMiddleware;
18
18
  outputFileSystem: Rspack.OutputFileSystem;
19
- private config;
19
+ socketServer: SocketServer;
20
20
  compiler: Rspack.Compiler | Rspack.MultiCompiler;
21
- private environments;
21
+ private config;
22
22
  private publicPaths;
23
- socketServer: SocketServer;
24
23
  private resolvedPort;
25
- constructor({ config, compiler, publicPaths, resolvedPort, environments, }: Options);
24
+ private context;
25
+ constructor({ config, context, compiler, publicPaths, resolvedPort, }: Options);
26
26
  init(): Promise<void>;
27
27
  /**
28
28
  * Call `compiler.watch()` to start compiling.
@@ -1,11 +1,11 @@
1
1
  import type { InternalContext, NormalizedConfig, RequestHandler } from '../types';
2
- import type { CompilationManager } from './compilationManager';
2
+ import type { BuildManager } from './buildManager';
3
3
  import type { RsbuildDevServer } from './devServer';
4
4
  import type { UpgradeEvent } from './helper';
5
5
  export type RsbuildDevMiddlewareOptions = {
6
6
  config: NormalizedConfig;
7
7
  context: InternalContext;
8
- compilationManager?: CompilationManager;
8
+ buildManager?: BuildManager;
9
9
  devServerAPI: RsbuildDevServer;
10
10
  /**
11
11
  * Callbacks returned by the `onBeforeStartDevServer` hook.
@@ -1,14 +1,14 @@
1
1
  import type { Server } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
3
  import type { Connect, CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
4
- import type { SocketMessage } from './socketServer';
4
+ import type { ServerMessage } from './socketServer';
5
5
  type HTTPServer = Server | Http2SecureServer;
6
- type ExtractSocketMessageData<T extends SocketMessage['type']> = Extract<SocketMessage, {
6
+ type ExtractSocketMessageData<T extends ServerMessage['type']> = Extract<ServerMessage, {
7
7
  type: T;
8
8
  }> extends {
9
9
  data: infer D;
10
10
  } ? D : undefined;
11
- export type SockWrite = <T extends SocketMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
11
+ export type SockWrite = <T extends ServerMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
12
12
  export type RsbuildDevServer = {
13
13
  /**
14
14
  * The `connect` app instance.
@@ -1,5 +1,5 @@
1
1
  import type { Connect, EnvironmentAPI, HtmlFallback, RequestHandler } from '../types';
2
- import type { CompilationManager } from './compilationManager';
2
+ import type { BuildManager } from './buildManager';
3
3
  export declare const faviconFallbackMiddleware: RequestHandler;
4
4
  export declare const getRequestLoggerMiddleware: () => Connect.NextHandleFunction;
5
5
  export declare const notFoundMiddleware: RequestHandler;
@@ -9,7 +9,7 @@ export declare const optionsFallbackMiddleware: RequestHandler;
9
9
  */
10
10
  export declare const getHtmlCompletionMiddleware: (params: {
11
11
  distPath: string;
12
- compilationManager: CompilationManager;
12
+ buildManager: BuildManager;
13
13
  }) => RequestHandler;
14
14
  /**
15
15
  * handle `server.base`
@@ -22,7 +22,7 @@ export declare const getBaseMiddleware: (params: {
22
22
  */
23
23
  export declare const getHtmlFallbackMiddleware: (params: {
24
24
  distPath: string;
25
- compilationManager: CompilationManager;
25
+ buildManager: BuildManager;
26
26
  htmlFallback?: HtmlFallback;
27
27
  }) => RequestHandler;
28
28
  /**
@@ -1,51 +1,62 @@
1
1
  import type { IncomingMessage } from 'node:http';
2
2
  import type { Socket } from 'node:net';
3
- import type { DevConfig, EnvironmentContext, Rspack } from '../types';
4
- export type SocketMessageStaticChanged = {
3
+ import type { DevConfig, InternalContext, Rspack } from '../types';
4
+ export type ServerMessageStaticChanged = {
5
5
  type: 'static-changed' | 'content-changed';
6
6
  };
7
- export type SocketMessageHash = {
7
+ export type ServerMessageHash = {
8
8
  type: 'hash';
9
9
  data: string;
10
10
  };
11
- export type SocketMessageOk = {
11
+ export type ServerMessageOk = {
12
12
  type: 'ok';
13
13
  };
14
- export type SocketMessageWarnings = {
14
+ export type ServerMessageWarnings = {
15
15
  type: 'warnings';
16
16
  data: {
17
17
  text: string[];
18
18
  };
19
19
  };
20
- export type SocketMessageErrors = {
20
+ export type ServerMessageErrors = {
21
21
  type: 'errors';
22
22
  data: {
23
23
  text: string[];
24
24
  html: string;
25
25
  };
26
26
  };
27
- export type SocketMessage = SocketMessageOk | SocketMessageStaticChanged | SocketMessageHash | SocketMessageWarnings | SocketMessageErrors;
27
+ export type ServerMessage = ServerMessageOk | ServerMessageStaticChanged | ServerMessageHash | ServerMessageWarnings | ServerMessageErrors;
28
+ export type ClientMessageError = {
29
+ type: 'client-error';
30
+ message: string;
31
+ stack?: string;
32
+ };
33
+ export type ClientMessagePing = {
34
+ type: 'ping';
35
+ };
36
+ export type ClientMessage = ClientMessagePing | ClientMessageError;
28
37
  export declare class SocketServer {
29
38
  private wsServer;
30
39
  private readonly socketsMap;
31
40
  private readonly options;
41
+ private readonly context;
32
42
  private stats;
33
43
  private initialChunks;
34
44
  private heartbeatTimer;
35
- private environments;
36
- constructor(options: DevConfig, environments: Record<string, EnvironmentContext>);
45
+ private getOutputFileSystem;
46
+ private reportedBrowserLogs;
47
+ constructor(context: InternalContext, options: DevConfig, getOutputFileSystem: () => Rspack.OutputFileSystem);
37
48
  upgrade: (req: IncomingMessage, socket: Socket, head: Buffer) => void;
38
49
  private checkSockets;
39
50
  private clearHeartbeatTimer;
40
51
  prepare(): Promise<void>;
41
- updateStats(stats: Rspack.Stats, token: string): void;
52
+ onBuildDone(stats: Rspack.Stats, token: string): void;
42
53
  /**
43
54
  * Write message to each socket
44
55
  * @param message - The message to send
45
56
  * @param token - The token of the socket to send the message to,
46
57
  * if not provided, the message will be sent to all sockets
47
58
  */
48
- sockWrite(message: SocketMessage, token?: string): void;
59
+ sockWrite(message: ServerMessage, token?: string): void;
49
60
  close(): Promise<void>;
50
61
  private onConnect;
51
62
  private getStats;
@@ -1,10 +1,10 @@
1
1
  import type { FSWatcher } from '../../compiled/chokidar/index.js';
2
2
  import type { ChokidarOptions, NormalizedConfig } from '../types';
3
- import type { CompilationManager } from './compilationManager';
3
+ import type { BuildManager } from './buildManager';
4
4
  type WatchFilesOptions = {
5
5
  root: string;
6
6
  config: NormalizedConfig;
7
- compilationManager?: CompilationManager;
7
+ buildManager?: BuildManager;
8
8
  };
9
9
  export type WatchFilesResult = {
10
10
  close(): Promise<void>;
@@ -1131,7 +1131,7 @@ export type OutputStructure = 'flat' | 'nested';
1131
1131
  /**
1132
1132
  * custom properties
1133
1133
  * e.g. { name: 'viewport' content: 'width=500, initial-scale=1' }
1134
- * */
1134
+ */
1135
1135
  export type MetaAttrs = {
1136
1136
  [attrName: string]: string | boolean;
1137
1137
  };
@@ -1139,7 +1139,7 @@ export type MetaOptions = {
1139
1139
  /**
1140
1140
  * name content pair
1141
1141
  * e.g. { viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no' }`
1142
- * */
1142
+ */
1143
1143
  [name: string]: string | false | MetaAttrs;
1144
1144
  };
1145
1145
  export type HtmlBasicTag = {
@@ -1460,6 +1460,13 @@ export type CliShortcut = {
1460
1460
  };
1461
1461
  export type WriteToDisk = boolean | ((filename: string) => boolean);
1462
1462
  export interface DevConfig {
1463
+ /**
1464
+ * Enables forwarding of browser runtime errors to the terminal. When `true`, the dev
1465
+ * client listens for window `error` events in the browser and send them to the dev server,
1466
+ * where they are printed in the terminal (prefixed with `[browser]`).
1467
+ * @default true
1468
+ */
1469
+ browserLogs?: boolean;
1463
1470
  /**
1464
1471
  * Whether to enable Hot Module Replacement.
1465
1472
  * @default true
@@ -1524,7 +1531,7 @@ export interface DevConfig {
1524
1531
  */
1525
1532
  lazyCompilation?: boolean | Rspack.LazyCompilationOptions;
1526
1533
  }
1527
- export type NormalizedDevConfig = Omit<DevConfig, 'watchFiles'> & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts'>> & {
1534
+ export type NormalizedDevConfig = Omit<DevConfig, 'watchFiles'> & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts' | 'browserLogs'>> & {
1528
1535
  watchFiles: WatchFiles[];
1529
1536
  client: NormalizedClientConfig;
1530
1537
  };
@@ -1587,10 +1594,10 @@ export type RsbuildConfigMeta = {
1587
1594
  /**
1588
1595
  * Only some dev options can be defined in the environment config
1589
1596
  */
1590
- export type AllowedEnvironmentDevKeys = 'hmr' | 'client' | 'liveReload' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk';
1597
+ export type AllowedEnvironmentDevKeys = 'hmr' | 'client' | 'liveReload' | 'browserLogs' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk';
1591
1598
  /**
1592
1599
  * The Rsbuild config to run in the specified environment.
1593
- * */
1600
+ */
1594
1601
  export interface EnvironmentConfig {
1595
1602
  /**
1596
1603
  * Options for local development.
@@ -1636,7 +1643,7 @@ export interface EnvironmentConfig {
1636
1643
  export type LogLevel = 'info' | 'warn' | 'error' | 'silent';
1637
1644
  /**
1638
1645
  * The Rsbuild config.
1639
- * */
1646
+ */
1640
1647
  export interface RsbuildConfig extends EnvironmentConfig {
1641
1648
  /**
1642
1649
  * Specify the build mode for Rsbuild, as each mode has different default behavior and optimizations.
@@ -26,7 +26,8 @@ export type RsbuildContext = {
26
26
  * // ...
27
27
  * });
28
28
  * await rsbuild.startDevServer();
29
- * console.log(rsbuild.context.devServer); // { hostname: 'localhost', port: 3000, https: false }
29
+ * console.log(rsbuild.context.devServer);
30
+ * // { hostname: 'localhost', port: 3000, https: false }
30
31
  * }
31
32
  * ```
32
33
  */
@@ -58,6 +59,13 @@ export type RsbuildContext = {
58
59
  */
59
60
  callerName: string;
60
61
  };
62
+ export type BuildStatus = 'idle' | 'building' | 'done';
63
+ export type BuildState = {
64
+ /** Current build status */
65
+ status: BuildStatus;
66
+ /** Whether there are build errors */
67
+ hasErrors: boolean;
68
+ };
61
69
  /** The inner context. */
62
70
  export type InternalContext = RsbuildContext & {
63
71
  /** All hooks. */
@@ -70,12 +78,14 @@ export type InternalContext = RsbuildContext & {
70
78
  normalizedConfig?: NormalizedConfig;
71
79
  /**
72
80
  * Get the plugin API.
73
- *
74
- * When environment is undefined, the global plugin API is returned, which can be used in all environments.
75
- * */
81
+ * When environment is undefined, the global plugin API is returned, which
82
+ * can be used in all environments.
83
+ */
76
84
  getPluginAPI?: (environment?: string) => RsbuildPluginAPI;
77
85
  /** The environment context. */
78
86
  environments: Record<string, EnvironmentContext>;
79
87
  /** Only build specified environment. */
80
88
  specifiedEnvironments?: string[];
89
+ /** Build state information */
90
+ buildState: BuildState;
81
91
  };
@@ -102,7 +102,7 @@ export type ModifyWebpackChainUtils = ModifyChainUtils & {
102
102
  CHAIN_ID: ChainIdentifier;
103
103
  /**
104
104
  * @deprecated Use target instead.
105
- * */
105
+ */
106
106
  name: string;
107
107
  /**
108
108
  * @deprecated Use HtmlPlugin instead.
@@ -13,6 +13,7 @@ export type Bundler = 'rspack' | 'webpack';
13
13
  export type StartDevServerOptions = {
14
14
  /**
15
15
  * Using a custom Rspack Compiler object.
16
+ * @deprecated This is no longer supported and will be removed in a future version.
16
17
  */
17
18
  compiler?: Compiler | MultiCompiler;
18
19
  /**
@@ -48,6 +49,7 @@ export type BuildOptions = {
48
49
  watch?: boolean;
49
50
  /**
50
51
  * Using a custom Rspack Compiler object.
52
+ * @deprecated This is no longer supported and will be removed in a future version.
51
53
  */
52
54
  compiler?: Compiler | MultiCompiler;
53
55
  };
@@ -131,11 +133,16 @@ export type CreateRsbuildOptions = {
131
133
  * If not specified or passing an empty array, all environments will be built.
132
134
  */
133
135
  environment?: string[];
136
+ /**
137
+ * Alias for `config`.
138
+ * This option will be deprecated in the future.
139
+ */
140
+ rsbuildConfig?: RsbuildConfig | (() => Promise<RsbuildConfig>);
134
141
  /**
135
142
  * Rsbuild configurations.
136
143
  * Passing a function to load the config asynchronously with custom logic.
137
144
  */
138
- rsbuildConfig?: RsbuildConfig | (() => Promise<RsbuildConfig>);
145
+ config?: RsbuildConfig | (() => Promise<RsbuildConfig>);
139
146
  /**
140
147
  * Whether to call `loadEnv` to load environment variables and define them
141
148
  * as global variables via `source.define`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.5.12",
3
+ "version": "1.5.13",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -46,7 +46,7 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.5.7",
49
+ "@rspack/core": "1.5.8",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.17",
52
52
  "core-js": "~3.45.1",
@@ -54,6 +54,7 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@jridgewell/remapping": "^2.3.5",
57
+ "@jridgewell/trace-mapping": "^0.3.31",
57
58
  "@rslib/core": "0.14.0",
58
59
  "@types/connect": "3.4.38",
59
60
  "@types/cors": "^2.8.19",
@@ -73,7 +74,7 @@
73
74
  "html-rspack-plugin": "6.1.3",
74
75
  "http-proxy-middleware": "^2.0.9",
75
76
  "launch-editor-middleware": "^2.11.1",
76
- "memfs": "^4.42.0",
77
+ "memfs": "^4.47.0",
77
78
  "mrmime": "^2.0.1",
78
79
  "on-finished": "2.4.1",
79
80
  "open": "^10.2.0",
@@ -88,6 +89,7 @@
88
89
  "rspack-chain": "^1.4.1",
89
90
  "rspack-manifest-plugin": "5.1.0",
90
91
  "sirv": "^3.0.2",
92
+ "stacktrace-parser": "^0.1.11",
91
93
  "style-loader": "3.3.4",
92
94
  "tinyglobby": "0.2.14",
93
95
  "typescript": "^5.9.2",
@@ -1,53 +0,0 @@
1
- /**
2
- * The dev middleware is modified based on
3
- * https://github.com/webpack/webpack-dev-middleware
4
- *
5
- * MIT Licensed
6
- * Copyright JS Foundation and other contributors
7
- * https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
8
- */
9
- import type { Stats as FSStats, ReadStream } from 'node:fs';
10
- import type { ServerResponse as NodeServerResponse } from 'node:http';
11
- import type { Compiler, Configuration, MultiCompiler, MultiStats, Stats, Watching } from '@rspack/core';
12
- import type { RequestHandler } from '../types';
13
- export type ServerResponse = NodeServerResponse & {
14
- locals?: {
15
- webpack?: {
16
- devMiddleware?: Context;
17
- };
18
- };
19
- };
20
- export type MultiWatching = ReturnType<MultiCompiler['watch']>;
21
- export type OutputFileSystem = {
22
- createReadStream?: (p: string, opts: {
23
- start: number;
24
- end: number;
25
- }) => ReadStream;
26
- statSync?: (p: string) => FSStats;
27
- lstat?: (p: string) => unknown;
28
- readFileSync?: (p: string) => Buffer;
29
- };
30
- export type Callback = (stats?: Stats | MultiStats) => void;
31
- export type Options = {
32
- writeToDisk?: boolean | ((targetPath: string, compilationName?: string) => boolean);
33
- publicPath?: NonNullable<Configuration['output']>['publicPath'];
34
- };
35
- export type Context = {
36
- state: boolean;
37
- stats: Stats | MultiStats | undefined;
38
- callbacks: Callback[];
39
- options: Options;
40
- compilers: Compiler[];
41
- watching: Watching | MultiWatching | undefined;
42
- outputFileSystem: OutputFileSystem;
43
- };
44
- export type FilledContext = Omit<Context, 'watching'> & {
45
- watching: Watching | MultiWatching;
46
- };
47
- export type Close = (callback: (err: Error | null | undefined) => void) => void;
48
- export type API = RequestHandler & {
49
- watch: () => void;
50
- close: Close;
51
- };
52
- export type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
53
- export declare function devMiddleware(compiler: Compiler | MultiCompiler, options?: Options): Promise<API>;
@@ -1,3 +0,0 @@
1
- import type { RequestHandler } from '../types';
2
- import type { FilledContext } from './index';
3
- export declare function wrapper(context: FilledContext): RequestHandler;
@@ -1,7 +0,0 @@
1
- import type { Stats } from 'node:fs';
2
- import type { FilledContext } from '../index';
3
- export type Extra = {
4
- stats?: Stats;
5
- errorCode?: number;
6
- };
7
- export declare function getFilenameFromUrl(context: FilledContext, url: string, extra?: Extra): string | undefined;
@@ -1,7 +0,0 @@
1
- import type { FilledContext } from '../index';
2
- type PublicPathInfo = {
3
- outputPath: string;
4
- publicPath: string | undefined;
5
- };
6
- export declare function getPaths(context: FilledContext): PublicPathInfo[];
7
- export {};
@@ -1,2 +0,0 @@
1
- import type { FilledContext } from '../index';
2
- export declare function ready(context: FilledContext, callback: (...args: any[]) => any): void;
@@ -1,3 +0,0 @@
1
- import type { Compiler, MultiCompiler } from '@rspack/core';
2
- import type { Context, WithOptional } from '../index';
3
- export declare function setupHooks(context: WithOptional<Context, 'watching' | 'outputFileSystem'>, compiler: Compiler | MultiCompiler): void;
@@ -1,3 +0,0 @@
1
- import type { Compiler } from '@rspack/core';
2
- import type { Options, OutputFileSystem } from '../index';
3
- export declare function setupOutputFileSystem(options: Options, compilers: Compiler[]): Promise<OutputFileSystem>;
@@ -1,7 +0,0 @@
1
- import type { Context, WithOptional } from '../index';
2
- declare module '@rspack/core' {
3
- interface Compiler {
4
- __hasRsbuildAssetEmittedCallback?: boolean;
5
- }
6
- }
7
- export declare function setupWriteToDisk(context: WithOptional<Context, 'watching' | 'outputFileSystem'>): void;
@@ -1,36 +0,0 @@
1
- import type { Compiler, MultiCompiler, Stats } from '@rspack/core';
2
- import type { Connect, EnvironmentContext, NormalizedConfig } from '../types';
3
- export declare const isClientCompiler: (compiler: {
4
- options: {
5
- target?: Compiler["options"]["target"];
6
- };
7
- }) => boolean;
8
- export type ServerCallbacks = {
9
- onInvalid: (token: string, fileName?: string | null) => void;
10
- onDone: (token: string, stats: Stats) => void;
11
- };
12
- export declare const setupServerHooks: ({ compiler, token, callbacks: { onDone, onInvalid }, }: {
13
- compiler: Compiler;
14
- token: string;
15
- callbacks: ServerCallbacks;
16
- }) => void;
17
- export type CompilationMiddleware = Connect.NextHandleFunction & {
18
- close: (callback: (err: Error | null | undefined) => void) => any;
19
- watch: () => void;
20
- };
21
- /**
22
- * The CompilationMiddleware handles compiler setup for development:
23
- * - Call `compiler.watch` (handled by rsbuild-dev-middleware)
24
- * - Inject the HMR client path into page
25
- * - Notify server when compiler hooks are triggered
26
- */
27
- export declare const getCompilationMiddleware: ({ config, compiler, callbacks, environments, resolvedPort, }: {
28
- config: NormalizedConfig;
29
- compiler: Compiler | MultiCompiler;
30
- /**
31
- * Should trigger when compiler hook called
32
- */
33
- callbacks: ServerCallbacks;
34
- environments: Record<string, EnvironmentContext>;
35
- resolvedPort: number;
36
- }) => Promise<CompilationMiddleware>;