@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
@@ -1,61 +1,65 @@
1
1
  export declare const isDeno: boolean;
2
2
  export declare const isWindows: boolean;
3
- export declare const ROOT_DIST_DIR = "dist";
4
- export declare const HTML_DIST_DIR = "./";
5
- export declare const FAVICON_DIST_DIR = "./";
6
- export declare const JS_DIST_DIR = "static/js";
7
- export declare const CSS_DIST_DIR = "static/css";
8
- export declare const SVG_DIST_DIR = "static/svg";
9
- export declare const FONT_DIST_DIR = "static/font";
10
- export declare const WASM_DIST_DIR = "static/wasm";
11
- export declare const IMAGE_DIST_DIR = "static/image";
12
- export declare const MEDIA_DIST_DIR = "static/media";
13
- export declare const ASSETS_DIST_DIR = "static/assets";
3
+ // Paths
4
+ export declare const ROOT_DIST_DIR = 'dist';
5
+ export declare const HTML_DIST_DIR = './';
6
+ export declare const FAVICON_DIST_DIR = './';
7
+ export declare const JS_DIST_DIR = 'static/js';
8
+ export declare const CSS_DIST_DIR = 'static/css';
9
+ export declare const SVG_DIST_DIR = 'static/svg';
10
+ export declare const FONT_DIST_DIR = 'static/font';
11
+ export declare const WASM_DIST_DIR = 'static/wasm';
12
+ export declare const IMAGE_DIST_DIR = 'static/image';
13
+ export declare const MEDIA_DIST_DIR = 'static/media';
14
+ export declare const ASSETS_DIST_DIR = 'static/assets';
15
+ // loaders will be emitted to the same folder of the main bundle
14
16
  export declare const LOADER_PATH: string;
15
17
  export declare const STATIC_PATH: string;
16
18
  export declare const CLIENT_PATH: string;
17
19
  export declare const COMPILED_PATH: string;
18
- export declare const TS_CONFIG_FILE = "tsconfig.json";
19
- export declare const HMR_SOCKET_PATH = "/rsbuild-hmr";
20
- export declare const RSBUILD_OUTPUTS_PATH = ".rsbuild";
21
- export declare const LOCALHOST = "localhost";
22
- export declare const ALL_INTERFACES_IPV4 = "0.0.0.0";
20
+ export declare const TS_CONFIG_FILE = 'tsconfig.json';
21
+ export declare const HMR_SOCKET_PATH = '/rsbuild-hmr';
22
+ export declare const RSBUILD_OUTPUTS_PATH = '.rsbuild';
23
+ export declare const LOCALHOST = 'localhost';
24
+ export declare const ALL_INTERFACES_IPV4 = '0.0.0.0';
25
+ // Defaults
23
26
  export declare const DEFAULT_PORT = 3000;
24
27
  export declare const DEFAULT_DATA_URL_SIZE = 4096;
25
- export declare const DEFAULT_MOUNT_ID = "root";
26
- export declare const DEFAULT_ASSET_PREFIX = "/";
27
- export declare const DEFAULT_STACK_TRACE = "summary";
28
+ export declare const DEFAULT_MOUNT_ID = 'root';
29
+ export declare const DEFAULT_ASSET_PREFIX = '/';
30
+ export declare const DEFAULT_STACK_TRACE = 'summary';
31
+ // Defaults to "baseline widely available on 2025-05-01"
32
+ // https://browsersl.ist/#q=baseline+widely+available+on+2025-05-01
28
33
  export declare const DEFAULT_WEB_BROWSERSLIST: string[];
29
34
  export declare const DEFAULT_BROWSERSLIST: Record<string, string[]>;
35
+ // RegExp
30
36
  export declare const JS_REGEX: RegExp;
31
37
  export declare const SCRIPT_REGEX: RegExp;
32
38
  export declare const CSS_REGEX: RegExp;
