@rsbuild/core 1.2.2 → 1.2.4

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.
@@ -1,8 +1,7 @@
1
1
  import RspackChain from '../compiled/rspack-chain/index.js';
2
- import type { InternalContext, ModifyBundlerChainUtils, Rspack } from './types';
2
+ import type { InternalContext, ModifyBundlerChainUtils } from './types';
3
3
  export declare function getBundlerChain(): RspackChain;
4
4
  export declare function modifyBundlerChain(context: InternalContext, utils: ModifyBundlerChainUtils): Promise<RspackChain>;
5
- export declare function chainToConfig(chain: RspackChain): Rspack.Configuration;
6
5
  export declare const CHAIN_ID: {
7
6
  /** Predefined rules */
8
7
  readonly RULE: {
@@ -15,6 +15,6 @@ 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, 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, 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, PreloadIncludeType, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProxyConfig, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig, TransformFn, TransformHandler, TransformImport, WatchFiles, } from './types';
18
+ export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, CacheGroup, CacheGroups, 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, 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, PreloadIncludeType, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig, TransformFn, TransformHandler, TransformImport, WatchFiles, } from './types';
19
19
  export type { ChainIdentifier } from './configChain';
20
20
  export type { RsbuildDevServer } from './server/devServer';
@@ -1,5 +1,5 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
2
  /**
3
- * Provide some basic configs of rspack
3
+ * Set some basic Rspack configs
4
4
  */
5
5
  export declare const pluginBasic: () => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import type { DevConfig, Rspack } from '../types';
1
+ import type { DevConfig, Rspack, ServerConfig } from '../types';
2
2
  import { type InitConfigsOptions } from './initConfigs';
