@rsbuild/core 1.0.10 → 1.0.11
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.
- package/dist/index.cjs +421 -266
- package/dist/index.js +415 -259
- package/dist-types/config.d.ts +1 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/server/cliShortcuts.d.ts +9 -0
- package/dist-types/server/helper.d.ts +2 -1
- package/dist-types/server/prodServer.d.ts +2 -2
- package/dist-types/server/restart.d.ts +3 -2
- package/dist-types/types/config.d.ts +27 -2
- package/dist-types/types/rsbuild.d.ts +19 -6
- package/package.json +1 -1
package/dist-types/config.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function defineConfig(config: RsbuildConfig): RsbuildConfig;
|
|
|
24
24
|
export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfigSyncFn;
|
|
25
25
|
export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
|
|
26
26
|
export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function watchFilesForRestart(files: string[], watchOptions?: WatchOptions): Promise<void>;
|
|
28
28
|
export declare function loadConfig({ cwd, path, envMode, }?: {
|
|
29
29
|
cwd?: string;
|
|
30
30
|
path?: string;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { logger } from './logger';
|
|
|
15
15
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
16
16
|
export { ensureAssetPrefix } from './helpers';
|
|
17
17
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME } from './constants';
|
|
18
|
-
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, CacheGroup, CacheGroups, Charset, ClientConfig, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler,
|
|
18
|
+
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, CacheGroup, CacheGroups, Charset, ClientConfig, CliShortcut, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentContext, EnvironmentConfig, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlConfig, HtmlRspackPlugin, HtmlBasicTag, HtmlFallback, HtmlTagHandler, HtmlTagDescriptor, HtmlTagContext, InspectConfigOptions, InspectConfigResult, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, LegalComments, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyRsbuildConfigFn, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigUtils, ModuleFederationConfig, MergedEnvironmentConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProxyConfig, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildTarget, RspackChain, RspackRule, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, ToolsConfig, TransformFn, TransformHandler, TransformImport, WatchFiles, } from './types';
|
|
19
19
|
export type { ChainIdentifier } from './configChain';
|
|
20
20
|
export {
|
|
21
21
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CliShortcut, NormalizedDevConfig } from '../types/config';
|
|
2
|
+
export declare const isCliShortcutsEnabled: (devConfig: NormalizedDevConfig) => boolean;
|
|
3
|
+
export declare function setupCliShortcuts({ openPage, closeServer, printUrls, restartServer, customShortcuts, }: {
|
|
4
|
+
openPage: () => Promise<void>;
|
|
5
|
+
closeServer: () => Promise<void>;
|
|
6
|
+
printUrls: () => void;
|
|
7
|
+
restartServer?: () => Promise<void>;
|
|
8
|
+
customShortcuts?: (shortcuts: CliShortcut[]) => CliShortcut[];
|
|
9
|
+
}): void;
|
|
@@ -18,7 +18,7 @@ export declare const joinUrlSegments: (s1: string, s2: string) => string;
|
|
|
18
18
|
export declare const stripBase: (path: string, base: string) => string;
|
|
19
19
|
export declare const getRoutes: (context: InternalContext) => Routes;
|
|
20
20
|
export declare const formatRoutes: (entry: RsbuildEntry, base: string, distPathPrefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
|
|
21
|
-
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, }: {
|
|
21
|
+
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak, }: {
|
|
22
22
|
urls: Array<{
|
|
23
23
|
url: string;
|
|
24
24
|
label: string;
|
|
@@ -27,6 +27,7 @@ export declare function printServerURLs({ urls: originalUrls, port, routes, prot
|
|
|
27
27
|
routes: Routes;
|
|
28
28
|
protocol: string;
|
|
29
29
|
printUrls?: PrintUrls;
|
|
30
|
+
trailingLineBreak?: boolean;
|
|
30
31
|
}): string | null;
|
|
31
32
|
/**
|
|
32
33
|
* Get available free port.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
3
|
import type Connect from '../../compiled/connect';
|
|
4
|
-
import type { InternalContext, NormalizedConfig,
|
|
4
|
+
import type { InternalContext, NormalizedConfig, PreviewOptions, ServerConfig } from '../types';
|
|
5
5
|
import { type StartServerResult } from './helper';
|
|
6
6
|
type RsbuildProdServerOptions = {
|
|
7
7
|
pwd: string;
|
|
@@ -21,5 +21,5 @@ export declare class RsbuildProdServer {
|
|
|
21
21
|
private applyStaticAssetMiddleware;
|
|
22
22
|
close(): Promise<void>;
|
|
23
23
|
}
|
|
24
|
-
export declare function startProdServer(context: InternalContext, config: NormalizedConfig, { getPortSilently }?:
|
|
24
|
+
export declare function startProdServer(context: InternalContext, config: NormalizedConfig, { getPortSilently }?: PreviewOptions): Promise<StartServerResult>;
|
|
25
25
|
export {};
|
|
@@ -3,7 +3,8 @@ type Cleaner = () => Promise<unknown> | unknown;
|
|
|
3
3
|
* Add a cleaner to handle side effects
|
|
4
4
|
*/
|
|
5
5
|
export declare const onBeforeRestartServer: (cleaner: Cleaner) => void;
|
|
6
|
-
export declare const restartDevServer: ({ filePath, }
|
|
7
|
-
filePath
|
|
6
|
+
export declare const restartDevServer: ({ filePath, clear, }?: {
|
|
7
|
+
filePath?: string;
|
|
8
|
+
clear?: boolean;
|
|
8
9
|
}) => Promise<void>;
|
|
9
10
|
export {};
|
|
@@ -939,6 +939,20 @@ export type WatchFiles = {
|
|
|
939
939
|
options?: WatchOptions;
|
|
940
940
|
type?: 'reload-page' | 'reload-server';
|
|
941
941
|
};
|
|
942
|
+
export type CliShortcut = {
|
|
943
|
+
/**
|
|
944
|
+
* The key to trigger the shortcut.
|
|
945
|
+
*/
|
|
946
|
+
key: string;
|
|
947
|
+
/**
|
|
948
|
+
* The description of the shortcut.
|
|
949
|
+
*/
|
|
950
|
+
description: string;
|
|
951
|
+
/**
|
|
952
|
+
* The action to execute when the shortcut is triggered.
|
|
953
|
+
*/
|
|
954
|
+
action: () => void | Promise<void>;
|
|
955
|
+
};
|
|
942
956
|
export interface DevConfig {
|
|
943
957
|
/**
|
|
944
958
|
* Whether to enable Hot Module Replacement.
|
|
@@ -961,6 +975,17 @@ export interface DevConfig {
|
|
|
961
975
|
* Config for Rsbuild client code.
|
|
962
976
|
*/
|
|
963
977
|
client?: ClientConfig;
|
|
978
|
+
/**
|
|
979
|
+
* Whether to enable CLI shortcuts.
|
|
980
|
+
*/
|
|
981
|
+
cliShortcuts?: boolean | {
|
|
982
|
+
/**
|
|
983
|
+
* Customize the CLI shortcuts.
|
|
984
|
+
* @param shortcuts - The default CLI shortcuts.
|
|
985
|
+
* @returns - The customized CLI shortcuts.
|
|
986
|
+
*/
|
|
987
|
+
custom?: (shortcuts?: CliShortcut[]) => CliShortcut[];
|
|
988
|
+
};
|
|
964
989
|
/**
|
|
965
990
|
* Provides the ability to execute a custom function and apply custom middlewares.
|
|
966
991
|
*/
|
|
@@ -973,14 +998,14 @@ export interface DevConfig {
|
|
|
973
998
|
/**
|
|
974
999
|
* This option allows you to configure a list of globs/directories/files to watch for file changes.
|
|
975
1000
|
*/
|
|
976
|
-
watchFiles?: WatchFiles;
|
|
1001
|
+
watchFiles?: WatchFiles | WatchFiles[];
|
|
977
1002
|
/**
|
|
978
1003
|
* Enable lazy compilation.
|
|
979
1004
|
* @default false
|
|
980
1005
|
*/
|
|
981
1006
|
lazyCompilation?: boolean | Rspack.LazyCompilationOptions;
|
|
982
1007
|
}
|
|
983
|
-
export type NormalizedDevConfig = DevConfig & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk'>> & {
|
|
1008
|
+
export type NormalizedDevConfig = DevConfig & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts'>> & {
|
|
984
1009
|
client: NormalizedClientConfig;
|
|
985
1010
|
};
|
|
986
1011
|
export type ModuleFederationConfig = {
|
|
@@ -8,11 +8,15 @@ import type { PluginManager, RsbuildPluginAPI } from './plugin';
|
|
|
8
8
|
import type { Rspack } from './rspack';
|
|
9
9
|
import type { WebpackConfig } from './thirdParty';
|
|
10
10
|
export type Bundler = 'rspack' | 'webpack';
|
|
11
|
-
export type CreateCompilerOptions = {
|
|
12
|
-
watch?: boolean;
|
|
13
|
-
};
|
|
14
11
|
export type StartDevServerOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* Using a custom Rspack Compiler object.
|
|
14
|
+
*/
|
|
15
15
|
compiler?: Compiler | MultiCompiler;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to get port silently and not print any logs.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
16
20
|
getPortSilently?: boolean;
|
|
17
21
|
};
|
|
18
22
|
export type CreateDevServerOptions = StartDevServerOptions & {
|
|
@@ -23,8 +27,17 @@ export type CreateDevServerOptions = StartDevServerOptions & {
|
|
|
23
27
|
*/
|
|
24
28
|
runCompile?: boolean;
|
|
25
29
|
};
|
|
26
|
-
export type
|
|
30
|
+
export type PreviewOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* Whether to get port silently and not print any logs.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
27
35
|
getPortSilently?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to check if the dist directory exists and is not empty.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
checkDistDir?: boolean;
|
|
28
41
|
};
|
|
29
42
|
export type BuildOptions = {
|
|
30
43
|
/**
|
|
@@ -67,7 +80,7 @@ export type InspectConfigResult<B extends 'rspack' | 'webpack' = 'rspack'> = {
|
|
|
67
80
|
bundlerConfigs: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
|
|
68
81
|
};
|
|
69
82
|
};
|
|
70
|
-
export type CreateCompiler = <C = Compiler | MultiCompiler>(
|
|
83
|
+
export type CreateCompiler = <C = Compiler | MultiCompiler>() => Promise<C>;
|
|
71
84
|
export type CreateRsbuildOptions = {
|
|
72
85
|
/** The root path of current project. */
|
|
73
86
|
cwd?: string;
|
|
@@ -104,7 +117,7 @@ export type RsbuildInstance = {
|
|
|
104
117
|
removePlugins: PluginManager['removePlugins'];
|
|
105
118
|
isPluginExists: PluginManager['isPluginExists'];
|
|
106
119
|
build: ProviderInstance['build'];
|
|
107
|
-
preview: (options?:
|
|
120
|
+
preview: (options?: PreviewOptions) => Promise<StartServerResult>;
|
|
108
121
|
initConfigs: ProviderInstance['initConfigs'];
|
|
109
122
|
inspectConfig: ProviderInstance['inspectConfig'];
|
|
110
123
|
createCompiler: ProviderInstance['createCompiler'];
|