33
39
  /**
34
40
  * Regular expression to match the 'raw' query parameter.
35
41
  * Matches patterns like: `?raw`, `?raw&other=value`, `?other=value&raw`, `?raw=value`
36
- */
37
- export declare const RAW_QUERY_REGEX: RegExp;
42
+ */ export declare const RAW_QUERY_REGEX: RegExp;
38
43
  /**
39
44
  * Regular expression to match the 'inline' query parameter.
40
45
  * Matches patterns like: `?inline`, `?inline&other=value`, `?other=value&inline`, `?inline=value`
41
- */
42
- export declare const INLINE_QUERY_REGEX: RegExp;
46
+ */ export declare const INLINE_QUERY_REGEX: RegExp;
43
47
  /**
44
48
  * Regular expression to match the 'url' query parameter.
45
49
  * Matches patterns like: `?url`, `?url&other=value`, `?other=value&url`, `?url=value`
46
- */
47
- export declare const URL_QUERY_REGEX: RegExp;
50
+ */ export declare const URL_QUERY_REGEX: RegExp;
48
51
  /**
49
52
  * Regular expression to match the 'worker' query parameter.
50
53
  * Matches patterns like: `?worker`, `?worker&inline`, `?inline&worker`, `?worker=value`
51
- */
52
- export declare const WORKER_QUERY_REGEX: RegExp;
54
+ */ export declare const WORKER_QUERY_REGEX: RegExp;
53
55
  export declare const NODE_MODULES_REGEX: RegExp;
54
- export declare const PLUGIN_SWC_NAME = "rsbuild:swc";
55
- export declare const PLUGIN_CSS_NAME = "rsbuild:css";
56
+ // Plugins
57
+ export declare const PLUGIN_SWC_NAME = 'rsbuild:swc';
58
+ export declare const PLUGIN_CSS_NAME = 'rsbuild:css';
59
+ // Extensions
56
60
  export declare const FONT_EXTENSIONS: string[];
57
61
  export declare const IMAGE_EXTENSIONS: string[];
58
62
  export declare const VIDEO_EXTENSIONS: string[];
59
63
  export declare const AUDIO_EXTENSIONS: string[];
60
- export declare const LAZY_COMPILATION_IDENTIFIER = "lazy-compilation-proxy";
61
- export declare const BROWSER_LOG_PREFIX = "[browser]";
64
+ export declare const LAZY_COMPILATION_IDENTIFIER = 'lazy-compilation-proxy';
65
+ export declare const BROWSER_LOG_PREFIX = '[browser]';
@@ -8,5 +8,4 @@ export declare function createPublicContext(context: InternalContext): Readonly<
8
8
  /**
9
9
  * Generate the actual context used in the build,
10
10
  * which can have a lot of overhead and take some side effects.
11
- */
12
- export declare function createContext(options: ResolvedCreateRsbuildOptions, userConfig: RsbuildConfig, logger: Logger): Promise<InternalContext>;
11
+ */ export declare function createContext(options: ResolvedCreateRsbuildOptions, userConfig: RsbuildConfig, logger: Logger): Promise<InternalContext>;
@@ -1,5 +1,4 @@
1
1
  import type { CreateRsbuildOptions, RsbuildInstance } from './types';
2
2
  /**
3
3
  * Create an Rsbuild instance.
4
- */
5
- export declare function createRsbuild(options?: CreateRsbuildOptions): Promise<RsbuildInstance>;
4
+ */ export declare function createRsbuild(options?: CreateRsbuildOptions): Promise<RsbuildInstance>;
@@ -14,12 +14,10 @@ import type { NormalizedConfig, RsbuildConfig, RsbuildEntry } from './types';
14
14
  * },
15
15
  * }
16
16
  * ```
17
- */
18
- export declare const defaultAllowedOrigins: RegExp;
17
+ */ export declare const defaultAllowedOrigins: RegExp;
19
18
  export declare function getDefaultEntry(root: string): RsbuildEntry;
20
19
  export declare const withDefaultConfig: (rootPath: string, userConfig: RsbuildConfig) => Promise<RsbuildConfig>;
21
20
  /**
22
21
  * Normalizes the user configuration by merging it with defaults and ensuring
23
22
  * consistent structure.
24
- */
25
- export declare const normalizeConfig: (config: RsbuildConfig, rootPath: string) => NormalizedConfig;
23
+ */ export declare const normalizeConfig: (config: RsbuildConfig, rootPath: string) => NormalizedConfig;
@@ -1,3 +1,3 @@
1
1
  type Callback = (exitCode: number) => void;
2
2
  export declare function exitHook(onExit: Callback): () => void;
3
- export {};
3
+ export { };
@@ -1,3 +1,4 @@
1
1
  import type { StatsError } from '@rspack/core';
2
2
  import { type Logger } from '../logger';
3
- export declare function formatStatsError(stats: StatsError, root: string, level: ('error' | 'warning') | undefined, logger: Logger): string;
3
+ // Formats Rspack stats error to readable message
4
+ export declare function formatStatsError(stats: StatsError, root: string, level: 'error' | 'warning' | undefined, logger: Logger): string;
@@ -6,13 +6,11 @@ export declare function isEmptyDir(path: string): boolean;
6
6
  * Find first already exists file.
7
7
  * @param files - Absolute file paths with extension.
8
8
  * @returns The file path if exists, or false if no file exists.
9
- */
10
- export declare const findExists: (files: string[]) => string | false;
9
+ */ export declare const findExists: (files: string[]) => string | false;
11
10
  export declare function pathExists(path: string): Promise<boolean>;
12
11
  export declare function isFileExists(file: string): Promise<boolean>;
13
12
  export declare function fileExistsByCompilation({ inputFileSystem }: Rspack.Compilation, filePath: string): Promise<boolean>;
14
13
  /**
15
14
  * Read file asynchronously using Rspack compiler's filesystem.
16
- */
17
- export declare function readFileAsync(fs: NonNullable<Rspack.Compilation['inputFileSystem'] | Rspack.OutputFileSystem>, filename: string): Promise<Buffer | string>;
15
+ */ export declare function readFileAsync(fs: NonNullable<Rspack.Compilation['inputFileSystem'] | Rspack.OutputFileSystem>, filename: string): Promise<Buffer | string>;
18
16
  export declare function emptyDir(dir: string, logger: Logger, keep?: RegExp[], checkExists?: boolean): Promise<void>;
@@ -24,7 +24,6 @@ export declare const camelCase: (input: string) => string;
24
24
  export declare const prettyTime: (seconds: number) => string;
25
25
  /**
26
26
  * Check if running in a TTY context
27
- */
28
- export declare const isTTY: (type?: 'stdin' | 'stdout') => boolean;
27
+ */ export declare const isTTY: (type?: 'stdin' | 'stdout') => boolean;
29
28
  export declare function hash(data: string): Promise<string>;
30
29
  export declare const isRspackRuntimeModule: (identifier: string) => boolean;
@@ -6,4 +6,4 @@ export type PackageJson = Partial<{
6
6
  peerDependencies: Record<string, string>;
7
7
  devDependencies: Record<string, string>;
8
8
  }>;
9
- export declare const readPackageJson: (rootPath: string) => Promise<PackageJson | undefined>;
9
+ export declare const readPackageJsonByPath: (pkgJsonPath: string) => Promise<PackageJson | undefined>;
@@ -7,20 +7,16 @@ export declare const getCompiledPath: (packageName: string) => string;
7
7
  * @param base - Base path to resolve relative from.
8
8
  * @param filePath - Absolute or relative file path.
9
9
  * @returns Resolved absolute file path.
10
- */
11
- export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
10
+ */ export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
12
11
  export declare const getPathnameFromUrl: (url: string) => string;
13
- /** dedupe and remove nested paths */
14
- export declare const dedupeNestedPaths: (paths: string[]) => string[];
12
+ /** dedupe and remove nested paths */ export declare const dedupeNestedPaths: (paths: string[]) => string[];
15
13
  /**
16
14
  * Convert Windows backslash paths to posix forward slashes
17
15
  * @example
18
16
  * toPosixPath('foo\\bar') // returns 'foo/bar'
19
- */
20
- export declare const toPosixPath: (filepath: string) => string;
17
+ */ export declare const toPosixPath: (filepath: string) => string;
21
18
  /**
22
19
  * Normalize filepaths for `source.include` and `source.exclude` configuration.
23
20
  * On Windows, `require.resolve` returns paths with posix forward slashes,
24
21
  * This function normalizes the path to use backslashes.
25
- */
26
- export declare const normalizeRuleConditionPath: (filepath: Rspack.RuleSetCondition) => Rspack.RuleSetCondition;
22
+ */ export declare const normalizeRuleConditionPath: (filepath: Rspack.RuleSetCondition) => Rspack.RuleSetCondition;
@@ -4,9 +4,8 @@ import type { ActionType, RsbuildStats, Rspack } from '../types';
4
4
  * If stats has errors, return stats errors directly
5
5
  * If stats has no errors, return child errors, as some errors exist in both
6
6
  * stats and childCompiler
7
- */
8
- export declare const getStatsErrors: ({ errors, children, }: RsbuildStats) => Rspack.StatsError[];
9
- export declare const getStatsWarnings: ({ warnings, children, }: RsbuildStats) => Rspack.StatsError[];
7
+ */ export declare const getStatsErrors: ({ errors, children }: RsbuildStats) => Rspack.StatsError[];
8
+ export declare const getStatsWarnings: ({ warnings, children }: RsbuildStats) => Rspack.StatsError[];
10
9
  export declare function getRsbuildStats(statsInstance: Rspack.Stats | Rspack.MultiStats, compiler: Rspack.Compiler | Rspack.MultiCompiler, logger: Logger, action?: ActionType): RsbuildStats;
11
10
  export declare function formatStats(stats: RsbuildStats, hasErrors: boolean, root: string, logger: Logger): {
12
11
  message?: string;
@@ -15,5 +14,4 @@ export declare function formatStats(stats: RsbuildStats, hasErrors: boolean, roo
15
14
  /**
16
15
  * Remove the loader chain delimiter from the module identifier.
17
16
  * @example ./src/index.js!=!/node_modules/my-loader/index.js -> ./src/index.js
18
- */
19
- export declare const removeLoaderChainDelimiter: (moduleId: string, logger: Logger) => string;
17
+ */ export declare const removeLoaderChainDelimiter: (moduleId: string, logger: Logger) => string;
@@ -3,6 +3,7 @@ import type { Rspack } from '../types';
3
3
  export declare const removeLeadingSlash: (s: string) => string;
4
4
  export declare const removeTailingSlash: (s: string) => string;
5
5
  export declare const addTrailingSlash: (s: string) => string;
6
+ // Determine if the string is a URL
6
7
  export declare const isURL: (str: string) => boolean;
7
8
  export declare const urlJoin: (base: string, path: string) => string;
8
9
  export declare const ensureAssetPrefix: (url: string, assetPrefix?: Rspack.PublicPath) => string;
@@ -8,6 +8,5 @@ export declare const require: NodeJS.Require;
8
8
  * https://github.com/nodejs/node/issues/59913
9
9
  * @param name
10
10
  * @returns
11
- */
12
- export declare const requireCompiledPackage: <T extends keyof CompiledPackages>(name: T) => CompiledPackages[T];
13
- export {};
11
+ */ export declare const requireCompiledPackage: <T extends keyof CompiledPackages>(name: T) => CompiledPackages[T];
12
+ export { };
@@ -1,7 +1,6 @@
1
- export declare const rspackMinVersion = "2.0.0";
1
+ export declare const rspackMinVersion = '2.0.0';
2
2
  /**
3
3
  * If the application overrides the Rspack version to a lower one,
4
4
  * we should check that the Rspack version is greater than the minimum
5
5
  * supported version.
6
- */
7
- export declare const isSatisfyRspackVersion: (originalVersion: string) => boolean;
6
+ */ export declare const isSatisfyRspackVersion: (originalVersion: string) => boolean;
@@ -2,8 +2,7 @@ import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerCha
2
2
  export declare function createEnvironmentAsyncHook<Callback extends (...args: any[]) => any>(): EnvironmentAsyncHook<Callback>;
3
3
  export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
4
4
  export declare function initHooks(): {
5
- /** The following hooks are global hooks */
6
- onExit: AsyncHook<OnExitFn>;
5
+ /** The following hooks are global hooks */ onExit: AsyncHook<OnExitFn>;
7
6
  onAfterBuild: AsyncHook<OnAfterBuildFn>;
8
7
  onCloseBuild: AsyncHook<OnCloseBuildFn>;
9
8
  onBeforeBuild: AsyncHook<OnBeforeBuildFn>;
@@ -16,8 +15,7 @@ export declare function initHooks(): {
16
15
  onBeforeStartPreviewServer: AsyncHook<OnBeforeStartPreviewServerFn>;
17
16
  onAfterCreateCompiler: AsyncHook<OnAfterCreateCompilerFn>;
18
17
  onBeforeCreateCompiler: AsyncHook<OnBeforeCreateCompilerFn>;
19
- /** The following hooks are related to the environment */
20
- modifyHTML: EnvironmentAsyncHook<ModifyHTMLFn>;
18
+ /** The following hooks are related to the environment */ modifyHTML: EnvironmentAsyncHook<ModifyHTMLFn>;
21
19
  modifyHTMLTags: EnvironmentAsyncHook<ModifyHTMLTagsFn>;
22
20
  modifyRspackConfig: EnvironmentAsyncHook<ModifyRspackConfigFn>;
23
21
  modifyBundlerChain: EnvironmentAsyncHook<ModifyBundlerChainFn>;
@@ -27,16 +25,16 @@ export declare function initHooks(): {
27
25
  onAfterEnvironmentCompile: EnvironmentAsyncHook<OnAfterEnvironmentCompileFn>;
28
26
  };
29
27
  export type Hooks = ReturnType<typeof initHooks>;
30
- export declare const registerBuildHook: ({ context, isWatch, compiler, rspackConfigs, MultiStatsCtor, }: {
28
+ export declare const registerBuildHook: ({ context, isWatch, compiler, rspackConfigs, MultiStatsCtor }: {
31
29
  rspackConfigs: Rspack.Configuration[];
32
30
  context: InternalContext;
33
31
  compiler: Rspack.Compiler | Rspack.MultiCompiler;
34
32
  isWatch: boolean;
35
- MultiStatsCtor: new (stats: Rspack.Stats[]) => Rspack.MultiStats;
33
+ MultiStatsCtor: new(stats: Rspack.Stats[]) => Rspack.MultiStats;
36
34
  }) => void;
37
- export declare const registerDevHook: ({ context, compiler, bundlerConfigs, MultiStatsCtor, }: {
35
+ export declare const registerDevHook: ({ context, compiler, bundlerConfigs, MultiStatsCtor }: {
38
36
  bundlerConfigs: Rspack.Configuration[];
39
37
  context: InternalContext;
40
38
  compiler: Rspack.Compiler | Rspack.MultiCompiler;
41
- MultiStatsCtor: new (stats: Rspack.Stats[]) => Rspack.MultiStats;
39
+ MultiStatsCtor: new(stats: Rspack.Stats[]) => Rspack.MultiStats;
42
40
  }) => void;
@@ -1,23 +1,28 @@
1
1
  /**
2
2
  * The methods and types exported from this file are considered as
3
3
  * the public API of @rsbuild/core.
4
- */
5
- import type * as Rspack from '@rspack/core';
4
+ */ import type * as Rspack from '@rspack/core';
6
5
  import { rspack } from '@rspack/core';
7
6
  export { runCLI } from './cli';
8
7
  export { createRsbuild } from './createRsbuild';
9
- export { type ConfigParams, defineConfig, type LoadConfigOptions, type LoadConfigResult, loadConfig, } from './loadConfig';
8
+ export { type ConfigParams, defineConfig, type LoadConfigOptions, type LoadConfigResult, loadConfig } from './loadConfig';
9
+ // Core methods
10
10
  export { type LoadEnvOptions, type LoadEnvResult, loadEnv } from './loadEnv';
11
+ // Rsbuild version
11
12
  export declare const version: string;
13
+ // Rspack instance
12
14
  export { rspack };
13
15
  export type { Rspack };
14
16
  export type { ChainIdentifier } from './configChain';
17
+ // Constants
15
18
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME } from './constants';
16
19
  export { defaultAllowedOrigins } from './defaultConfig';
17
20
  export { ensureAssetPrefix } from './helpers/url';
21
+ // Helpers
18
22
  export { createLogger, type Logger, defaultLogger as logger } from './logger';
19
23
  export { mergeRsbuildConfig } from './mergeConfig';
20
24
  export type { RsbuildDevServer } from './server/devServer';
21
- export type { RsbuildServerBase, ServerStartResult, StartDevServerResult, StartPreviewServerResult, } from './server/helper';
25
+ export type { RsbuildServerBase, ServerStartResult, StartDevServerResult, StartPreviewServerResult } from './server/helper';
22
26
  export type { RsbuildPreviewServer } from './server/previewServer';
23
- export type { AliasStrategy, AppIcon, AppIconItem, AutoExternal, Build, BuildOptions, BuildResult, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, Connect, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, FilenameHash, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InitConfigsOptions, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedResolveConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedSplitChunksConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OverlayOptions, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolveConfig, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SourceMapExtract, SourceMapExtractOptions, SourceMapExtractTarget, SplitChunks, SplitChunksConfig, SplitChunksPreset, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
27
+ // Types
28
+ export type { AliasStrategy, AppIcon, AppIconItem, AutoExternal, AutoExternalExclude, Build, BuildOptions, BuildResult, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, Connect, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, FilenameHash, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InitConfigsOptions, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedResolveConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedSplitChunksConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OverlayOptions, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolveConfig, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SourceMapExtract, SourceMapExtractOptions, SourceMapExtractTarget, SplitChunks, SplitChunksConfig, SplitChunksPreset, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles } from './types';
@@ -12,8 +12,7 @@ export type InitConfigsOptions = {
12
12
  * 4. Initialize the configs for each environment
13
13
  * 5. Run all the `modifyEnvironmentConfig` hooks
14
14
  * 6. Validate the final Rsbuild config
15
- */
16
- export declare function initRsbuildConfig({ context, pluginManager, }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
17
- export declare function initConfigs({ context, pluginManager, rsbuildOptions, }: InitConfigsOptions): Promise<{
15
+ */ export declare function initRsbuildConfig({ context, pluginManager }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
16
+ export declare function initConfigs({ context, pluginManager, rsbuildOptions }: InitConfigsOptions): Promise<{
18
17
  rspackConfigs: Rspack.Configuration[];
19
18
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { Logger } from './logger';
2
2
  import type { InternalContext, NormalizedEnvironmentConfig, PluginManager, RsbuildPluginAPI } from './types';
3
3
  export declare function getHTMLPathByEntry(entryName: string, config: NormalizedEnvironmentConfig, logger: Logger): string;
4
- export declare function initPluginAPI({ context, pluginManager, }: {
4
+ export declare function initPluginAPI({ context, pluginManager }: {
5
5
  context: InternalContext;
6
6
  pluginManager: PluginManager;
7
7
  }): (environment?: string) => RsbuildPluginAPI;
@@ -1,7 +1,7 @@
1
1
  import type { InitConfigsOptions } from './initConfigs';
2
2
  import type { InspectConfigOptions, InspectConfigResult, Rspack } from './types';
3
3
  export declare function stringifyConfig(config: unknown, verbose?: boolean): string;
4
- export declare function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
4
+ export declare function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions }: InitConfigsOptions & {
5
5
  inspectOptions?: InspectConfigOptions;
6
6
  bundlerConfigs: Rspack.Configuration[];
7
7
  }): Promise<InspectConfigResult>;
@@ -10,51 +10,43 @@ export type RsbuildConfigSyncFn = (env: ConfigParams) => RsbuildConfig;
10
10
  export type RsbuildConfigExport = RsbuildConfig | RsbuildConfigSyncFn | RsbuildConfigAsyncFn;
11
11
  export type LoadConfigOptions = {
12
12
  /**
13
- * The root path to resolve the config file.
14
- * @default process.cwd()
15
- */
16
- cwd?: string;
13
+ * The root path to resolve the config file.
14
+ * @default process.cwd()
15
+ */ cwd?: string;
17
16
  /**
18
- * The path to the config file, can be a relative or absolute path.
19
- * If `path` is not provided, the function will search for the config file in the `cwd`.
20
- */
21
- path?: string;
17
+ * The path to the config file, can be a relative or absolute path.
18
+ * If `path` is not provided, the function will search for the config file in the `cwd`.
19
+ */ path?: string;
22
20
  /**
23
- * A custom meta object to be passed into the config function of `defineConfig`.
24
- */
25
- meta?: Record<string, unknown>;
21
+ * A custom meta object to be passed into the config function of `defineConfig`.
22
+ */ meta?: Record<string, unknown>;
26
23
  /**
27
- * The `envMode` passed into the config function of `defineConfig`.
28
- * @default process.env.NODE_ENV
29
- */
30
- envMode?: string;
24
+ * The `envMode` passed into the config function of `defineConfig`.
25
+ * @default process.env.NODE_ENV
26
+ */ envMode?: string;
31
27
  /**
32
- * Specify the config loader, can be `auto`, `jiti` or `native`.
33
- * - 'auto': Use native Node.js loader first, fallback to jiti if failed
34
- * - 'jiti': Use `jiti` as loader, which supports TypeScript and ESM out of the box
35
- * - 'native': Use native Node.js loader, requires TypeScript support in Node.js >= 22.6
36
- * @default 'auto'
37
- */
38
- loader?: ConfigLoader;
28
+ * Specify the config loader, can be `auto`, `jiti` or `native`.
29
+ * - 'auto': Use native Node.js loader first, fallback to jiti if failed
30
+ * - 'jiti': Use `jiti` as loader, which supports TypeScript and ESM out of the box
31
+ * - 'native': Use native Node.js loader, requires TypeScript support in Node.js >= 22.6
32
+ * @default 'auto'
33
+ */ loader?: ConfigLoader;
39
34
  };
40
35
  export type LoadConfigResult = {
41
36
  /**
42
- * The loaded configuration object.
43
- */
44
- content: RsbuildConfig;
37
+ * The loaded configuration object.
38
+ */ content: RsbuildConfig;
45
39
  /**
46
- * The path to the loaded configuration file.
47
- * Return `null` if the configuration file is not found.
48
- */
49
- filePath: string | null;
40
+ * The path to the loaded configuration file.
41
+ * Return `null` if the configuration file is not found.
42
+ */ filePath: string | null;
50
43
  };
51
44
  /**
52
45
  * This function helps you to autocomplete configuration types.
53
46
  * It accepts a Rsbuild config object, or a function that returns a config.
54
- */
55
- export declare function defineConfig(config: RsbuildConfig): RsbuildConfig;
47
+ */ export declare function defineConfig(config: RsbuildConfig): RsbuildConfig;
56
48
  export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfigSyncFn;
57
49
  export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
58
50
  export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
59
51
  export type ConfigLoader = 'auto' | 'jiti' | 'native';
60
- export declare function loadConfig({ cwd, path, envMode, meta, loader, }?: LoadConfigOptions): Promise<LoadConfigResult>;
52
+ export declare function loadConfig({ cwd, path, envMode, meta, loader }?: LoadConfigOptions): Promise<LoadConfigResult>;
@@ -1,63 +1,54 @@
1
1
  export type LoadEnvOptions = {
2
2
  /**
3
- * The root path to load the env file
4
- * @default process.cwd()
5
- */
6
- cwd?: string;
7
- /**
8
- * Used to specify the name of the .env.[mode] file
9
- * @default process.env.NODE_ENV
10
- */
11
- mode?: string;
12
- /**
13
- * The prefix of public variables
14
- * @default ['PUBLIC_']
15
- */
16
- prefixes?: string[];
17
- /**
18
- * Specify a target object to store environment variables.
19
- * If not provided, variables will be written to `process.env`.
20
- * @default process.env
21
- */
22
- processEnv?: Record<string, string>;
3
+ * The root path to load the env file
4
+ * @default process.cwd()
5
+ */ cwd?: string;
6
+ /**
7
+ * Used to specify the name of the .env.[mode] file
8
+ * @default process.env.NODE_ENV
9
+ */ mode?: string;
10
+ /**
11
+ * The prefix of public variables
12
+ * @default ['PUBLIC_']
13
+ */ prefixes?: string[];
14
+ /**
15
+ * Specify a target object to store environment variables.
16
+ * If not provided, variables will be written to `process.env`.
17
+ * @default process.env
18
+ */ processEnv?: Record<string, string>;
23
19
  };
24
20
  export type LoadEnvResult = {
25
21
  /**
26
- * All environment variables in the .env file
27
- */
28
- parsed: Record<string, string>;
29
- /**
30
- * The absolute paths to all env files
31
- */
32
- filePaths: string[];
33
- /**
34
- * Environment variables that start with prefixes.
35
- *
36
- * @example
37
- * ```ts
38
- * {
39
- * PUBLIC_FOO: 'bar',
40
- * }
41
- * ```
42
- **/
43
- rawPublicVars: Record<string, string | undefined>;
44
- /**
45
- * Formatted environment variables that start with prefixes.
46
- * The keys contain the prefixes `process.env.*` and `import.meta.env.*`.
47
- * The values are processed by `JSON.stringify`.
48
- *
49
- * @example
50
- * ```ts
51
- * {
52
- * 'process.env.PUBLIC_FOO': '"bar"',
53
- * 'import.meta.env.PUBLIC_FOO': '"bar"',
54
- * }
55
- * ```
56
- **/
57
- publicVars: Record<string, string>;
58
- /**
59
- * Clear the environment variables mounted on `process.env`
60
- */
61
- cleanup: () => void;
22
+ * All environment variables in the .env file
23
+ */ parsed: Record<string, string>;
24
+ /**
25
+ * The absolute paths to all env files
26
+ */ filePaths: string[];
27
+ /**
28
+ * Environment variables that start with prefixes.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * {
33
+ * PUBLIC_FOO: 'bar',
34
+ * }
35
+ * ```
36
+ **/ rawPublicVars: Record<string, string | undefined>;
37
+ /**
38
+ * Formatted environment variables that start with prefixes.
39
+ * The keys contain the prefixes `process.env.*` and `import.meta.env.*`.
40
+ * The values are processed by `JSON.stringify`.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * {
45
+ * 'process.env.PUBLIC_FOO': '"bar"',
46
+ * 'import.meta.env.PUBLIC_FOO': '"bar"',
47
+ * }
48
+ * ```
49
+ **/ publicVars: Record<string, string>;
50
+ /**
51
+ * Clear the environment variables mounted on `process.env`
52
+ */ cleanup: () => void;
62
53
  };
