@rsbuild/core 1.0.17 → 1.0.18

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 CHANGED
@@ -3734,7 +3734,7 @@ function pick(obj, keys) {
3734
3734
  {}
3735
3735
  );
3736
3736
  }
3737
- var import_node_path4, import_deepmerge, import_picocolors3, rspackMinVersion, getNodeEnv, setNodeEnv, isFunction, isObject, isPlainObject, castArray, cloneDeep, compareSemver, isSatisfyRspackVersion, removeLeadingSlash, removeTailingSlash, addTrailingSlash, formatPublicPath, getPublicPathFromChain, getPublicPathFromCompiler, urlJoin, canParse, ensureAssetPrefix, applyToCompiler, upperFirst, isURL, createVirtualModule, isMultiCompiler, camelCase, prettyTime;
3737
+ var import_node_path4, import_deepmerge, import_picocolors3, rspackMinVersion, getNodeEnv, setNodeEnv, isFunction, isObject, isPlainObject, castArray, cloneDeep, compareSemver, isSatisfyRspackVersion, removeLeadingSlash, removeTailingSlash, addTrailingSlash, formatPublicPath, getPublicPathFromChain, getPublicPathFromCompiler, urlJoin, canParse, ensureAssetPrefix, applyToCompiler, upperFirst, isURL, createVirtualModule, isMultiCompiler, camelCase, prettyTime, isTTY;
3738
3738
  var init_helpers = __esm({
3739
3739
  "src/helpers/index.ts"() {
3740
3740
  "use strict";
@@ -3752,19 +3752,8 @@ var init_helpers = __esm({
3752
3752
  };
3753
3753
  isFunction = (func) => typeof func === "function";
3754
3754
  isObject = (obj) => Object.prototype.toString.call(obj) === "[object Object]";
3755
- isPlainObject = (o) => {
3756
- if (isObject(o) === false)
3757
- return false;
3758
- const ctor = o.constructor;
3759
- if (ctor === void 0)
3760
- return true;
3761
- const prot = ctor.prototype;
3762
- if (isObject(prot) === false)
3763
- return false;
3764
- if (prot.hasOwnProperty("isPrototypeOf") === false) {
3765
- return false;
3766
- }
3767
- return true;
3755
+ isPlainObject = (obj) => {
3756
+ return obj !== null && typeof obj === "object" && Object.getPrototypeOf(obj) === Object.prototype;
3768
3757
  };
3769
3758
  castArray = (arr) => {
3770
3759
  if (arr === void 0) {
@@ -3891,6 +3880,9 @@ var init_helpers = __esm({
3891
3880
  const minutes = seconds / 60;
3892
3881
  return `${format(minutes.toFixed(2))} m`;
3893
3882
  };
3883
+ isTTY = (type = "stdout") => {
3884
+ return (type === "stdin" ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
3885
+ };
3894
3886
  }
3895
3887
  });
3896
3888
 
@@ -3971,13 +3963,14 @@ var init_restart = __esm({
3971
3963
  import_node_path5 = __toESM(require("path"));
3972
3964
  import_picocolors4 = __toESM(require("../compiled/picocolors/index.js"));
3973
3965
  init_init();
3966
+ init_helpers();
3974
3967
  init_logger();
3975
3968
  cleaners = [];
3976
3969
  onBeforeRestartServer = (cleaner) => {
3977
3970
  cleaners.push(cleaner);
3978
3971
  };
3979
3972
  clearConsole = () => {
3980
- if (process.stdout.isTTY && !process.env.DEBUG) {
3973
+ if (isTTY() && !process.env.DEBUG) {
3981
3974
  process.stdout.write("\x1B[H\x1B[2J");
3982
3975
  }
3983
3976
  };
@@ -4302,7 +4295,8 @@ var init_config = __esm({
4302
4295
  svg: DEFAULT_DATA_URL_SIZE,
4303
4296
  font: DEFAULT_DATA_URL_SIZE,
4304
4297
  image: DEFAULT_DATA_URL_SIZE,
4305
- media: DEFAULT_DATA_URL_SIZE
4298
+ media: DEFAULT_DATA_URL_SIZE,
4299
+ assets: DEFAULT_DATA_URL_SIZE
4306
4300
  },
4307
4301
  legalComments: "linked",
4308
4302
  injectStyles: false,
@@ -5184,14 +5178,7 @@ function createPluginManager() {
5184
5178
  continue;
5185
5179
  }
5186
5180
  validatePlugin(newPlugin);
5187
- const existPlugin = plugins.find(
5188
- (item) => item.instance.name === newPlugin.name && item.environment === environment
5189
- );
5190
- if (existPlugin) {
5191
- import_rslog.logger.warn(
5192
- `Rsbuild plugin "${newPlugin.name}" registered multiple times.`
5193
- );
5194
- } else if (before) {
5181
+ if (before) {
5195
5182
  const index = plugins.findIndex(
5196
5183
  (item) => item.instance.name === before
5197
5184
  );
@@ -6042,7 +6029,7 @@ async function createContext(options, userConfig, bundlerType) {
6042
6029
  const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
6043
6030
  const cachePath = (0, import_node_path10.join)(rootPath, "node_modules", ".cache");
6044
6031
  return {
6045
- version: "1.0.17",
6032
+ version: "1.0.18",
6046
6033
  rootPath,
6047
6034
  distPath: "",
6048
6035
  cachePath,
@@ -6375,7 +6362,7 @@ var init_configChain = __esm({
6375
6362
  JS_DATA_URI: "js-data-uri",
6376
6363
  /** Rule for ts */
6377
6364
  TS: "ts",
6378
- /** Rule for css */
6365
+ /** Rule for CSS */
6379
6366
  CSS: "css",
6380
6367
  /** Rule for less */
6381
6368
  LESS: "less",
@@ -7025,9 +7012,10 @@ var init_cliShortcuts = __esm({
7025
7012
  "use strict";
7026
7013
  import_node_readline = __toESM(require("readline"));
7027
7014
  import_picocolors10 = __toESM(require("../compiled/picocolors/index.js"));
7015
+ init_helpers();
7028
7016
  init_logger();
7029
7017
  init_restart();
7030
- isCliShortcutsEnabled = (devConfig) => devConfig.cliShortcuts && process.stdin.isTTY && !process.env.CI;
7018
+ isCliShortcutsEnabled = (devConfig) => devConfig.cliShortcuts && isTTY("stdin");
7031
7019
  }
7032
7020
  });
7033
7021
 
@@ -10374,6 +10362,19 @@ var init_asset = __esm({
10374
10362
  if (!emitAssets) {
10375
10363
  chain.module.generator.merge({ "asset/resource": { emit: false } });
10376
10364
  }
10365
+ const { assetsInclude } = config.source;
10366
+ if (assetsInclude) {
10367
+ const { dataUriLimit } = config.output;
10368
+ const rule = chain.module.rule("additional-assets").test(assetsInclude);
10369
+ const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit.assets;
10370
+ chainStaticAssetRule({
10371
+ emit: emitAssets,
10372
+ rule,
10373
+ maxSize,
10374
+ filename: assetsFilename,
10375
+ assetType: "additional"
10376
+ });
10377
+ }
10377
10378
  });
10378
10379
  }
10379
10380
  });
@@ -13609,7 +13610,7 @@ var init_init = __esm({
13609
13610
 
13610
13611
  // src/cli/commands.ts
13611
13612
  function runCli() {
13612
- program.name("rsbuild").usage("<command> [options]").version("1.0.17");
13613
+ program.name("rsbuild").usage("<command> [options]").version("1.0.18");
13613
13614
  const devCommand = program.command("dev");
13614
13615
  const buildCommand = program.command("build");
13615
13616
  const previewCommand = program.command("preview");
@@ -13718,7 +13719,7 @@ function prepareCli() {
13718
13719
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
13719
13720
  console.log();
13720
13721
  }
13721
- import_rslog.logger.greet(` ${`Rsbuild v${"1.0.17"}`}
13722
+ import_rslog.logger.greet(` ${`Rsbuild v${"1.0.18"}`}
13722
13723
  `);
13723
13724
  }
13724
13725
  var import_node_module;
@@ -13747,6 +13748,7 @@ __export(internal_exports, {
13747
13748
  initHooks: () => initHooks,
13748
13749
  initPlugins: () => initPlugins,
13749
13750
  initRsbuildConfig: () => initRsbuildConfig,
13751
+ isPlainObject: () => isPlainObject,
13750
13752
  modifyBundlerChain: () => modifyBundlerChain,
13751
13753
  onCompileDone: () => onCompileDone,
13752
13754
  outputInspectConfigFiles: () => outputInspectConfigFiles,
@@ -13804,7 +13806,7 @@ init_logger();
13804
13806
  init_mergeConfig();
13805
13807
  init_helpers();
13806
13808
  init_constants();
13807
- var version = "1.0.17";
13809
+ var version = "1.0.18";
13808
13810
  // Annotate the CommonJS export names for ESM import in node:
13809
13811
  0 && (module.exports = {
13810
13812
  PLUGIN_CSS_NAME,
package/dist/index.js CHANGED
@@ -3773,7 +3773,7 @@ function pick(obj, keys) {
3773
3773
  {}
3774
3774
  );
3775
3775
  }
3776
- var import_deepmerge, rspackMinVersion, getNodeEnv, setNodeEnv, isFunction, isObject, isPlainObject, castArray, cloneDeep, compareSemver, isSatisfyRspackVersion, removeLeadingSlash, removeTailingSlash, addTrailingSlash, formatPublicPath, getPublicPathFromChain, getPublicPathFromCompiler, urlJoin, canParse, ensureAssetPrefix, applyToCompiler, upperFirst, isURL, createVirtualModule, isMultiCompiler, camelCase, prettyTime;
3776
+ var import_deepmerge, rspackMinVersion, getNodeEnv, setNodeEnv, isFunction, isObject, isPlainObject, castArray, cloneDeep, compareSemver, isSatisfyRspackVersion, removeLeadingSlash, removeTailingSlash, addTrailingSlash, formatPublicPath, getPublicPathFromChain, getPublicPathFromCompiler, urlJoin, canParse, ensureAssetPrefix, applyToCompiler, upperFirst, isURL, createVirtualModule, isMultiCompiler, camelCase, prettyTime, isTTY;
3777
3777
  var init_helpers = __esm({
3778
3778
  "src/helpers/index.ts"() {
3779
3779
  "use strict";
@@ -3790,19 +3790,8 @@ var init_helpers = __esm({
3790
3790
  };
3791
3791
  isFunction = (func) => typeof func === "function";
3792
3792
  isObject = (obj) => Object.prototype.toString.call(obj) === "[object Object]";
3793
- isPlainObject = (o) => {
3794
- if (isObject(o) === false)
3795
- return false;
3796
- const ctor = o.constructor;
3797
- if (ctor === void 0)
3798
- return true;
3799
- const prot = ctor.prototype;
3800
- if (isObject(prot) === false)
3801
- return false;
3802
- if (prot.hasOwnProperty("isPrototypeOf") === false) {
3803
- return false;
3804
- }
3805
- return true;
3793
+ isPlainObject = (obj) => {
3794
+ return obj !== null && typeof obj === "object" && Object.getPrototypeOf(obj) === Object.prototype;
3806
3795
  };
3807
3796
  castArray = (arr) => {
3808
3797
  if (arr === void 0) {
@@ -3929,6 +3918,9 @@ var init_helpers = __esm({
3929
3918
  const minutes = seconds / 60;
3930
3919
  return `${format(minutes.toFixed(2))} m`;
3931
3920
  };
3921
+ isTTY = (type = "stdout") => {
3922
+ return (type === "stdin" ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
3923
+ };
3932
3924
  }
3933
3925
  });
3934
3926
 
@@ -4011,13 +4003,14 @@ var init_restart = __esm({
4011
4003
  "use strict";
4012
4004
  init_esm();
4013
4005
  init_init();
4006
+ init_helpers();
4014
4007
  init_logger();
4015
4008
  cleaners = [];
4016
4009
  onBeforeRestartServer = (cleaner) => {
4017
4010
  cleaners.push(cleaner);
4018
4011
  };
4019
4012
  clearConsole = () => {
4020
- if (process.stdout.isTTY && !process.env.DEBUG) {
4013
+ if (isTTY() && !process.env.DEBUG) {
4021
4014
  process.stdout.write("\x1B[H\x1B[2J");
4022
4015
  }
4023
4016
  };
@@ -4343,7 +4336,8 @@ var init_config = __esm({
4343
4336
  svg: DEFAULT_DATA_URL_SIZE,
4344
4337
  font: DEFAULT_DATA_URL_SIZE,
4345
4338
  image: DEFAULT_DATA_URL_SIZE,
4346
- media: DEFAULT_DATA_URL_SIZE
4339
+ media: DEFAULT_DATA_URL_SIZE,
4340
+ assets: DEFAULT_DATA_URL_SIZE
4347
4341
  },
4348
4342
  legalComments: "linked",
4349
4343
  injectStyles: false,
@@ -5230,14 +5224,7 @@ function createPluginManager() {
5230
5224
  continue;
5231
5225
  }
5232
5226
  validatePlugin(newPlugin);
5233
- const existPlugin = plugins.find(
5234
- (item) => item.instance.name === newPlugin.name && item.environment === environment
5235
- );
5236
- if (existPlugin) {
5237
- logger.warn(
5238
- `Rsbuild plugin "${newPlugin.name}" registered multiple times.`
5239
- );
5240
- } else if (before) {
5227
+ if (before) {
5241
5228
  const index = plugins.findIndex(
5242
5229
  (item) => item.instance.name === before
5243
5230
  );
@@ -6091,7 +6078,7 @@ async function createContext(options, userConfig, bundlerType) {
6091
6078
  const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
6092
6079
  const cachePath = join6(rootPath, "node_modules", ".cache");
6093
6080
  return {
6094
- version: "1.0.17",
6081
+ version: "1.0.18",
6095
6082
  rootPath,
6096
6083
  distPath: "",
6097
6084
  cachePath,
@@ -6428,7 +6415,7 @@ var init_configChain = __esm({
6428
6415
  JS_DATA_URI: "js-data-uri",
6429
6416
  /** Rule for ts */
6430
6417
  TS: "ts",
6431
- /** Rule for css */
6418
+ /** Rule for CSS */
6432
6419
  CSS: "css",
6433
6420
  /** Rule for less */
6434
6421
  LESS: "less",
@@ -7080,9 +7067,10 @@ var init_cliShortcuts = __esm({
7080
7067
  "src/server/cliShortcuts.ts"() {
7081
7068
  "use strict";
7082
7069
  init_esm();
7070
+ init_helpers();
7083
7071
  init_logger();
7084
7072
  init_restart();
7085
- isCliShortcutsEnabled = (devConfig) => devConfig.cliShortcuts && process.stdin.isTTY && !process.env.CI;
7073
+ isCliShortcutsEnabled = (devConfig) => devConfig.cliShortcuts && isTTY("stdin");
7086
7074
  }
7087
7075
  });
7088
7076
 
@@ -10460,6 +10448,19 @@ var init_asset = __esm({
10460
10448
  if (!emitAssets) {
10461
10449
  chain.module.generator.merge({ "asset/resource": { emit: false } });
10462
10450
  }
10451
+ const { assetsInclude } = config.source;
10452
+ if (assetsInclude) {
10453
+ const { dataUriLimit } = config.output;
10454
+ const rule = chain.module.rule("additional-assets").test(assetsInclude);
10455
+ const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit.assets;
10456
+ chainStaticAssetRule({
10457
+ emit: emitAssets,
10458
+ rule,
10459
+ maxSize,
10460
+ filename: assetsFilename,
10461
+ assetType: "additional"
10462
+ });
10463
+ }
10463
10464
  });
10464
10465
  }
10465
10466
  });
@@ -13727,7 +13728,7 @@ var init_init = __esm({
13727
13728
 
13728
13729
  // src/cli/commands.ts
13729
13730
  function runCli() {
13730
- program.name("rsbuild").usage("<command> [options]").version("1.0.17");
13731
+ program.name("rsbuild").usage("<command> [options]").version("1.0.18");
13731
13732
  const devCommand = program.command("dev");
13732
13733
  const buildCommand = program.command("build");
13733
13734
  const previewCommand = program.command("preview");
@@ -13838,7 +13839,7 @@ function prepareCli() {
13838
13839
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
13839
13840
  console.log();
13840
13841
  }
13841
- logger.greet(` ${`Rsbuild v${"1.0.17"}`}
13842
+ logger.greet(` ${`Rsbuild v${"1.0.18"}`}
13842
13843
  `);
13843
13844
  }
13844
13845
  var init_prepare = __esm({
@@ -13866,6 +13867,7 @@ __export(internal_exports, {
13866
13867
  initHooks: () => initHooks,
13867
13868
  initPlugins: () => initPlugins,
13868
13869
  initRsbuildConfig: () => initRsbuildConfig,
13870
+ isPlainObject: () => isPlainObject,
13869
13871
  modifyBundlerChain: () => modifyBundlerChain,
13870
13872
  onCompileDone: () => onCompileDone,
13871
13873
  outputInspectConfigFiles: () => outputInspectConfigFiles,
@@ -13909,7 +13911,7 @@ init_mergeConfig();
13909
13911
  init_helpers();
13910
13912
  init_constants();
13911
13913
  import { rspack as rspack10 } from "@rspack/core";
13912
- var version = "1.0.17";
13914
+ var version = "1.0.18";
13913
13915
  export {
13914
13916
  PLUGIN_CSS_NAME,
13915
13917
  PLUGIN_SWC_NAME,
@@ -20,7 +20,7 @@ export declare const CHAIN_ID: {
20
20
  readonly JS_DATA_URI: "js-data-uri";
21
21
  /** Rule for ts */
22
22
  readonly TS: "ts";
23
- /** Rule for css */
23
+ /** Rule for CSS */
24
24
  readonly CSS: "css";
25
25
  /** Rule for less */
26
26
  readonly LESS: "less";
@@ -10,7 +10,7 @@ export declare const setNodeEnv: (env: string) => void;
10
10
  export declare const isNil: (o: unknown) => o is undefined | null;
11
11
  export declare const isFunction: (func: unknown) => func is (...args: any[]) => any;
12
12
  export declare const isObject: (obj: unknown) => obj is Record<string, any>;
13
- export declare const isPlainObject: (o: unknown) => o is Record<string, any>;
13
+ export declare const isPlainObject: (obj: unknown) => obj is Record<string, any>;
14
14
  export declare const castArray: <T>(arr?: T | T[]) => T[];
15
15
  export declare const cloneDeep: <T>(value: T) => T;
16
16
  export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
@@ -37,3 +37,7 @@ export declare const isMultiCompiler: <C extends Rspack.Compiler | WebpackCompil
37
37
  export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Pick<T, U>;
38
38
  export declare const camelCase: (input: string) => string;
39
39
  export declare const prettyTime: (seconds: number) => string;
40
+ /**
41
+ * Check if running in a TTY context
42
+ */
43
+ export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
@@ -11,7 +11,7 @@ export { initRsbuildConfig } from './provider/initConfigs';
11
11
  export { stringifyConfig, getRsbuildInspectConfig, outputInspectConfigFiles, } from './config';
12
12
  export type { InternalContext } from './types';
13
13
  export { setHTMLPlugin, getHTMLPlugin } from './pluginHelper';
14
- export { formatStats, getStatsOptions, prettyTime } from './helpers';
14
+ export { formatStats, getStatsOptions, prettyTime, isPlainObject, } from './helpers';
15
15
  export { registerBuildHook, registerDevHook, onCompileDone } from './hooks';
16
16
  export { getChainUtils, getConfigUtils } from './provider/rspackConfig';
17
17
  export { chainToConfig, modifyBundlerChain } from './configChain';
@@ -1,7 +1,7 @@
1
1
  import type { SwcLoaderOptions } from '@rspack/core';
2
2
  import type { NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
3
3
  /**
4
- * Provide some swc configs of rspack
4
+ * Provide some SWC configs of Rspack
5
5
  */
6
6
  export declare const pluginSwc: () => RsbuildPlugin;
7
7
  export declare function applySwcDecoratorConfig(swcConfig: SwcLoaderOptions, config: NormalizedEnvironmentConfig): void;
@@ -9,7 +9,7 @@ export type MiddlewareCallbacks = {
9
9
  onDone: (stats: any) => void;
10
10
  };
11
11
  export type DevMiddlewareOptions = {
12
- /** To ensure HMR works, the devMiddleware need inject the hmr client path into page when HMR enable. */
12
+ /** To ensure HMR works, the devMiddleware need inject the HMR client path into page when HMR enable. */
13
13
  clientPaths?: string[];
14
14
  clientConfig: DevConfig['client'];
15
15
  publicPath?: string;
@@ -19,7 +19,7 @@ export type DevMiddlewareAPI = Middleware & {
19
19
  /**
20
20
  * The rsbuild/server do nothing about compiler, the devMiddleware need do such things to ensure dev works well:
21
21
  * - Call compiler.watch (normally did by rsbuild-dev-middleware).
22
- * - Inject the hmr client path into page (the hmr client rsbuild/server already provide).
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
25
  export type DevMiddleware = (options: DevMiddlewareOptions) => DevMiddlewareAPI;
@@ -107,6 +107,11 @@ export interface SourceConfig {
107
107
  * and the `alias` option in the bundler.
108
108
  */
109
109
  aliasStrategy?: AliasStrategy;
110
+ /**
111
+ * Include additional files that should be treated as static assets.
112
+ * @default undefined
113
+ */
114
+ assetsInclude?: Rspack.RuleSetCondition;
110
115
  /**
111
116
  * Specify directories or modules that need additional compilation.
112
117
  * In order to maintain faster compilation speed, Rsbuild will not compile files under node_modules through
@@ -529,47 +534,78 @@ export type FilenameConfig = {
529
534
  assets?: string;
530
535
  };
531
536
  export type DataUriLimit = {
532
- /** The data URI limit of the SVG image. */
537
+ /**
538
+ * The data URI limit of the SVG image.
539
+ * @default 4096
540
+ */
533
541
  svg?: number;
534
- /** The data URI limit of the font file. */
542
+ /**
543
+ * The data URI limit of the font file.
544
+ * @default 4096
545
+ */
535
546
  font?: number;
536
- /** The data URI limit of non-SVG images. */
547
+ /**
548
+ * The data URI limit of non-SVG images.
549
+ * @default 4096
550
+ */
537
551
  image?: number;
538
- /** The data URI limit of media resources such as videos. */
552
+ /**
553
+ * The data URI limit of media resources such as videos.
554
+ * @default 4096
555
+ */
539
556
  media?: number;
557
+ /**
558
+ * The data URI limit of other static assets.
559
+ * @default 4096
560
+ */
561
+ assets?: number;
540
562
  };
541
563
  export type Charset = 'ascii' | 'utf8';
542
564
  export type LegalComments = 'none' | 'inline' | 'linked';
543
565
  export type NormalizedDataUriLimit = Required<DataUriLimit>;
544
566
  export type Polyfill = 'usage' | 'entry' | 'off';
545
567
  export type SourceMap = {
568
+ /**
569
+ * The source map type for JavaScript files.
570
+ * @default isDev ? 'cheap-module-source-map' : false
571
+ */
546
572
  js?: Rspack.Configuration['devtool'];
573
+ /**
574
+ * Whether to generate source map for CSS files.
575
+ * @default false
576
+ */
547
577
  css?: boolean;
548
578
  };
549
579
  export type CSSModulesLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
550
580
  export type CSSModules = {
551
581
  /**
552
582
  * Allows CSS Modules to be automatically enabled based on their filenames.
583
+ * @default true
553
584
  */
554
585
  auto?: CSSLoaderModulesOptions['auto'];
555
586
  /**
556
587
  * Allows exporting names from global class names, so you can use them via import.
588
+ * @default false
557
589
  */
558
590
  exportGlobals?: boolean;
559
591
  /**
560
592
  * Style of exported class names.
593
+ * @default 'camelCase'
561
594
  */
562
595
  exportLocalsConvention?: CSSModulesLocalsConvention;
563
596
  /**
564
597
  * Set the local ident name of CSS Modules.
598
+ * @default isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'
565
599
  */
566
600
  localIdentName?: string;
567
601
  /**
568
602
  * Controls the level of compilation applied to the input styles.
603
+ * @default 'local'
569
604
  */
570
605
  mode?: CSSLoaderModulesOptions['mode'];
571
606
  /**
572
607
  * Whether to enable ES modules named export for locals.
608
+ * @default false
573
609
  */
574
610
  namedExport?: boolean;
575
611
  };
@@ -609,6 +645,7 @@ export interface OutputConfig {
609
645
  /**
610
646
  * At build time, prevent some `import` dependencies from being packed into bundles in your code, and instead fetch them externally at runtime.
611
647
  * For more information, please see: [Rspack Externals](https://rspack.dev/config/externals)
648
+ * @default undefined
612
649
  */
613
650
  externals?: Externals;
614
651
  /**
@@ -628,12 +665,14 @@ export interface OutputConfig {
628
665
  charset?: Charset;
629
666
  /**
630
667
  * Configure how the polyfill is injected.
668
+ * @default 'off'
631
669
  */
632
670
  polyfill?: Polyfill;
633
671
  /**
634
672
  * When using CDN in the production,
635
673
  * you can use this option to set the URL prefix of static assets,
636
674
  * similar to the output.publicPath config of webpack.
675
+ * @default `server.base`
637
676
  */
638
677
  assetPrefix?: string;
639
678
  /**
@@ -647,6 +686,7 @@ export interface OutputConfig {
647
686
  * comment in CSS that contains @license or @preserve or that starts with //! or /\*!.
648
687
  * These comments are preserved in output files by default since that follows the intent
649
688
  * of the original authors of the code.
689
+ * @default 'linked'
650
690
  */
651
691
  legalComments?: LegalComments;
652
692
  /**
@@ -660,30 +700,44 @@ export interface OutputConfig {
660
700
  cssModules?: CSSModules;
661
701
  /**
662
702
  * Whether to disable code minification in production build.
703
+ * @default true
663
704
  */
664
705
  minify?: Minify;
665
706
  /**
666
707
  * Whether to generate manifest file.
708
+ * @default false
667
709
  */
668
710
  manifest?: string | boolean;
669
711
  /**
670
- * Whether to generate source map files, and which format of source map to generate
712
+ * Whether to generate source map files, and which format of source map to generate.
713
+ *
714
+ * @default
715
+ * ```js
716
+ * const defaultSourceMap = {
717
+ * js: isDev ? 'cheap-module-source-map' : false,
718
+ * css: false,
719
+ * };
720
+ * ```
671
721
  */
672
722
  sourceMap?: SourceMap;
673
723
  /**
674
724
  * Whether to add filename hash after production build.
725
+ * @default true
675
726
  */
676
727
  filenameHash?: boolean | string;
677
728
  /**
678
729
  * Whether to inline output scripts files (.js files) into HTML with `<script>` tags.
730
+ * @default false
679
731
  */
680
732
  inlineScripts?: InlineChunkConfig;
681
733
  /**
682
734
  * Whether to inline output style files (.css files) into html with `<style>` tags.
735
+ * @default false
683
736
  */
684
737
  inlineStyles?: InlineChunkConfig;
685
738
  /**
686
739
  * Whether to inject styles into the DOM via `style-loader`.
740
+ * @default false
687
741
  */
688
742
  injectStyles?: boolean;
689
743
  /**
@@ -691,26 +745,25 @@ export interface OutputConfig {
691
745
  * This value will be used by [SWC](https://github.com/swc-project/swc) and
692
746
  * [Lightning CSS](https://github.com/parcel-bundler/lightningcss) to identify the JavaScript syntax that
693
747
  * need to be transformed and the CSS browser prefixes that need to be added.
748
+ * @default undefined
694
749
  */
695
750
  overrideBrowserslist?: string[];
696
751
  /**
697
752
  * Copies the specified file or directory to the dist directory.
753
+ * @default undefined
698
754
  */
699
755
  copy?: CopyRspackPluginOptions | CopyRspackPluginOptions['patterns'];
700
756
  /**
701
757
  * Whether to emit static assets such as image, font, etc.
702
758
  * Return `false` to avoid outputting unnecessary assets for some scenarios such as SSR.
759
+ * @default true
703
760
  */
704
761
  emitAssets?: boolean;
705
762
  }
706
763
  export interface NormalizedOutputConfig extends OutputConfig {
707
764
  target: RsbuildTarget;
708
765
  filename: FilenameConfig;
709
- distPath: Omit<Required<DistPathConfig>, 'jsAsync' | 'cssAsync' | 'js'> & {
710
- js?: string;
711
- jsAsync?: string;
712
- cssAsync?: string;
713
- };
766
+ distPath: Omit<Required<DistPathConfig>, 'jsAsync' | 'cssAsync' | 'js'> & Pick<DistPathConfig, 'jsAsync' | 'cssAsync' | 'js'>;
714
767
  polyfill: Polyfill;
715
768
  sourceMap: {
716
769
  js?: Rspack.Configuration['devtool'];
@@ -809,27 +862,40 @@ export type AppIcon = {
809
862
  export interface HtmlConfig {
810
863
  /**
811
864
  * Configure the `<meta>` tag of the HTML.
865
+ *
866
+ * @default
867
+ * ```js
868
+ * const defaultMeta = {
869
+ * charset: { charset: 'UTF-8' },
870
+ * viewport: 'width=device-width, initial-scale=1.0',
871
+ * };
872
+ * ```
812
873
  */
813
874
  meta?: ChainedHtmlOption<MetaOptions>;
814
875
  /**
815
876
  * Set the title tag of the HTML page.
877
+ * @default 'Rsbuild App'
816
878
  */
817
879
  title?: ChainedHtmlOption<string>;
818
880
  /**
819
881
  * Set the inject position of the `<script>` tag.
882
+ * @default 'head'
820
883
  */
821
884
  inject?: ChainedHtmlOption<ScriptInject>;
822
885
  /**
823
886
  * Inject custom html tags into the output html files.
887
+ * @default undefined
824
888
  */
825
889
  tags?: OneOrMany<HtmlTagDescriptor>;
826
890
  /**
827
891
  * Set the favicon icon for all pages.
892
+ * @default undefined
828
893
  */
829
894
  favicon?: ChainedHtmlOption<string>;
830
895
  /**
831
896
  * Set the web application icons to display when added to the home screen of a mobile device.
832
897
  *
898
+ * @default undefined
833
899
  * @example
834
900
  * appIcon: {
835
901
  * name: 'My Website',
@@ -842,20 +908,24 @@ export interface HtmlConfig {
842
908
  appIcon?: AppIcon;
843
909
  /**
844
910
  * Set the id of root element.
911
+ * @default 'root'
845
912
  */
846
913
  mountId?: string;
847
914
  /**
848
915
  * Set the [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) attribute
849
916
  * of the `<script>` tag.
917
+ * @default false
850
918
  */
851
919
  crossorigin?: boolean | CrossOrigin;
852
920
  /**
853
921
  * Define the directory structure of the HTML output files.
922
+ * @default 'flat'
854
923
  */
855
924
  outputStructure?: OutputStructure;
856
925
  /**
857
926
  * Define the path to the HTML template,
858
927
  * corresponding to the `template` config of [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin).
928
+ * @default A built-in HTML template
859
929
  */
860
930
  template?: ChainedHtmlOption<string>;
861
931
  /**
@@ -867,6 +937,7 @@ export interface HtmlConfig {
867
937
  }>;
868
938
  /**
869
939
  * Set the loading mode of the `<script>` tag.
940
+ * @default 'defer'
870
941
  */
871
942
  scriptLoading?: ScriptLoading;
872
943
  }
@@ -73,10 +73,12 @@ export type PluginManager = {
73
73
  environment: string;
74
74
  }) => RsbuildPlugin[];
75
75
  addPlugins: (plugins: Array<RsbuildPlugin | Falsy>, options?: {
76
+ /**
77
+ * Insert before the specified plugin.
78
+ */
76
79
  before?: string;
77
80
  /**
78
81
  * Add a plugin for the specified environment.
79
- *
80
82
  * If environment is not specified, it will be registered as a global plugin (effective in all environments)
81
83
  */
82
84
  environment?: string;
@@ -36,7 +36,7 @@ export type CSSLoaderModulesMode = 'local' | 'global' | 'pure' | 'icss' | ((reso
36
36
  export type CSSLoaderExportLocalsConvention = 'asIs' | 'as-is' | 'camelCase' | 'camel-case' | 'camelCaseOnly' | 'camel-case-only' | 'dashes' | 'dashesOnly' | 'dashes-only' | ((name: string) => string);
37
37
  export interface CSSLoaderModulesOptions {
38
38
  /**
39
- * Allows auto enable CSS modules/ICSS based on the filename, query or fragment.
39
+ * Allows auto enable CSS Modules/ICSS based on the filename, query or fragment.
40
40
  */
41
41
  auto?: boolean | RegExp | ((resourcePath: string, resourceQuery: string, resourceFragment: string) => boolean);
42
42
  /**
@@ -88,7 +88,7 @@ export interface CSSLoaderModulesOptions {
88
88
  */
89
89
  namedExport?: boolean;
90
90
  /**
91
- * Enables a callback to output the CSS modules mapping JSON.
91
+ * Enables a callback to output the CSS Modules mapping JSON.
92
92
  */
93
93
  getJSON?: (context: {
94
94
  resourcePath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {