@rsbuild/core 2.0.8 → 2.0.10

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 (86) hide show
  1. package/compiled/connect-next/package.json +1 -1
  2. package/compiled/css-loader/index.js +2 -2
  3. package/compiled/html-rspack-plugin/index.js +14 -14
  4. package/compiled/html-rspack-plugin/package.json +1 -1
  5. package/compiled/postcss-loader/index.js +6 -6
  6. package/compiled/rslog/index.d.ts +3 -3
  7. package/compiled/rslog/package.json +1 -1
  8. package/compiled/rspack-chain/package.json +1 -1
  9. package/dist/1~rslib-runtime.js +8 -5
  10. package/dist/756.js +25 -21
  11. package/dist/launch-editor-middleware.js +58 -23
  12. package/dist/manifest-plugin.js +6 -6
  13. package/dist/memfs.js +101 -99
  14. package/dist/tinyglobby.js +11 -9
  15. package/dist-types/build.d.ts +1 -1
  16. package/dist-types/cli/init.d.ts +1 -1
  17. package/dist-types/configChain.d.ts +59 -118
  18. package/dist-types/constants.d.ts +35 -31
  19. package/dist-types/createContext.d.ts +1 -2
  20. package/dist-types/createRsbuild.d.ts +1 -2
  21. package/dist-types/defaultConfig.d.ts +2 -4
  22. package/dist-types/helpers/exitHook.d.ts +1 -1
  23. package/dist-types/helpers/format.d.ts +2 -1
  24. package/dist-types/helpers/fs.d.ts +2 -4
  25. package/dist-types/helpers/index.d.ts +1 -2
  26. package/dist-types/helpers/path.d.ts +4 -8
  27. package/dist-types/helpers/stats.d.ts +3 -5
  28. package/dist-types/helpers/url.d.ts +1 -0
  29. package/dist-types/helpers/vendors.d.ts +2 -3
  30. package/dist-types/helpers/version.d.ts +2 -3
  31. package/dist-types/hooks.d.ts +6 -8
  32. package/dist-types/index.d.ts +10 -5
  33. package/dist-types/initConfigs.d.ts +2 -3
  34. package/dist-types/initPlugins.d.ts +1 -1
  35. package/dist-types/inspectConfig.d.ts +1 -1
  36. package/dist-types/loadConfig.d.ts +24 -32
  37. package/dist-types/loadEnv.d.ts +48 -57
  38. package/dist-types/loader/transformRawLoader.d.ts +1 -0
  39. package/dist-types/logger.d.ts +1 -2
  40. package/dist-types/mergeConfig.d.ts +1 -2
  41. package/dist-types/pluginHelper.d.ts +1 -2
  42. package/dist-types/pluginManager.d.ts +4 -7
  43. package/dist-types/plugins/basic.d.ts +1 -2
  44. package/dist-types/plugins/css.d.ts +4 -0
  45. package/dist-types/plugins/fileSize.d.ts +6 -5
  46. package/dist-types/plugins/rspackProfile.d.ts +2 -0
  47. package/dist-types/plugins/server.d.ts +1 -0
  48. package/dist-types/plugins/swc.d.ts +1 -2
  49. package/dist-types/restart.d.ts +4 -5
  50. package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +2 -3
  51. package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +2 -3
  52. package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +3 -4
  53. package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +1 -2
  54. package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +2 -3
  55. package/dist-types/rspackConfig.d.ts +1 -1
  56. package/dist-types/server/ansiHTML.d.ts +1 -2
  57. package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +1 -2
  58. package/dist-types/server/assets-middleware/index.d.ts +3 -5
  59. package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +1 -2
  60. package/dist-types/server/browserLogs.d.ts +1 -2
  61. package/dist-types/server/buildManager.d.ts +4 -6
  62. package/dist-types/server/cliShortcuts.d.ts +3 -1
  63. package/dist-types/server/devMiddlewares.d.ts +2 -3
  64. package/dist-types/server/devServer.d.ts +18 -23
  65. package/dist-types/server/gracefulShutdown.d.ts +2 -4
  66. package/dist-types/server/gzipMiddleware.d.ts +1 -1
  67. package/dist-types/server/helper.d.ts +36 -45
  68. package/dist-types/server/historyApiFallback.d.ts +8 -1
  69. package/dist-types/server/httpServer.d.ts +1 -1
  70. package/dist-types/server/middlewares.d.ts +4 -8
  71. package/dist-types/server/open.d.ts +1 -1
  72. package/dist-types/server/runner/basic.d.ts +4 -5
  73. package/dist-types/server/runner/index.d.ts +3 -1
  74. package/dist-types/server/socketServer.d.ts +24 -18
  75. package/dist-types/server/watchFiles.d.ts +1 -1
  76. package/dist-types/types/config.d.ts +1192 -1465
  77. package/dist-types/types/context.d.ts +63 -92
  78. package/dist-types/types/hooks.d.ts +106 -150
  79. package/dist-types/types/plugin.d.ts +359 -444
  80. package/dist-types/types/rsbuild.d.ts +156 -191
  81. package/dist-types/types/thirdParty.d.ts +101 -132
  82. package/dist-types/types/utils.d.ts +2 -5
  83. package/package.json +13 -13
  84. package/dist-types/client/hmr.d.ts +0 -3
  85. package/dist-types/client/log.d.ts +0 -13
  86. package/dist-types/client/overlay.d.ts +0 -1
@@ -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>;
@@ -1,5 +1,4 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
2
  /**
3
3
  * Set some basic Rspack configs
4
- */
5
- export declare const pluginBasic: () => RsbuildPlugin;
4
+ */ export declare const pluginBasic: () => RsbuildPlugin;
@@ -1,4 +1,8 @@
1
1
  import type { CSSLoaderOptions, NormalizedEnvironmentConfig, RsbuildPlugin, Rspack } from '../types';
2
2
  export declare function getLightningCSSLoaderOptions(config: NormalizedEnvironmentConfig, targets: string[], minify: boolean): Promise<Rspack.LightningcssLoaderOptions>;
3
+ // If the target is not `web` and the modules option of css-loader is enabled,
4
+ // we must enable exportOnlyLocals to only exports the modules identifier mappings.
5
+ // Otherwise, the compiled CSS code may contain invalid code, such as `new URL`.
6
+ // https://github.com/webpack/css-loader#exportonlylocals
3
7
  export declare const normalizeCssLoaderOptions: (options: CSSLoaderOptions, exportOnlyLocals: boolean) => CSSLoaderOptions;
4
8
  export declare const pluginCss: () => RsbuildPlugin;
@@ -1,6 +1,7 @@
1
- import type { InternalContext, PrintFileSizeAsset, RsbuildPlugin } from '../types';
2
- /** Normalize file path by removing hash for comparison across builds */
3
- export declare function normalizeFilePath(filePath: string): string;
4
- /** Exclude source map and license files by default */
5
- export declare const excludeAsset: (asset: PrintFileSizeAsset) => boolean;
1
+ /**
2
+ * modified from https://github.com/facebook/create-react-app
3
+ * license at https://github.com/facebook/create-react-app/blob/master/LICENSE
4
+ */ import type { InternalContext, PrintFileSizeAsset, RsbuildPlugin } from '../types';
5
+ /** Normalize file path by removing hash for comparison across builds */ export declare function normalizeFilePath(filePath: string): string;
6
+ /** Exclude source map and license files by default */ export declare const excludeAsset: (asset: PrintFileSizeAsset) => boolean;
6
7
  export declare const pluginFileSize: (context: InternalContext) => RsbuildPlugin;
@@ -1,2 +1,4 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
+ // Referenced from Rspack CLI
3
+ // https://github.com/web-infra-dev/rspack/blob/main/packages/rspack-cli/src/utils/profile.ts
2
4
  export declare const pluginRspackProfile: () => RsbuildPlugin;