63
- export declare function loadEnv({ cwd, mode, prefixes, processEnv, }?: LoadEnvOptions): LoadEnvResult;
54
+ export declare function loadEnv({ cwd, mode, prefixes, processEnv }?: LoadEnvOptions): LoadEnvResult;
@@ -1,3 +1,4 @@
1
1
  import transform from './transformLoader';
2
2
  export default transform;
3
+ // make the loader to receive raw Buffer
3
4
  export declare const raw = true;
@@ -16,8 +16,7 @@
16
16
  *
17
17
  * This convention helps distinguish between normal operations
18
18
  * and important alerts that require attention.
19
- */
20
- import { createLogger as baseCreateLogger, type Logger, logger as defaultLogger } from '../compiled/rslog';
19
+ */ import { createLogger as baseCreateLogger, type Logger, logger as defaultLogger } from '../compiled/rslog';
21
20
  export declare const isDebug: () => boolean;
22
21
  export declare const isVerbose: (targetLogger: Pick<Logger, 'level'>) => boolean;
23
22
  export declare const createLogger: (...args: Parameters<typeof baseCreateLogger>) => ReturnType<typeof baseCreateLogger>;
@@ -4,5 +4,4 @@ import type { RsbuildConfig } from './types';
4
4
  *
5
5
  * This function returns a new merged configuration object and does not modify