3
3
  export declare function createCompiler(options: InitConfigsOptions): Promise<{
4
4
  compiler: Rspack.Compiler | Rspack.MultiCompiler;
@@ -24,4 +24,5 @@ export type DevMiddlewareOptions = {
24
24
  callbacks: MiddlewareCallbacks;
25
25
  /** whether use Server Side Render */
26
26
  serverSideRender?: boolean;
27
+ serverConfig: ServerConfig;
27
28
  };
@@ -8,5 +8,5 @@ export { getHTMLPlugin } from '../pluginHelper';
8
8
  export { formatStats, getStatsOptions, prettyTime } from '../helpers';
9
9
  export { registerBuildHook, registerDevHook } from '../hooks';
10
10
  export { getChainUtils, getConfigUtils } from './rspackConfig';
11
- export { chainToConfig, modifyBundlerChain } from '../configChain';
11
+ export { modifyBundlerChain } from '../configChain';
12
12
  export { createDevServer } from '../server/devServer';
@@ -22,6 +22,6 @@ export type DevMiddlewareAPI = Middleware & {
22
22
  * - Inject the HMR client path into page (the HMR client rsbuild/server already provide).
23
23
  * - Notify server when compiler hooks are triggered.
24
24
  */
25
- export type DevMiddleware = (options: DevMiddlewareOptions) => DevMiddlewareAPI;
25
+ export type DevMiddleware = (options: DevMiddlewareOptions) => Promise<DevMiddlewareAPI>;
26
26
  export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => Promise<NonNullable<DevMiddleware>>;
27
27
  export {};
@@ -50,6 +50,7 @@ export declare const getServerConfig: ({ config, }: {
50
50
  https: boolean;
51
51
  portTip: string | undefined;
52
52
  }>;
53
+ export declare const isWildcardHost: (host: string) => boolean;
53
54
  export declare const getHostInUrl: (host: string) => string;
54
55
  type AddressUrl = {
55
56
  label: string;
@@ -0,0 +1,10 @@
1
+ import type { DevConfig, ServerConfig } from '../types/config';
2
+ /**
3
+ * Checks if localhost resolves differently between node's default DNS lookup
4
+ * and explicit DNS lookup.
5
+ *
6
+ * Returns the resolved address if there's a difference, undefined otherwise.
7
+ * This helps detect cases where IPv4/IPv6 resolution might vary.
8
+ */
9
+ export declare function getLocalhostResolvedAddress(): Promise<string | undefined>;
10
+ export declare function getResolvedClientConfig(clientConfig: DevConfig['client'], serverConfig: ServerConfig): Promise<DevConfig['client']>;
@@ -174,7 +174,8 @@ export interface NormalizedSourceConfig extends SourceConfig {
174
174
  decorators: Required<Decorators>;
175
175
  }
176
176
  export type HtmlFallback = false | 'index';
177
- export type ProxyBypass = (req: IncomingMessage, res: ServerResponse, proxyOptions: ProxyOptions) => string | undefined | null | boolean;
177
+ export type ProxyBypass = (req: IncomingMessage, res: ServerResponse, proxyOptions: ProxyOptions) => MaybePromise<string | undefined | null | boolean>;
178
+ export type { ProxyFilter };
178
179
  export type ProxyOptions = HttpProxyOptions & {
179
180
  /**
180
181
  * Bypass the proxy based on the return value of a function.
@@ -182,6 +183,7 @@ export type ProxyOptions = HttpProxyOptions & {
182
183
  * - Return `true` to continue processing the request without proxy.
183
184
  * - Return `false` to produce a 404 error for the request.
184
185
  * - Return a path to serve from, instead of continuing to proxy the request.
186
+ * - Return a Promise to handle the request asynchronously.
185
187
  */
186
188
  bypass?: ProxyBypass;
187
189
  /**
@@ -135,6 +135,7 @@ export type ModifyBundlerChainUtils = ModifyChainUtils & {
135
135
  DefinePlugin: PluginInstance;
136
136
  IgnorePlugin: PluginInstance;
137
137
  ProvidePlugin: PluginInstance;
138
+ SourceMapDevToolPlugin: PluginInstance;
138
139
  HotModuleReplacementPlugin: PluginInstance;
139
140
  };
140
141
  };
@@ -148,6 +148,11 @@ export type TransformContext = {
148
148
  * The code of the module.
149
149
  */
150
150
  code: string;
151
+ /**
152
+ * The directory path of the currently processed module,
153
+ * which changes with the location of each processed module.
154
+ */
155
+ context: string | null;
151
156
  /**
152
157
  * The absolute path of the module, including the query.
153
158
  * @example '/home/user/project/src/index.js?foo=123'
@@ -185,6 +190,10 @@ export type TransformContext = {
185
190
  * Compile and execute a module at the build time.
186
191
  */
187
192
  importModule: Rspack.LoaderContext['importModule'];
193
+ /**
194
+ * Resolve a module specifier.
195
+ */
196
+ resolve: Rspack.LoaderContext['resolve'];
188
197
  };
189
198
  export type TransformHandler = (context: TransformContext) => MaybePromise<TransformResult>;
190
199
  export type TransformDescriptor = {
@@ -313,9 +322,9 @@ export type RsbuildPluginAPI = Readonly<{
313
322
  modifyBundlerChain: PluginHook<ModifyBundlerChainFn>;
314
323
  /** Only works when bundler is Rspack */
315
324
  modifyRspackConfig: PluginHook<ModifyRspackConfigFn>;
316
- /** Only works when bundler is Webpack */
325
+ /** Only works when bundler is webpack */
317
326
  modifyWebpackChain: PluginHook<ModifyWebpackChainFn>;
318
- /** Only works when bundler is Webpack */
327
+ /** Only works when bundler is webpack */
319
328
  modifyWebpackConfig: PluginHook<ModifyWebpackConfigFn>;
320
329
  getRsbuildConfig: GetRsbuildConfig;
321
330
  getNormalizedConfig: typeof getNormalizedConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -52,12 +52,12 @@
52
52
  "core-js": "~3.40.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@rslib/core": "0.3.2",
55
+ "@rslib/core": "0.4.0",
56
56
  "@types/connect": "3.4.38",
57
- "@types/node": "^22.10.7",
57
+ "@types/node": "^22.13.0",
58
58
  "@types/on-finished": "2.3.4",
59
59
  "@types/webpack-bundle-analyzer": "4.7.0",
60
- "@types/ws": "^8.5.13",
60
+ "@types/ws": "^8.5.14",
61
61
  "browserslist-load-config": "1.0.0",
62
62
  "cac": "^6.7.14",
63
63
  "chokidar": "^4.0.3",
@@ -83,7 +83,7 @@
83
83
  "reduce-configs": "^1.1.0",
84
84
  "rsbuild-dev-middleware": "0.1.2",
85
85
  "rslog": "^1.2.3",
86
- "rspack-chain": "^1.1.1",
86
+ "rspack-chain": "^1.2.1",
87
87
  "rspack-manifest-plugin": "5.0.3",
88
88
  "sirv": "^3.0.0",
89
89
  "style-loader": "3.3.4",