@@ -1,2 +1,3 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
+ // For Rsbuild server config
2
3
  export declare const pluginServer: () => RsbuildPlugin;
@@ -1,5 +1,4 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
2
  /**
3
3
  * Provide some SWC configs of Rspack
4
- */
5
- export declare const pluginSwc: () => RsbuildPlugin;
4
+ */ export declare const pluginSwc: () => RsbuildPlugin;
@@ -4,17 +4,16 @@ import type { RsbuildInstance } from './types';
4
4
  type Cleaner = () => unknown;
5
5
  /**
6
6
  * Add a cleaner to handle side effects
7
- */
8
- export declare const onBeforeRestartServer: (cleaner: Cleaner) => void;
9
- export declare const restartDevServer: ({ filePath, clear, logger, }: {
7
+ */ export declare const onBeforeRestartServer: (cleaner: Cleaner) => void;
8
+ export declare const restartDevServer: ({ filePath, clear, logger }: {
10
9
  filePath?: string;
11
10
  clear?: boolean;
12
11
  logger: Logger;
13
12
  }) => Promise<boolean>;
14
- export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions, }: {
13
+ export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions }: {
15
14
  files: string[];
16
15
  rsbuild: RsbuildInstance;
17
16
  isBuildWatch: boolean;
18
17
  watchOptions?: ChokidarOptions;
19
18
  }): Promise<void>;
20
- export {};
19
+ export { };
@@ -9,8 +9,7 @@ export type TagConfig = {
9
9
  };