6
6
  * the input configuration objects.
7
- */
8
- export declare const mergeRsbuildConfig: <T = RsbuildConfig>(...originalConfigs: (T | undefined)[]) => T;
7
+ */ export declare const mergeRsbuildConfig: <T = RsbuildConfig>(...originalConfigs: (T | undefined)[]) => T;
@@ -1,5 +1,4 @@
1
1
  /**
2
2
  * This file is used to get the global instance for html-plugin.
3
- */
4
- import type { HtmlRspackPlugin, NormalizedEnvironmentConfig } from './types';
3
+ */ import type { HtmlRspackPlugin, NormalizedEnvironmentConfig } from './types';
5
4
  export declare function getHTMLPlugin(config?: NormalizedEnvironmentConfig): typeof HtmlRspackPlugin;
@@ -3,20 +3,17 @@ import type { InternalContext, PluginManager, PluginMeta } from './types';
3
3
  /**
4
4
  * Determines whether the plugin is registered in the specified environment.
5
5
  * If the pluginEnvironment is undefined, it means it can match any environment.
6
- */
7
- export declare const isEnvironmentMatch: (pluginEnvironment?: string, specifiedEnvironment?: string) => boolean;
6
+ */ export declare const isEnvironmentMatch: (pluginEnvironment?: string, specifiedEnvironment?: string) => boolean;
8
7
  export declare function createPluginManager(logger: Logger): PluginManager;
9
8
  /**
10
9
  * Sorts plugins by their `enforce` property.
11
- */
12
- export declare const sortPluginsByEnforce: (plugins: PluginMeta[]) => PluginMeta[];
10
+ */ export declare const sortPluginsByEnforce: (plugins: PluginMeta[]) => PluginMeta[];
13
11
  /**
14
12
  * Performs topological sorting on plugins based on their dependencies.
15
13
  * Uses the `pre` and `post` properties of plugins to determine the correct
16
14
  * execution order.
17
- */
18
- export declare const sortPluginsByDependencies: (plugins: PluginMeta[]) => PluginMeta[];
19
- export declare function initPlugins({ context, pluginManager, }: {
15
+ */ export declare const sortPluginsByDependencies: (plugins: PluginMeta[]) => PluginMeta[];
16
+ export declare function initPlugins({ context, pluginManager }: {
20
17
  context: InternalContext;
21
18
  pluginManager: PluginManager;
22
19
  }): Promise<void>;