@rsbuild/core 2.0.0-alpha.3 → 2.0.0-beta.0

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.
@@ -2,7 +2,7 @@ import * as __rspack_external__rspack_lite_tapable_c6bdf810 from "@rspack/lite-t
2
2
  import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  import "./131.js";
4
4
  __webpack_require__.add({
5
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
5
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.1_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: !0
8
8
  }), exports.transformFiles = exports.reduceChunk = exports.reduceAssets = exports.generateManifest = void 0;
@@ -64,11 +64,11 @@ __webpack_require__.add({
64
64
  'sort'
65
65
  ].filter((fname)=>!!options[fname]).reduce((prev, fname)=>prev[fname](options[fname]), files).map(standardizeFilePaths);
66
66
  },
67
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
67
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.1_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
68
68
  Object.defineProperty(exports, "__esModule", {
69
69
  value: !0
70
70
  }), exports.normalModuleLoaderHook = exports.getCompilerHooks = exports.emitHook = exports.beforeRunHook = void 0;
71
- let node_fs_1 = __webpack_require__("node:fs"), node_path_1 = __webpack_require__("node:path"), lite_tapable_1 = __webpack_require__("@rspack/lite-tapable"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
71
+ let node_fs_1 = __webpack_require__("node:fs"), node_path_1 = __webpack_require__("node:path"), lite_tapable_1 = __webpack_require__("@rspack/lite-tapable"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.1_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
72
72
  let hooks = compilerHookMap.get(compiler);
73
73
  return void 0 === hooks && (hooks = {
74
74
  afterEmit: new lite_tapable_1.SyncWaterfallHook([
@@ -122,9 +122,9 @@ __webpack_require__.add({
122
122
  }), emitFile.call(module, file, content, sourceMap));
123
123
  };
124
124
  },
125
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
125
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.1_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
126
126
  exports.RspackManifestPlugin = void 0;
127
- let node_path_1 = __webpack_require__("node:path"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
127
+ let node_path_1 = __webpack_require__("node:path"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.1_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
128
128
  assetHookStage: 1 / 0,
129
129
  basePath: '',
130
130
  fileName: 'manifest.json',
@@ -40,24 +40,12 @@ export declare const CHAIN_ID: {
40
40
  /** Predefined rule groups */
41
41
  readonly ONE_OF: {
42
42
  /** JS oneOf rules */
43
- readonly JS_MAIN: "js-main";
43
+ readonly JS_MAIN: "js";
44
44
  readonly JS_RAW: "js-raw";
45
45
  /** CSS oneOf rules */
46
- readonly CSS_MAIN: "css-main";
46
+ readonly CSS_MAIN: "css";
47
47
  readonly CSS_RAW: "css-raw";
48
48
  readonly CSS_INLINE: "css-inline";
49
- /** Less oneOf rules */
50
- readonly LESS_MAIN: "less-main";
51
- readonly LESS_RAW: "less-raw";
52
- readonly LESS_INLINE: "less-inline";
53
- /** Sass oneOf rules */
54
- readonly SASS_MAIN: "sass-main";
55
- readonly SASS_RAW: "sass-raw";
56
- readonly SASS_INLINE: "sass-inline";
57
- /** Stylus oneOf rules */
58
- readonly STYLUS_MAIN: "stylus-main";
59
- readonly STYLUS_RAW: "stylus-raw";
60
- readonly STYLUS_INLINE: "stylus-inline";
61
49
  /** SVG oneOf rules */
62
50
  readonly SVG: "svg";
63
51
  readonly SVG_RAW: "svg-asset-raw";
@@ -1,6 +1,7 @@
1
1
  import color from 'picocolors';
2
2
  import RspackChain from '../../compiled/rspack-chain/types';
3
3
  import type { FilenameConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildTarget, Rspack } from '../types';
4
+ export { require } from './vendors';
4
5
  export { color, RspackChain };
5
6
  export declare const getNodeEnv: () => string;
6
7
  export declare const setNodeEnv: (env: string) => void;
@@ -4,6 +4,7 @@ type CompiledPackages = {
4
4
  'html-rspack-plugin': typeof import('../../compiled/html-rspack-plugin').default;
5
5
  'http-proxy-middleware': typeof import('../../compiled/http-proxy-middleware');
6
6
  };
7
+ export declare const require: NodeJS.Require;
7
8
  /**
8
9
  * Load compiled package from `compiled` folder.
9
10
  * use `require()` as compiled packages are CommonJS modules.
@@ -3,7 +3,7 @@
3
3
  * the public API of @rsbuild/core.
4
4
  */
5
5
  import type * as Rspack from '@rspack/core';
6
- import { rspack } from './rspack';
6
+ import { rspack } from '@rspack/core';
7
7
  export { runCLI } from './cli';
8
8
  export { createRsbuild } from './createRsbuild';
9
9
  export { type ConfigParams, defineConfig, type LoadConfigOptions, type LoadConfigResult, loadConfig, } from './loadConfig';
@@ -19,4 +19,4 @@ export { type Logger, logger } from './logger';
19
19
  export { mergeRsbuildConfig } from './mergeConfig';
20
20
  export type { RsbuildDevServer } from './server/devServer';
21
21
  export type { StartServerResult } from './server/helper';
22
- export type { AliasStrategy, AppIcon, AppIconItem, 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, 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, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, 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, SplitChunks, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
22
+ export type { AliasStrategy, AppIcon, AppIconItem, 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, 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, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, 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, SplitChunks, SplitChunksConfig, SplitChunksPreset, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
@@ -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';
4
+ import { rspack } from '@rspack/core';
5
5
  import type { HtmlRspackPlugin, NormalizedEnvironmentConfig } from './types';
6
6
  /**
7
7
  * This method is used to override the Rsbuild default html-plugin (html-rspack-plugin).
@@ -1,4 +1,4 @@
1
- import type { Compiler } from '@rspack/core';
1
+ import { type Compiler } from '@rspack/core';
2
2
  import type { EnvironmentContext, HtmlRspackPlugin, HtmlTag, HtmlTagDescriptor, InternalContext } from '../types';
3
3
  type HtmlTagObject = HtmlRspackPlugin.HtmlTagObject;
4
4
  export type TagConfig = {
@@ -6,7 +6,7 @@
6
6
  * Copyright JS Foundation and other contributors
7
7
  * https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
8
8
  */
9
- import type { Compiler, MultiCompiler } from '@rspack/core';
9
+ import { type Compiler, type MultiCompiler } from '@rspack/core';
10
10
  import type { InternalContext, NormalizedConfig, RequestHandler } from '../../types';
11
11
  import type { SocketServer } from '../socketServer';
12
12
  export type MultiWatching = ReturnType<MultiCompiler['watch']>;
@@ -370,9 +370,12 @@ export interface ServerConfig {
370
370
  https?: HttpsServerOptions | SecureServerSessionOptions;
371
371
  /**
372
372
  * Specify the host that the Rsbuild server listens to.
373
- * @default '0.0.0.0'
373
+ * - `string`: specify a hostname or IP address to listen on.
374
+ * - `true`: equals to `0.0.0.0`, listen on all interfaces.
375
+ * - `false`: equals to `localhost`
376
+ * @default 'localhost'
374
377
  */
375
- host?: string;
378
+ host?: string | boolean;
376
379
  /**
377
380
  * Adds headers to all responses.
378
381
  */
@@ -437,8 +440,9 @@ export interface ServerConfig {
437
440
  middlewareMode?: boolean;
438
441
  }
439
442
  export type NormalizedServerConfig = {
443
+ host: string;
440
444
  publicDir: Required<PublicDirOptions>[];
441
- } & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy'>, 'publicDir'>;
445
+ } & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy'>, 'host' | 'publicDir'>;
442
446
  export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
443
447
  export type SriOptions = {
444
448
  /**
@@ -606,7 +610,7 @@ export interface PerformanceConfig {
606
610
  printFileSize?: PrintFileSizeOptions | boolean;
607
611
  /**
608
612
  * Configure the chunk splitting strategy.
609
- * @default { strategy: 'split-by-experience' }
613
+ * @deprecated Use `splitChunks` instead.
610
614
  */
611
615
  chunkSplit?: ChunkSplit;
612
616
  /**
@@ -659,9 +663,13 @@ export interface PerformanceConfig {
659
663
  }
660
664
  export interface NormalizedPerformanceConfig extends PerformanceConfig {
661
665
  printFileSize: PrintFileSizeOptions | boolean;
662
- chunkSplit: ChunkSplit;
663
666
  }
664
667
  export type SplitChunks = Rspack.OptimizationSplitChunksOptions | false;
668
+ export type SplitChunksPreset = 'default' | 'single-vendor' | 'per-package';
669
+ export type SplitChunksConfig = Rspack.OptimizationSplitChunksOptions & {
670
+ preset?: SplitChunksPreset;
671
+ };
672
+ export type NormalizedSplitChunksConfig = SplitChunksConfig;
665
673
  export type ForceSplitting = RegExp[] | Record<string, RegExp>;
666
674
  export interface BaseSplitRules {
667
675
  strategy?: string;
@@ -1750,6 +1758,10 @@ export interface EnvironmentConfig {
1750
1758
  * Options for build performance and runtime performance.
1751
1759
  */
1752
1760
  performance?: PerformanceConfig;
1761
+ /**
1762
+ * Options for chunk splitting.
1763
+ */
1764
+ splitChunks?: SplitChunksConfig | false;
1753
1765
  /**
1754
1766
  * Options for module federation.
1755
1767
  */
@@ -1791,8 +1803,9 @@ export interface RsbuildConfig extends EnvironmentConfig {
1791
1803
  */
1792
1804
  dev?: DevConfig;
1793
1805
  /**
1794
- * Options for the Rsbuild server,
1795
- * will take effect during local development and preview.
1806
+ * Options for the Rsbuild server.
1807
+ * Mainly applies to local development and preview.
1808
+ * Some options (e.g. `publicDir`, `base`) also affect production builds.
1796
1809
  */
1797
1810
  server?: ServerConfig;
1798
1811
  /**
@@ -1820,6 +1833,7 @@ export type MergedEnvironmentConfig = {
1820
1833
  plugins?: RsbuildPlugins;
1821
1834
  security: NormalizedSecurityConfig;
1822
1835
  performance: NormalizedPerformanceConfig;
1836
+ splitChunks: NormalizedSplitChunksConfig | false;
1823
1837
  moduleFederation?: ModuleFederationConfig;
1824
1838
  };
1825
1839
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -36,7 +36,7 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rspack/core": "2.0.0-alpha.0",
39
+ "@rspack/core": "2.0.0-alpha.1",
40
40
  "@rspack/lite-tapable": "~1.1.0",
41
41
  "@swc/helpers": "^0.5.18",
42
42
  "jiti": "^2.6.1"
@@ -1,2 +0,0 @@
1
- declare const rspack: (typeof import('@rspack/core'))['rspack'];
2
- export { rspack };