@rsbuild/core 1.3.20 → 1.3.22
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/compiled/css-loader/index.js +18 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/style-loader/index.js +10 -10
- package/compiled/tinyglobby/index.d.ts +35 -16
- package/compiled/tinyglobby/index.js +417 -439
- package/compiled/tinyglobby/package.json +1 -1
- package/dist/client/hmr.js +15 -12
- package/dist/index.cjs +384 -336
- package/dist/index.js +339 -323
- package/dist-types/cli/commands.d.ts +1 -1
- package/dist-types/defaultConfig.d.ts +26 -0
- package/dist-types/helpers/index.d.ts +7 -1
- package/dist-types/helpers/path.d.ts +2 -3
- package/dist-types/index.d.ts +2 -2
- package/dist-types/inspectConfig.d.ts +35 -0
- package/dist-types/{config.d.ts → loadConfig.d.ts} +9 -62
- package/dist-types/pluginHelper.d.ts +1 -1
- package/dist-types/plugins/minimize.d.ts +1 -1
- package/dist-types/provider/helpers.d.ts +1 -1
- package/dist-types/provider/initConfigs.d.ts +9 -0
- package/dist-types/server/cliShortcuts.d.ts +2 -2
- package/dist-types/server/helper.d.ts +2 -2
- package/dist-types/server/runner/asModule.d.ts +2 -2
- package/dist-types/types/config.d.ts +24 -14
- package/dist-types/types/context.d.ts +20 -1
- package/dist-types/types/plugin.d.ts +1 -1
- package/dist-types/types/utils.d.ts +7 -2
- package/package.json +6 -6
- package/dist-types/provider/inspectConfig.d.ts +0 -6
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NormalizedConfig, PublicDir, PublicDirOptions, RsbuildConfig, RsbuildEntry } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default allowed origins for CORS.
|
|
4
|
+
* - localhost
|
|
5
|
+
* - 127.0.0.1
|
|
6
|
+
* - [::1]
|
|
7
|
+
*
|
|
8
|
+
* Can be used in `server.cors.origin` config.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* server: {
|
|
12
|
+
* cors: {
|
|
13
|
+
* origin: [defaultAllowedOrigins, 'https://example.com'],
|
|
14
|
+
* },
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const defaultAllowedOrigins: RegExp;
|
|
19
|
+
export declare function getDefaultEntry(root: string): RsbuildEntry;
|
|
20
|
+
export declare const withDefaultConfig: (rootPath: string, config: RsbuildConfig) => Promise<RsbuildConfig>;
|
|
21
|
+
/**
|
|
22
|
+
* Merges user config with default values to ensure required properties
|
|
23
|
+
* are initialized.
|
|
24
|
+
*/
|
|
25
|
+
export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
|
|
26
|
+
export declare const normalizePublicDirs: (publicDir?: PublicDir) => Required<PublicDirOptions>[];
|
|
@@ -5,7 +5,7 @@ export * from './fs';
|
|
|
5
5
|
export * from './path';
|
|
6
6
|
export * from './stats';
|
|
7
7
|
export { color };
|
|
8
|
-
export declare const rspackMinVersion = "1.
|
|
8
|
+
export declare const rspackMinVersion = "1.2.4";
|
|
9
9
|
export declare const getNodeEnv: () => string;
|
|
10
10
|
export declare const setNodeEnv: (env: string) => void;
|
|
11
11
|
export declare const isNil: (o: unknown) => o is undefined | null;
|
|
@@ -14,6 +14,11 @@ export declare const isObject: (obj: unknown) => obj is Record<string, any>;
|
|
|
14
14
|
export declare const isPlainObject: (obj: unknown) => obj is Record<string, any>;
|
|
15
15
|
export declare const castArray: <T>(arr?: T | T[]) => T[];
|
|
16
16
|
export declare const cloneDeep: <T>(value: T) => T;
|
|
17
|
+
/**
|
|
18
|
+
* If the application overrides the Rspack version to a lower one,
|
|
19
|
+
* we should check that the Rspack version is greater than the minimum
|
|
20
|
+
* supported version.
|
|
21
|
+
*/
|
|
17
22
|
export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
|
|
18
23
|
export declare const removeLeadingSlash: (s: string) => string;
|
|
19
24
|
export declare const removeTailingSlash: (s: string) => string;
|
|
@@ -42,3 +47,4 @@ export declare const prettyTime: (seconds: number) => string;
|
|
|
42
47
|
*/
|
|
43
48
|
export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
|
|
44
49
|
export declare const addCompilationError: (compilation: Rspack.Compilation, message: string) => void;
|
|
50
|
+
export declare function hash(data: string): string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare function
|
|
2
|
-
export declare function getRelativePath(base: string, filepath: string): string;
|
|
1
|
+
export declare function toRelativePath(base: string, filepath: string): string;
|
|
3
2
|
export declare function getCommonParentPath(paths: string[]): string;
|
|
4
3
|
export declare const getCompiledPath: (packageName: string) => string;
|
|
5
4
|
/**
|
|
@@ -9,7 +8,7 @@ export declare const getCompiledPath: (packageName: string) => string;
|
|
|
9
8
|
* @returns Resolved absolute file path.
|
|
10
9
|
*/
|
|
11
10
|
export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
|
|
12
|
-
export declare const
|
|
11
|
+
export declare const getPathnameFromUrl: (publicPath: string) => string;
|
|
13
12
|
/** dedupe and remove nested paths */
|
|
14
13
|
export declare const dedupeNestedPaths: (paths: string[]) => string[];
|
|
15
14
|
/**
|
package/dist-types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { rspack } from '@rspack/core';
|
|
|
6
6
|
import type * as Rspack from '@rspack/core';
|
|
7
7
|
export { loadEnv, type LoadEnvOptions, type LoadEnvResult } from './loadEnv';
|
|
8
8
|
export { createRsbuild } from './createRsbuild';
|
|
9
|
-
export { loadConfig, defineConfig, type ConfigParams, type LoadConfigOptions, type LoadConfigResult, } from './
|
|
9
|
+
export { loadConfig, defineConfig, type ConfigParams, type LoadConfigOptions, type LoadConfigResult, } from './loadConfig';
|
|
10
10
|
export { runCLI } from './cli';
|
|
11
11
|
export declare const version: string;
|
|
12
12
|
export { rspack };
|
|
@@ -14,7 +14,7 @@ export type { Rspack };
|
|
|
14
14
|
export { logger } from './logger';
|
|
15
15
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
16
16
|
export { ensureAssetPrefix } from './helpers';
|
|
17
|
-
export { defaultAllowedOrigins } from './
|
|
17
|
+
export { defaultAllowedOrigins } from './defaultConfig';
|
|
18
18
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME } from './constants';
|
|
19
19
|
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, Charset, ClientConfig, CliShortcut, CleanDistPath, CleanDistPathObject, 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, InternalContext, LegalComments, ManifestData, ManifestConfig, ManifestObjectConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyRsbuildConfigFn, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, MergedEnvironmentConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterEnvironmentCompileFn, OnBeforeEnvironmentCompileFn, OnCloseBuildFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProcessAssetsDescriptor, ProcessAssetsHook, ProcessAssetsHandler, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolveHook, ResolveHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ResourceHintsIncludeType, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig, TransformHook, TransformHandler, TransformImport, WatchFiles, } from './types';
|
|
20
20
|
export type { ChainIdentifier } from './configChain';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { InitConfigsOptions } from './provider/initConfigs';
|
|
2
|
+
import type { InspectConfigOptions, InspectConfigResult, NormalizedConfig, PluginManager, Rspack, WebpackConfig } from './types';
|
|
3
|
+
export declare const getRsbuildInspectConfig: ({ normalizedConfig, inspectOptions, pluginManager, }: {
|
|
4
|
+
normalizedConfig: NormalizedConfig;
|
|
5
|
+
inspectOptions: InspectConfigOptions;
|
|
6
|
+
pluginManager: PluginManager;
|
|
7
|
+
}) => {
|
|
8
|
+
rawRsbuildConfig: string;
|
|
9
|
+
rsbuildConfig: InspectConfigResult["origin"]["rsbuildConfig"];
|
|
10
|
+
rawEnvironmentConfigs: Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}>;
|
|
14
|
+
environmentConfigs: InspectConfigResult["origin"]["environmentConfigs"];
|
|
15
|
+
};
|
|
16
|
+
export declare function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType, }: {
|
|
17
|
+
configType: string;
|
|
18
|
+
rawEnvironmentConfigs: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
content: string;
|
|
21
|
+
}>;
|
|
22
|
+
rawBundlerConfigs: Array<{
|
|
23
|
+
name: string;
|
|
24
|
+
content: string;
|
|
25
|
+
}>;
|
|
26
|
+
inspectOptions: InspectConfigOptions & {
|
|
27
|
+
outputPath: string;
|
|
28
|
+
};
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
export declare function stringifyConfig(config: unknown, verbose?: boolean): string;
|
|
31
|
+
export declare function inspectConfig<B extends 'rspack' | 'webpack' = 'rspack'>({ context, pluginManager, bundlerConfigs, inspectOptions, bundler, }: InitConfigsOptions & {
|
|
32
|
+
inspectOptions?: InspectConfigOptions;
|
|
33
|
+
bundlerConfigs: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
|
|
34
|
+
bundler?: 'rspack' | 'webpack';
|
|
35
|
+
}): Promise<InspectConfigResult<B>>;
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
* Default allowed origins for CORS.
|
|
4
|
-
* - localhost
|
|
5
|
-
* - 127.0.0.1
|
|
6
|
-
* - [::1]
|
|
7
|
-
*
|
|
8
|
-
* Can be used in `server.cors.origin` config.
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* server: {
|
|
12
|
-
* cors: {
|
|
13
|
-
* origin: [defaultAllowedOrigins, 'https://example.com'],
|
|
14
|
-
* },
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare const defaultAllowedOrigins: RegExp;
|
|
19
|
-
export declare function getDefaultEntry(root: string): RsbuildEntry;
|
|
20
|
-
export declare const withDefaultConfig: (rootPath: string, config: RsbuildConfig) => Promise<RsbuildConfig>;
|
|
21
|
-
/**
|
|
22
|
-
* Merges user config with default values to ensure required properties
|
|
23
|
-
* are initialized.
|
|
24
|
-
*/
|
|
25
|
-
export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
|
|
1
|
+
import type { RsbuildConfig } from './types';
|
|
26
2
|
export type ConfigParams = {
|
|
27
3
|
env: string;
|
|
28
4
|
command: string;
|
|
@@ -32,14 +8,6 @@ export type ConfigParams = {
|
|
|
32
8
|
export type RsbuildConfigAsyncFn = (env: ConfigParams) => Promise<RsbuildConfig>;
|
|
33
9
|
export type RsbuildConfigSyncFn = (env: ConfigParams) => RsbuildConfig;
|
|
34
10
|
export type RsbuildConfigExport = RsbuildConfig | RsbuildConfigSyncFn | RsbuildConfigAsyncFn;
|
|
35
|
-
/**
|
|
36
|
-
* This function helps you to autocomplete configuration types.
|
|
37
|
-
* It accepts a Rsbuild config object, or a function that returns a config.
|
|
38
|
-
*/
|
|
39
|
-
export declare function defineConfig(config: RsbuildConfig): RsbuildConfig;
|
|
40
|
-
export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfigSyncFn;
|
|
41
|
-
export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
|
|
42
|
-
export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
|
|
43
11
|
export type LoadConfigOptions = {
|
|
44
12
|
/**
|
|
45
13
|
* The root path to resolve the config file.
|
|
@@ -79,34 +47,13 @@ export type LoadConfigResult = {
|
|
|
79
47
|
*/
|
|
80
48
|
filePath: string | null;
|
|
81
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* This function helps you to autocomplete configuration types.
|
|
52
|
+
* It accepts a Rsbuild config object, or a function that returns a config.
|
|
53
|
+
*/
|
|
54
|
+
export declare function defineConfig(config: RsbuildConfig): RsbuildConfig;
|
|
55
|
+
export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfigSyncFn;
|
|
56
|
+
export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
|
|
57
|
+
export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
|
|
82
58
|
export type ConfigLoader = 'jiti' | 'native';
|
|
83
59
|
export declare function loadConfig({ cwd, path, envMode, meta, loader, }?: LoadConfigOptions): Promise<LoadConfigResult>;
|
|
84
|
-
export declare const getRsbuildInspectConfig: ({ normalizedConfig, inspectOptions, pluginManager, }: {
|
|
85
|
-
normalizedConfig: NormalizedConfig;
|
|
86
|
-
inspectOptions: InspectConfigOptions;
|
|
87
|
-
pluginManager: PluginManager;
|
|
88
|
-
}) => {
|
|
89
|
-
rawRsbuildConfig: string;
|
|
90
|
-
rsbuildConfig: InspectConfigResult["origin"]["rsbuildConfig"];
|
|
91
|
-
rawEnvironmentConfigs: Array<{
|
|
92
|
-
name: string;
|
|
93
|
-
content: string;
|
|
94
|
-
}>;
|
|
95
|
-
environmentConfigs: InspectConfigResult["origin"]["environmentConfigs"];
|
|
96
|
-
};
|
|
97
|
-
export declare function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType, }: {
|
|
98
|
-
configType: string;
|
|
99
|
-
rawEnvironmentConfigs: Array<{
|
|
100
|
-
name: string;
|
|
101
|
-
content: string;
|
|
102
|
-
}>;
|
|
103
|
-
rawBundlerConfigs: Array<{
|
|
104
|
-
name: string;
|
|
105
|
-
content: string;
|
|
106
|
-
}>;
|
|
107
|
-
inspectOptions: InspectConfigOptions & {
|
|
108
|
-
outputPath: string;
|
|
109
|
-
};
|
|
110
|
-
}): Promise<void>;
|
|
111
|
-
export declare function stringifyConfig(config: unknown, verbose?: boolean): string;
|
|
112
|
-
export declare const normalizePublicDirs: (publicDir?: PublicDir) => Required<PublicDirOptions>[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file is used to get/set the global instance for html-plugin and css-extract plugin.
|
|
3
3
|
*/
|
|
4
|
-
import rspack from '@rspack/core';
|
|
4
|
+
import { rspack } from '@rspack/core';
|
|
5
5
|
import type { HtmlRspackPlugin } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* This method is used to override the Rsbuild default html-plugin (html-rspack-plugin).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LightningCssMinimizerRspackPluginOptions, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
|
|
2
2
|
import type { NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
|
|
3
3
|
export declare const getSwcMinimizerOptions: (config: NormalizedEnvironmentConfig, jsOptions?: SwcJsMinimizerRspackPluginOptions) => SwcJsMinimizerRspackPluginOptions;
|
|
4
|
-
export declare const parseMinifyOptions: (config: NormalizedEnvironmentConfig
|
|
4
|
+
export declare const parseMinifyOptions: (config: NormalizedEnvironmentConfig) => {
|
|
5
5
|
minifyJs: boolean;
|
|
6
6
|
minifyCss: boolean;
|
|
7
7
|
jsOptions?: SwcJsMinimizerRspackPluginOptions;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { setCssExtractPlugin, setHTMLPlugin } from '../pluginHelper';
|
|
5
5
|
export { initRsbuildConfig } from './initConfigs';
|
|
6
|
-
export {
|
|
6
|
+
export { inspectConfig } from '../inspectConfig';
|
|
7
7
|
export { getHTMLPlugin } from '../pluginHelper';
|
|
8
8
|
export { formatStats, getStatsOptions, prettyTime } from '../helpers';
|
|
9
9
|
export { registerBuildHook, registerDevHook } from '../hooks';
|
|
@@ -4,6 +4,15 @@ export type InitConfigsOptions = {
|
|
|
4
4
|
pluginManager: PluginManager;
|
|
5
5
|
rsbuildOptions: ResolvedCreateRsbuildOptions;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Initialize the Rsbuild config
|
|
9
|
+
* 1. Initialize the Rsbuild plugins
|
|
10
|
+
* 2. Run all the `modifyRsbuildConfig` hooks
|
|
11
|
+
* 3. Normalize the Rsbuild config, merge with the default config
|
|
12
|
+
* 4. Initialize the configs for each environment
|
|
13
|
+
* 5. Run all the `modifyEnvironmentConfig` hooks
|
|
14
|
+
* 6. Validate the final Rsbuild config
|
|
15
|
+
*/
|
|
7
16
|
export declare function initRsbuildConfig({ context, pluginManager, }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
|
|
8
17
|
export declare function initConfigs({ context, pluginManager, rsbuildOptions, }: InitConfigsOptions): Promise<{
|
|
9
18
|
rspackConfigs: Rspack.Configuration[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CliShortcut, NormalizedDevConfig } from '../types/config';
|
|
2
2
|
export declare const isCliShortcutsEnabled: (devConfig: NormalizedDevConfig) => boolean;
|
|
3
3
|
export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, }: {
|
|
4
|
-
help?: boolean;
|
|
4
|
+
help?: boolean | string;
|
|
5
5
|
openPage: () => Promise<void>;
|
|
6
6
|
closeServer: () => Promise<void>;
|
|
7
7
|
printUrls: () => void;
|
|
8
8
|
restartServer?: () => Promise<boolean>;
|
|
9
9
|
customShortcuts?: (shortcuts: CliShortcut[]) => CliShortcut[];
|
|
10
|
-
}): () => void
|
|
10
|
+
}): Promise<() => void>;
|
|
@@ -61,7 +61,7 @@ export declare const getServerConfig: ({ config, }: {
|
|
|
61
61
|
portTip: string | undefined;
|
|
62
62
|
}>;
|
|
63
63
|
export declare const isWildcardHost: (host: string) => boolean;
|
|
64
|
-
export declare const getHostInUrl: (host: string) => string
|
|
64
|
+
export declare const getHostInUrl: (host: string) => Promise<string>;
|
|
65
65
|
type AddressUrl = {
|
|
66
66
|
label: string;
|
|
67
67
|
url: string;
|
|
@@ -70,7 +70,7 @@ export declare const getAddressUrls: ({ protocol, port, host, }: {
|
|
|
70
70
|
protocol?: string;
|
|
71
71
|
port: number;
|
|
72
72
|
host?: string;
|
|
73
|
-
}) => AddressUrl[]
|
|
73
|
+
}) => Promise<AddressUrl[]>;
|
|
74
74
|
export declare const getCompilationId: (compiler: Rspack.Compiler | Rspack.Compilation) => string;
|
|
75
75
|
export declare function getServerTerminator(server: Server | Http2SecureServer): () => Promise<void>;
|
|
76
76
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const asModule: (something: Record<string, any>, context: Record<string, any>, unlinked?: boolean) => Promise<
|
|
1
|
+
import type { SourceTextModule } from 'node:vm';
|
|
2
|
+
export declare const asModule: (something: Record<string, any>, context: Record<string, any>, unlinked?: boolean) => Promise<SourceTextModule>;
|
|
@@ -14,7 +14,7 @@ import type { ModifyWebpackChainUtils, ModifyWebpackConfigUtils, RsbuildPlugins
|
|
|
14
14
|
import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild';
|
|
15
15
|
import type { BundlerPluginInstance, Rspack, RspackRule } from './rspack';
|
|
16
16
|
import type { CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, PostCSSLoaderOptions, PostCSSPlugin, StyleLoaderOptions, WebpackConfig } from './thirdParty';
|
|
17
|
-
import type { ConfigChain, ConfigChainMergeContext, ConfigChainWithContext,
|
|
17
|
+
import type { ConfigChain, ConfigChainMergeContext, ConfigChainWithContext, MaybePromise, OneOrMany, TwoLevelReadonly } from './utils';
|
|
18
18
|
export type ToolsSwcConfig = ConfigChain<SwcLoaderOptions>;
|
|
19
19
|
export type ToolsBundlerChainConfig = OneOrMany<(chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>>;
|
|
20
20
|
export type ToolsPostCSSLoaderConfig = ConfigChainWithContext<PostCSSLoaderOptions, {
|
|
@@ -226,11 +226,6 @@ export type TransformImport = {
|
|
|
226
226
|
type TransformImportFn = (imports: TransformImport[]) => TransformImport[] | void;
|
|
227
227
|
export interface NormalizedSourceConfig extends SourceConfig {
|
|
228
228
|
define: Define;
|
|
229
|
-
/**
|
|
230
|
-
* @deprecated Use `resolve.alias` instead.
|
|
231
|
-
* `source.alias` will be removed in v2.0.0.
|
|
232
|
-
*/
|
|
233
|
-
alias: ConfigChain<Alias>;
|
|
234
229
|
preEntry: string[];
|
|
235
230
|
decorators: Required<Decorators>;
|
|
236
231
|
}
|
|
@@ -805,19 +800,29 @@ export type CSSModules = {
|
|
|
805
800
|
};
|
|
806
801
|
export type Minify = boolean | {
|
|
807
802
|
/**
|
|
808
|
-
* Whether to enable JavaScript
|
|
803
|
+
* Whether to enable minification for JavaScript bundles.
|
|
804
|
+
* - `true`: Enabled in production mode.
|
|
805
|
+
* - `false`: Disabled in all modes.
|
|
806
|
+
* - `'always'`: Enabled in all modes.
|
|
807
|
+
* @default true
|
|
809
808
|
*/
|
|
810
|
-
js?: boolean;
|
|
809
|
+
js?: boolean | 'always';
|
|
811
810
|
/**
|
|
812
811
|
* Minimizer options of JavaScript, which will be passed to SWC.
|
|
812
|
+
* @default {}
|
|
813
813
|
*/
|
|
814
814
|
jsOptions?: SwcJsMinimizerRspackPluginOptions;
|
|
815
815
|
/**
|
|
816
|
-
* Whether to enable CSS
|
|
816
|
+
* Whether to enable minification for CSS bundles.
|
|
817
|
+
* - `true`: Enabled in production mode.
|
|
818
|
+
* - `false`: Disabled in all modes.
|
|
819
|
+
* - `'always'`: Enabled in all modes.
|
|
820
|
+
* @default true
|
|
817
821
|
*/
|
|
818
|
-
css?: boolean;
|
|
822
|
+
css?: boolean | 'always';
|
|
819
823
|
/**
|
|
820
824
|
* Minimizer options of CSS, which will be passed to LightningCSS.
|
|
825
|
+
* @default inherit from `tools.lightningcssLoader` config
|
|
821
826
|
*/
|
|
822
827
|
cssOptions?: LightningCssMinimizerRspackPluginOptions;
|
|
823
828
|
};
|
|
@@ -954,7 +959,8 @@ export interface OutputConfig {
|
|
|
954
959
|
*/
|
|
955
960
|
cssModules?: CSSModules;
|
|
956
961
|
/**
|
|
957
|
-
*
|
|
962
|
+
* Configure whether to enable code minification in production mode, or to configure
|
|
963
|
+
* minimizer options.
|
|
958
964
|
* @default true
|
|
959
965
|
*/
|
|
960
966
|
minify?: Minify;
|
|
@@ -1349,9 +1355,12 @@ export interface DevConfig {
|
|
|
1349
1355
|
custom?: (shortcuts: CliShortcut[]) => CliShortcut[];
|
|
1350
1356
|
/**
|
|
1351
1357
|
* Whether to print the help hint when the server is started.
|
|
1358
|
+
* - `true`: Print the default help hint.
|
|
1359
|
+
* - `false`: Disable the help hint.
|
|
1360
|
+
* - `string`: Print a custom help hint.
|
|
1352
1361
|
* @default true
|
|
1353
1362
|
*/
|
|
1354
|
-
help?: boolean;
|
|
1363
|
+
help?: boolean | string;
|
|
1355
1364
|
};
|
|
1356
1365
|
/**
|
|
1357
1366
|
* Provides the ability to execute a custom function and apply custom middlewares.
|
|
@@ -1373,7 +1382,8 @@ export interface DevConfig {
|
|
|
1373
1382
|
*/
|
|
1374
1383
|
lazyCompilation?: boolean | Rspack.LazyCompilationOptions;
|
|
1375
1384
|
}
|
|
1376
|
-
export type NormalizedDevConfig = DevConfig & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts'>> & {
|
|
1385
|
+
export type NormalizedDevConfig = Omit<DevConfig, 'watchFiles'> & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts'>> & {
|
|
1386
|
+
watchFiles: WatchFiles[];
|
|
1377
1387
|
client: NormalizedClientConfig;
|
|
1378
1388
|
};
|
|
1379
1389
|
export interface ResolveConfig {
|
|
@@ -1520,7 +1530,7 @@ export type MergedEnvironmentConfig = {
|
|
|
1520
1530
|
/**
|
|
1521
1531
|
* The normalized Rsbuild environment config.
|
|
1522
1532
|
*/
|
|
1523
|
-
export type NormalizedEnvironmentConfig =
|
|
1533
|
+
export type NormalizedEnvironmentConfig = TwoLevelReadonly<Omit<MergedEnvironmentConfig, 'dev'> & {
|
|
1524
1534
|
dev: NormalizedDevConfig;
|
|
1525
1535
|
server: NormalizedServerConfig;
|
|
1526
1536
|
_privateMeta?: RsbuildConfigMeta;
|
|
@@ -13,10 +13,29 @@ export type RsbuildContext = {
|
|
|
13
13
|
distPath: string;
|
|
14
14
|
/** Absolute path of cache files. */
|
|
15
15
|
cachePath: string;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Dev server information when running in dev mode.
|
|
18
|
+
* Available after the dev server has been created.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createRsbuild } from '@rsbuild/core';
|
|
23
|
+
*
|
|
24
|
+
* async function main() {
|
|
25
|
+
* const rsbuild = createRsbuild({
|
|
26
|
+
* // ...
|
|
27
|
+
* });
|
|
28
|
+
* await rsbuild.startDevServer();
|
|
29
|
+
* console.log(rsbuild.context.devServer); // { hostname: 'localhost', port: 3000, https: false }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
17
33
|
devServer?: {
|
|
34
|
+
/** The hostname the server is running on. */
|
|
18
35
|
hostname: string;
|
|
36
|
+
/** The port number the server is listening on. */
|
|
19
37
|
port: number;
|
|
38
|
+
/** Whether the server is using HTTPS protocol. */
|
|
20
39
|
https: boolean;
|
|
21
40
|
};
|
|
22
41
|
/**
|
|
@@ -20,7 +20,7 @@ export type EnvironmentAsyncHook<Callback extends (...args: any[]) => T, T = any
|
|
|
20
20
|
* Registers a callback function to be executed when the hook is triggered.
|
|
21
21
|
* The callback can be a plain function or a HookDescriptor that includes execution order.
|
|
22
22
|
* The callback will be executed in all environments by default.
|
|
23
|
-
* If you need to specify the environment,
|
|
23
|
+
* If you need to specify the environment, use `tapEnvironment`
|
|
24
24
|
* @param cb The callback function or hook descriptor to register
|
|
25
25
|
*/
|
|
26
26
|
tap: (cb: Callback | HookDescriptor<Callback>) => void;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export type Falsy = false | null | undefined;
|
|
2
2
|
export type OneOrMany<T> = T | T[];
|
|
3
3
|
export type MaybePromise<T> = T | Promise<T>;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Creates a type with readonly properties at the first and second levels only.
|
|
6
|
+
*/
|
|
7
|
+
export type TwoLevelReadonly<T> = keyof T extends never ? T : {
|
|
8
|
+
readonly [k in keyof T]: T[k] extends object ? {
|
|
9
|
+
readonly [p in keyof T[k]]: T[k][p];
|
|
10
|
+
} : T[k];
|
|
6
11
|
};
|
|
7
12
|
export type ConfigChain<T> = OneOrMany<T | ((config: T) => T | void)>;
|
|
8
13
|
export type ConfigChainWithContext<T, Ctx> = OneOrMany<T | ((config: T, ctx: Ctx) => T | void)>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.22",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "1.3.
|
|
49
|
+
"@rspack/core": "1.3.12",
|
|
50
50
|
"@rspack/lite-tapable": "~1.0.1",
|
|
51
51
|
"@swc/helpers": "^0.5.17",
|
|
52
52
|
"core-js": "~3.42.0",
|
|
53
53
|
"jiti": "^2.4.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rslib/core": "0.
|
|
56
|
+
"@rslib/core": "0.8.0",
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
58
58
|
"@types/cors": "^2.8.18",
|
|
59
|
-
"@types/node": "^22.15.
|
|
59
|
+
"@types/node": "^22.15.21",
|
|
60
60
|
"@types/on-finished": "2.3.4",
|
|
61
61
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
"rspack-manifest-plugin": "5.0.3",
|
|
89
89
|
"sirv": "^3.0.1",
|
|
90
90
|
"style-loader": "3.3.4",
|
|
91
|
-
"tinyglobby": "^0.2.
|
|
91
|
+
"tinyglobby": "^0.2.14",
|
|
92
92
|
"typescript": "^5.8.3",
|
|
93
|
-
"webpack": "^5.99.
|
|
93
|
+
"webpack": "^5.99.9",
|
|
94
94
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
95
95
|
"webpack-merge": "6.0.1",
|
|
96
96
|
"ws": "^8.18.2"
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { InspectConfigOptions, InspectConfigResult, Rspack } from '../types';
|
|
2
|
-
import { type InitConfigsOptions } from './initConfigs';
|
|
3
|
-
export declare function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
|
|
4
|
-
inspectOptions?: InspectConfigOptions;
|
|
5
|
-
bundlerConfigs?: Rspack.Configuration[];
|
|
6
|
-
}): Promise<InspectConfigResult<'rspack'>>;
|