10
10
  /**
11
11
  * A unique identifier for providing extra data to RsbuildHtmlPlugin
12
- */
13
- export declare const entryNameSymbol: unique symbol;
12
+ */ export declare const entryNameSymbol: unique symbol;
14
13
  export type HtmlExtraData = {
15
14
  entryName: string;
16
15
  context: InternalContext;
@@ -35,4 +34,4 @@ export declare class RsbuildHtmlPlugin {
35
34
  constructor(getExtraData: (entryName: string) => HtmlExtraData | undefined, getHTMLPlugin: () => typeof HtmlRspackPlugin);
36
35
  apply(compiler: Compiler): void;
37
36
  }
38
- export {};
37
+ export { };
@@ -14,8 +14,7 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */
18
- import type { Compiler, RspackPluginInstance } from '@rspack/core';
17
+ */ import type { Compiler, RspackPluginInstance } from '@rspack/core';
19
18
  import type { HtmlRspackPlugin, ResourceHintsOptions } from '../../types';
20
19
  type LinkType = 'preload' | 'prefetch';
21
20
  export declare class HtmlResourceHintsPlugin implements RspackPluginInstance {
@@ -29,4 +28,4 @@ export declare class HtmlResourceHintsPlugin implements RspackPluginInstance {
29
28
  constructor(options: ResourceHintsOptions, type: LinkType, HTMLCount: number, isDev: boolean, getHTMLPlugin: () => typeof HtmlRspackPlugin);
30
29
  apply(compiler: Compiler): void;
31
30
  }
32
- export {};
31
+ export { };
@@ -14,8 +14,7 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */
18
- import type { Chunk, Compilation } from '@rspack/core';
17
+ */ import type { Chunk, Compilation } from '@rspack/core';
19
18
  import type { HtmlRspackPlugin, ResourceHintsOptions } from '../../types';
20
19
  interface DoesChunkBelongToHtmlOptions {
21
20
  chunk: Chunk;
@@ -24,5 +23,5 @@ interface DoesChunkBelongToHtmlOptions {
24
23
  pluginOptions?: ResourceHintsOptions;
25
24
  }
26
25
  export declare function recursiveChunkEntryNames(chunk: Chunk): string[];
27
- export declare function doesChunkBelongToHtml({ chunk, htmlPluginData, }: DoesChunkBelongToHtmlOptions): boolean;
28
- export {};
26
+ export declare function doesChunkBelongToHtml({ chunk, htmlPluginData }: DoesChunkBelongToHtmlOptions): boolean;
27
+ export { };
@@ -14,8 +14,7 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */
18
- import type { Chunk, Compilation } from '@rspack/core';
17
+ */ import type { Chunk, Compilation } from '@rspack/core';
19
18
  import type { ResourceHintsIncludeType } from '../../types';
20
19
  export declare function extractChunks(compilation: Compilation, includeType?: ResourceHintsIncludeType): Chunk[] | {
21
20
  files: string[];
@@ -14,9 +14,8 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */
18
- export type ResourceType = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
19
- export declare function getResourceType({ href, file, }: {
17
+ */ export type ResourceType = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
18
+ export declare function getResourceType({ href, file }: {
20
19
  href: string;
21
20
  file: string;
22
21
  }): ResourceType;
@@ -1,7 +1,7 @@
1
1
  import type { EnvironmentContext, InternalContext, ModifyChainUtils, ModifyRspackConfigUtils, RsbuildTarget, Rspack } from './types';
2
2
  export declare function getConfigUtils(getCurrentConfig: () => Rspack.Configuration, chainUtils: ModifyChainUtils): ModifyRspackConfigUtils;
3
3
  export declare function getChainUtils(target: RsbuildTarget, environment: EnvironmentContext, environments: Record<string, EnvironmentContext>): ModifyChainUtils;
4
- export declare function generateRspackConfig({ target, context, environmentName, }: {
4
+ export declare function generateRspackConfig({ target, context, environmentName }: {
5
5
  target: RsbuildTarget;
6
6
  context: InternalContext;
7
7
  environmentName: string;
@@ -1,4 +1,3 @@
1
1
  /**
2
2
  * Converts text with ANSI color codes to HTML markup
3
- */
4
- export declare function ansiHTML(text: string): string;
3
+ */ export declare function ansiHTML(text: string): string;
@@ -3,8 +3,7 @@ import type { InternalContext, Rspack } from '../../types';
3
3
  /**
4
4
  * Resolves URL to file path with security checks and retrieves file from
5
5
  * the build output directories.
6
- */
7
- export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.OutputFileSystem, context: InternalContext): Promise<{
6
+ */ export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.OutputFileSystem, context: InternalContext): Promise<{
8
7
  filename: string;
9
8
  fsStats: FSStats;
10
9
  } | {
@@ -5,8 +5,7 @@
5
5
  * MIT Licensed
6
6
  * Copyright JS Foundation and other contributors
7
7
  * https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
8
- */
9
- import { type Compiler, type MultiCompiler } from '@rspack/core';
8
+ */ import { type Compiler, type MultiCompiler } from '@rspack/core';
10
9
  import type { InternalContext, LiveReload, NormalizedConfig, RequestHandler } from '../../types';
11
10
  import type { SocketServer } from '../socketServer';
12
11
  export type MultiWatching = ReturnType<MultiCompiler['watch']>;
@@ -16,7 +15,7 @@ export type AssetsMiddleware = RequestHandler & {
16
15
  close: AssetsMiddlewareClose;
17
16
  };
18
17
  export declare const isClientCompiler: (compiler: Compiler) => boolean;
19
- export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload, }: {
18
+ export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload }: {
20
19
  context: InternalContext;
21
20
  compiler: Compiler;
22
21
  token: string;
@@ -28,8 +27,7 @@ export declare const setupServerHooks: ({ context, compiler, token, socketServer
28
27
  * - Call `compiler.watch`
29
28
  * - Inject the HMR client path into page
30
29
  * - Notify server when compiler hooks are triggered
31
- */
32
- export declare const assetsMiddleware: ({ config, compiler, context, socketServer, resolvedPort, }: {
30
+ */ export declare const assetsMiddleware: ({ config, compiler, context, socketServer, resolvedPort }: {
33
31
  config: NormalizedConfig;
34
32
  compiler: Compiler | MultiCompiler;
35
33
  context: InternalContext;
@@ -11,6 +11,5 @@ export type ResolvedWriteToDisk = boolean | ((filePath: string, name?: string) =
11
11
  * Resolve writeToDisk config across multiple environments.
12
12
  * Returns the unified config if all environments have the same value,
13
13
  * otherwise returns a function that resolves config based on compilation.
14
- */
15
- export declare const resolveWriteToDiskConfig: (config: NormalizedDevConfig, environments: Record<string, EnvironmentContext>, environmentList: EnvironmentContext[]) => ResolvedWriteToDisk;
14
+ */ export declare const resolveWriteToDiskConfig: (config: NormalizedDevConfig, environments: Record<string, EnvironmentContext>, environmentList: EnvironmentContext[]) => ResolvedWriteToDisk;
16
15
  export declare function setupWriteToDisk(compilers: Compiler[], writeToDisk: ResolvedWriteToDisk, logger: Logger): void;
@@ -5,5 +5,4 @@ export type CachedTraceMap = Map<string, TraceMap>;
5
5
  /**
6
6
  * Formats error messages received from the browser into a log string with
7
7
  * source location information.
8
- */
9
- export declare const formatBrowserErrorLog: (message: string, context: InternalContext, fs: Rspack.OutputFileSystem, stackTrace: BrowserLogsStackTrace, stackFrames: StackFrame[] | null, cachedTraceMap: CachedTraceMap) => Promise<string>;
8
+ */ export declare const formatBrowserErrorLog: (message: string, context: InternalContext, fs: Rspack.OutputFileSystem, stackTrace: BrowserLogsStackTrace, stackFrames: StackFrame[] | null, cachedTraceMap: CachedTraceMap) => Promise<string>;
@@ -11,8 +11,7 @@ type Options = {
11
11
  * Setup compiler related logic:
12
12
  * 1. setup assets middleware
13
13
  * 2. establish webSocket connect
14
- */
15
- export declare class BuildManager {
14
+ */ export declare class BuildManager {
16
15
  assetsMiddleware: AssetsMiddleware;
17
16
  outputFileSystem: Rspack.OutputFileSystem;
18
17
  socketServer: SocketServer;
@@ -23,11 +22,10 @@ export declare class BuildManager {
23
22
  constructor({ config, context, compiler, resolvedPort }: Options);
24
23
  init(): Promise<void>;
25
24
  /**
26
- * Call `compiler.watch()` to start compiling.
27
- */
28
- watch(): void;
25
+ * Call `compiler.watch()` to start compiling.
26
+ */ watch(): void;
29
27
  close(): Promise<void>;
30
28
  readFileSync: (fileName: string) => string;
31
29
  private setupCompilationMiddleware;
32
30
  }
33
- export {};
31
+ export { };
@@ -1,8 +1,10 @@
1
1
  import type { Logger } from '../logger';
2
2
  import type { CliShortcut, NormalizedConfig } from '../types/config';
3
3
  export declare const isCliShortcutsEnabled: (config: NormalizedConfig) => boolean;
4
+ // Normalize user input so shortcuts are case-insensitive
5
+ // and still work with accidental surrounding whitespace.
4
6
  export declare const normalizeShortcutInput: (input: string) => string;
5
- export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger, }: {
7
+ export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger }: {
6
8
  help?: boolean | string;
7
9
  openPage: () => Promise<void>;
8
10
  closeServer: () => Promise<void>;
@@ -8,9 +8,8 @@ export type RsbuildDevMiddlewareOptions = {
8
8
  buildManager?: BuildManager;
9
9
  devServer: RsbuildDevServer;
10
10
  /**
11
- * Callbacks returned by `onBeforeStartDevServer` hook and `server.setup` config
12
- */
13
- postCallbacks: (() => Promise<void> | void)[];
11
+ * Callbacks returned by `onBeforeStartDevServer` hook and `server.setup` config
12
+ */ postCallbacks: (() => Promise<void> | void)[];
14
13
  };
15
14
  export type GetDevMiddlewaresResult = {
16
15
  close: () => Promise<void>;
@@ -12,36 +12,31 @@ type ExtractSocketMessageData<T extends ServerMessage['type']> = 'data' extends
12
12
  export type HotSend = <T extends ServerMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
13
13
  export type RsbuildDevServer = RsbuildServerBase & {
14
14
  /**
15
- * Notifies Rsbuild that the custom server has successfully started.
16
- * Rsbuild will trigger the `onAfterStartDevServer` hook at this stage.
17
- */
18
- afterListen: () => Promise<void>;
15
+ * Notifies Rsbuild that the custom server has successfully started.
16
+ * Rsbuild will trigger the `onAfterStartDevServer` hook at this stage.
17
+ */ afterListen: () => Promise<void>;
19
18
  /**
20
- * Activate socket connection.
21
- * This ensures that HMR works properly.
22
- */
23
- connectWebSocket: (options: {
19
+ * Activate socket connection.
20
+ * This ensures that HMR works properly.
21
+ */ connectWebSocket: (options: {
24
22
  server: HTTPServer;
25
23
  }) => void;
26
24
  /**
27
- * Environment API of Rsbuild server.
28
- */
29
- environments: EnvironmentAPI;
25
+ * Environment API of Rsbuild server.
26
+ */ environments: EnvironmentAPI;
30
27
  /**
31
- * Start listening on the Rsbuild dev server.
32
- * Do not call this method if you are using a custom server.
33
- */
34
- listen: () => Promise<StartDevServerResult>;
28
+ * Start listening on the Rsbuild dev server.
29
+ * Do not call this method if you are using a custom server.
30
+ */ listen: () => Promise<StartDevServerResult>;
35
31
  /**
36
- * Allows middleware to send some message to HMR client, and then the HMR
37
- * client will take different actions depending on the message type.
38
- * - `full-reload`: The page will reload.
39
- * - `static-changed`: Alias of `full-reload` for backward compatibility.
40
- * - `custom`: Send custom messages via `custom` type with optional data to the browser and handle them via HMR events.
41
- */
42
- sockWrite: HotSend;
32
+ * Allows middleware to send some message to HMR client, and then the HMR
33
+ * client will take different actions depending on the message type.
34
+ * - `full-reload`: The page will reload.
35
+ * - `static-changed`: Alias of `full-reload` for backward compatibility.
36
+ * - `custom`: Send custom messages via `custom` type with optional data to the browser and handle them via HMR events.
37
+ */ sockWrite: HotSend;
43
38
  };
44
39
  export declare function createDevServer<Options extends {
45
40
  context: InternalContext;
46
41
  }>(options: Options, createCompiler: CreateCompiler, config: NormalizedConfig, { getPortSilently, runCompile }?: CreateDevServerOptions): Promise<RsbuildDevServer>;
47
- export {};
42
+ export { };
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Registers a cleanup callback to be executed before process termination
3
- */
4
- export declare const registerCleanup: (callback: () => Promise<void>) => void;
3
+ */ export declare const registerCleanup: (callback: () => Promise<void>) => void;
5
4
  export declare const removeCleanup: (callback: () => Promise<void>) => void;
6
5
  /**
7
6
  * Sets up listeners for termination signals and stdin end event
8
7
  * This should be called once during application initialization
9
- */
10
- export declare const setupGracefulShutdown: () => (() => void);
8
+ */ export declare const setupGracefulShutdown: () => (() => void);
@@ -1,2 +1,2 @@
1
1
  import type { CompressOptions, RequestHandler } from '../types';
2
- export declare function gzipMiddleware({ filter, level, }?: CompressOptions): RequestHandler;
2
+ export declare function gzipMiddleware({ filter, level }?: CompressOptions): RequestHandler;