@rsbuild/core 1.0.15 → 1.0.16

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.
@@ -16,8 +16,13 @@ declare class HtmlRspackPlugin {
16
16
 
17
17
  apply(compiler: Compiler): void;
18
18
 
19
+ /**
20
+ * @deprecated use `getCompilationHooks` instead
21
+ */
19
22
  static getHooks(compilation: Compilation): HtmlRspackPlugin.Hooks;
20
23
 
24
+ static getCompilationHooks(compilation: Compilation): HtmlRspackPlugin.Hooks;
25
+
21
26
  /**
22
27
  * Static helper to create a tag object to be get injected into the dom
23
28
  */
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 241: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 825: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(361);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(201);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -304,7 +304,7 @@
304
304
  }
305
305
  module.exports = { CachedChildCompilation };
306
306
  },
307
- 361: (module) => {
307
+ 201: (module) => {
308
308
  "use strict";
309
309
  class HtmlWebpackChildCompiler {
310
310
  constructor(templates) {
@@ -473,7 +473,7 @@
473
473
  }
474
474
  module.exports = { HtmlWebpackChildCompiler };
475
475
  },
476
- 479: (module) => {
476
+ 928: (module) => {
477
477
  "use strict";
478
478
  module.exports = {};
479
479
  module.exports.none = (chunks) => chunks;
@@ -492,7 +492,7 @@
492
492
  };
493
493
  module.exports.auto = module.exports.none;
494
494
  },
495
- 135: (module) => {
495
+ 627: (module) => {
496
496
  "use strict";
497
497
  module.exports = function (err) {
498
498
  return {
@@ -513,7 +513,7 @@
513
513
  };
514
514
  };
515
515
  },
516
- 935: (module, __unused_webpack_exports, __nccwpck_require__) => {
516
+ 766: (module, __unused_webpack_exports, __nccwpck_require__) => {
517
517
  "use strict";
518
518
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(348);
519
519
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -539,7 +539,7 @@
539
539
  }
540
540
  module.exports = { getHtmlRspackPluginHooks };
541
541
  },
542
- 697: (module) => {
542
+ 217: (module) => {
543
543
  const voidTags = [
544
544
  "area",
545
545
  "base",
@@ -607,19 +607,19 @@
607
607
  htmlTagObjectToString,
608
608
  };
609
609
  },
610
- 922: (module, __unused_webpack_exports, __nccwpck_require__) => {
610
+ 175: (module, __unused_webpack_exports, __nccwpck_require__) => {
611
611
  "use strict";
612
612
  const promisify = __nccwpck_require__(837).promisify;
613
613
  const vm = __nccwpck_require__(144);
614
614
  const fs = __nccwpck_require__(147);
615
615
  const path = __nccwpck_require__(17);
616
- const { CachedChildCompilation } = __nccwpck_require__(241);
616
+ const { CachedChildCompilation } = __nccwpck_require__(825);
617
617
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
618
- __nccwpck_require__(697);
619
- const prettyError = __nccwpck_require__(135);
620
- const chunkSorter = __nccwpck_require__(479);
618
+ __nccwpck_require__(217);
619
+ const prettyError = __nccwpck_require__(627);
620
+ const chunkSorter = __nccwpck_require__(928);
621
621
  const getHtmlRspackPluginHooks =
622
- __nccwpck_require__(935).getHtmlRspackPluginHooks;
622
+ __nccwpck_require__(766).getHtmlRspackPluginHooks;
623
623
  class HtmlRspackPlugin {
624
624
  constructor(userOptions = {}) {
625
625
  this.version = HtmlRspackPlugin.version;
@@ -1265,7 +1265,7 @@
1265
1265
  fileContent,
1266
1266
  compilation,
1267
1267
  ) {
1268
- if (/\[\\*([\w:]+)\\*\]/i.test(filename) === false) {
1268
+ if (/\[(?:[\w:]+)\]/.test(filename) === false) {
1269
1269
  return { path: filename, info: {} };
1270
1270
  }
1271
1271
  const hash = compiler.webpack.util.createHash(
@@ -1530,6 +1530,7 @@
1530
1530
  };
1531
1531
  }
1532
1532
  HtmlRspackPlugin.version = 6;
1533
+ HtmlRspackPlugin.getCompilationHooks = getHtmlRspackPluginHooks;
1533
1534
  HtmlRspackPlugin.getHooks = getHtmlRspackPluginHooks;
1534
1535
  HtmlRspackPlugin.createHtmlTagObject = createHtmlTagObject;
1535
1536
  module.exports = HtmlRspackPlugin;
@@ -1577,6 +1578,6 @@
1577
1578
  }
1578
1579
  if (typeof __nccwpck_require__ !== "undefined")
1579
1580
  __nccwpck_require__.ab = __dirname + "/";
1580
- var __webpack_exports__ = __nccwpck_require__(922);
1581
+ var __webpack_exports__ = __nccwpck_require__(175);
1581
1582
  module.exports = __webpack_exports__;
1582
1583
  })();
@@ -1 +1 @@
1
- {"name":"html-rspack-plugin","author":"Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)","version":"6.0.1","funding":{"type":"opencollective","url":"https://opencollective.com/html-webpack-plugin"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"html-rspack-plugin","author":"Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)","version":"6.0.2","funding":{"type":"opencollective","url":"https://opencollective.com/html-webpack-plugin"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
package/dist/index.cjs CHANGED
@@ -6018,7 +6018,7 @@ async function createContext(options, userConfig, bundlerType) {
6018
6018
  const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
6019
6019
  const cachePath = (0, import_node_path10.join)(rootPath, "node_modules", ".cache");
6020
6020
  return {
6021
- version: "1.0.15",
6021
+ version: "1.0.16",
6022
6022
  rootPath,
6023
6023
  distPath: "",
6024
6024
  cachePath,
@@ -6504,6 +6504,16 @@ async function getConfigUtils(config, chainUtils) {
6504
6504
  }
6505
6505
  config.module.rules.unshift(...ruleArr);
6506
6506
  },
6507
+ appendRules(rules) {
6508
+ const ruleArr = castArray(rules);
6509
+ if (!config.module) {
6510
+ config.module = {};
6511
+ }
6512
+ if (!config.module.rules) {
6513
+ config.module.rules = [];
6514
+ }
6515
+ config.module.rules.push(...ruleArr);
6516
+ },
6507
6517
  prependPlugins(plugins) {
6508
6518
  const pluginArr = castArray(plugins);
6509
6519
  if (!config.plugins) {
@@ -9853,11 +9863,18 @@ var init_output = __esm({
9853
9863
  const extractPluginOptions = config.tools.cssExtract.pluginOptions;
9854
9864
  const cssPath = config.output.distPath.css;
9855
9865
  const cssFilename = getFilename(config, "css", isProd);
9866
+ const isCssFilenameFn = typeof cssFilename === "function";
9856
9867
  const cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : "async");
9857
9868
  chain.plugin(CHAIN_ID2.PLUGIN.MINI_CSS_EXTRACT).use(getCssExtractPlugin(), [
9858
9869
  {
9859
- filename: import_node_path22.posix.join(cssPath, cssFilename),
9860
- chunkFilename: import_node_path22.posix.join(cssAsyncPath, cssFilename),
9870
+ filename: isCssFilenameFn ? (...args) => {
9871
+ const name = cssFilename(...args);
9872
+ return import_node_path22.posix.join(cssPath, name);
9873
+ } : import_node_path22.posix.join(cssPath, cssFilename),
9874
+ chunkFilename: isCssFilenameFn ? (...args) => {
9875
+ const name = cssFilename(...args);
9876
+ return import_node_path22.posix.join(cssAsyncPath, name);
9877
+ } : import_node_path22.posix.join(cssAsyncPath, cssFilename),
9861
9878
  ...extractPluginOptions
9862
9879
  }
9863
9880
  ]);
@@ -12599,10 +12616,16 @@ function pluginModuleFederation() {
12599
12616
  if (!moduleFederation?.options) {
12600
12617
  return;
12601
12618
  }
12602
- if (moduleFederation.options.exposes && config.server?.port && !config.dev?.client?.port) {
12619
+ if (moduleFederation.options.exposes) {
12603
12620
  config.dev ||= {};
12604
- config.dev.client ||= {};
12605
- config.dev.client.port = config.server.port;
12621
+ if (config.server?.port && !config.dev.client?.port) {
12622
+ config.dev.client ||= {};
12623
+ config.dev.client.port = config.server.port;
12624
+ }
12625
+ const originalConfig = api.getRsbuildConfig("original");
12626
+ if (originalConfig.dev?.assetPrefix === void 0 && config.dev.assetPrefix === DEFAULT_ASSET_PREFIX) {
12627
+ config.dev.assetPrefix = true;
12628
+ }
12606
12629
  }
12607
12630
  });
12608
12631
  api.modifyEnvironmentConfig((config) => {
@@ -12637,10 +12660,6 @@ function pluginModuleFederation() {
12637
12660
  chain.output.set("uniqueName", options.name);
12638
12661
  }
12639
12662
  }
12640
- const publicPath = chain.output.get("publicPath");
12641
- if (publicPath === DEFAULT_ASSET_PREFIX) {
12642
- chain.output.set("publicPath", "auto");
12643
- }
12644
12663
  }
12645
12664
  );
12646
12665
  }
@@ -13564,7 +13583,7 @@ var init_init = __esm({
13564
13583
 
13565
13584
  // src/cli/commands.ts
13566
13585
  function runCli() {
13567
- program.name("rsbuild").usage("<command> [options]").version("1.0.15");
13586
+ program.name("rsbuild").usage("<command> [options]").version("1.0.16");
13568
13587
  const devCommand = program.command("dev");
13569
13588
  const buildCommand = program.command("build");
13570
13589
  const previewCommand = program.command("preview");
@@ -13673,7 +13692,7 @@ function prepareCli() {
13673
13692
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
13674
13693
  console.log();
13675
13694
  }
13676
- import_rslog.logger.greet(` ${`Rsbuild v${"1.0.15"}`}
13695
+ import_rslog.logger.greet(` ${`Rsbuild v${"1.0.16"}`}
13677
13696
  `);
13678
13697
  }
13679
13698
  var import_node_module;
@@ -13759,7 +13778,7 @@ init_logger();
13759
13778
  init_mergeConfig();
13760
13779
  init_helpers();
13761
13780
  init_constants();
13762
- var version = "1.0.15";
13781
+ var version = "1.0.16";
13763
13782
  // Annotate the CommonJS export names for ESM import in node:
13764
13783
  0 && (module.exports = {
13765
13784
  PLUGIN_CSS_NAME,
package/dist/index.js CHANGED
@@ -6067,7 +6067,7 @@ async function createContext(options, userConfig, bundlerType) {
6067
6067
  const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
6068
6068
  const cachePath = join6(rootPath, "node_modules", ".cache");
6069
6069
  return {
6070
- version: "1.0.15",
6070
+ version: "1.0.16",
6071
6071
  rootPath,
6072
6072
  distPath: "",
6073
6073
  cachePath,
@@ -6559,6 +6559,16 @@ async function getConfigUtils(config, chainUtils) {
6559
6559
  }
6560
6560
  config.module.rules.unshift(...ruleArr);
6561
6561
  },
6562
+ appendRules(rules) {
6563
+ const ruleArr = castArray(rules);
6564
+ if (!config.module) {
6565
+ config.module = {};
6566
+ }
6567
+ if (!config.module.rules) {
6568
+ config.module.rules = [];
6569
+ }
6570
+ config.module.rules.push(...ruleArr);
6571
+ },
6562
6572
  prependPlugins(plugins) {
6563
6573
  const pluginArr = castArray(plugins);
6564
6574
  if (!config.plugins) {
@@ -9935,11 +9945,18 @@ var init_output = __esm({
9935
9945
  const extractPluginOptions = config.tools.cssExtract.pluginOptions;
9936
9946
  const cssPath = config.output.distPath.css;
9937
9947
  const cssFilename = getFilename2(config, "css", isProd);
9948
+ const isCssFilenameFn = typeof cssFilename === "function";
9938
9949
  const cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : "async");
9939
9950
  chain.plugin(CHAIN_ID2.PLUGIN.MINI_CSS_EXTRACT).use(getCssExtractPlugin(), [
9940
9951
  {
9941
- filename: posix4.join(cssPath, cssFilename),
9942
- chunkFilename: posix4.join(cssAsyncPath, cssFilename),
9952
+ filename: isCssFilenameFn ? (...args) => {
9953
+ const name = cssFilename(...args);
9954
+ return posix4.join(cssPath, name);
9955
+ } : posix4.join(cssPath, cssFilename),
9956
+ chunkFilename: isCssFilenameFn ? (...args) => {
9957
+ const name = cssFilename(...args);
9958
+ return posix4.join(cssAsyncPath, name);
9959
+ } : posix4.join(cssAsyncPath, cssFilename),
9943
9960
  ...extractPluginOptions
9944
9961
  }
9945
9962
  ]);
@@ -12711,10 +12728,16 @@ function pluginModuleFederation() {
12711
12728
  if (!moduleFederation?.options) {
12712
12729
  return;
12713
12730
  }
12714
- if (moduleFederation.options.exposes && config.server?.port && !config.dev?.client?.port) {
12731
+ if (moduleFederation.options.exposes) {
12715
12732
  config.dev ||= {};
12716
- config.dev.client ||= {};
12717
- config.dev.client.port = config.server.port;
12733
+ if (config.server?.port && !config.dev.client?.port) {
12734
+ config.dev.client ||= {};
12735
+ config.dev.client.port = config.server.port;
12736
+ }
12737
+ const originalConfig = api.getRsbuildConfig("original");
12738
+ if (originalConfig.dev?.assetPrefix === void 0 && config.dev.assetPrefix === DEFAULT_ASSET_PREFIX) {
12739
+ config.dev.assetPrefix = true;
12740
+ }
12718
12741
  }
12719
12742
  });
12720
12743
  api.modifyEnvironmentConfig((config) => {
@@ -12749,10 +12772,6 @@ function pluginModuleFederation() {
12749
12772
  chain.output.set("uniqueName", options.name);
12750
12773
  }
12751
12774
  }
12752
- const publicPath = chain.output.get("publicPath");
12753
- if (publicPath === DEFAULT_ASSET_PREFIX) {
12754
- chain.output.set("publicPath", "auto");
12755
- }
12756
12775
  }
12757
12776
  );
12758
12777
  }
@@ -13682,7 +13701,7 @@ var init_init = __esm({
13682
13701
 
13683
13702
  // src/cli/commands.ts
13684
13703
  function runCli() {
13685
- program.name("rsbuild").usage("<command> [options]").version("1.0.15");
13704
+ program.name("rsbuild").usage("<command> [options]").version("1.0.16");
13686
13705
  const devCommand = program.command("dev");
13687
13706
  const buildCommand = program.command("build");
13688
13707
  const previewCommand = program.command("preview");
@@ -13793,7 +13812,7 @@ function prepareCli() {
13793
13812
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
13794
13813
  console.log();
13795
13814
  }
13796
- logger.greet(` ${`Rsbuild v${"1.0.15"}`}
13815
+ logger.greet(` ${`Rsbuild v${"1.0.16"}`}
13797
13816
  `);
13798
13817
  }
13799
13818
  var init_prepare = __esm({
@@ -13864,7 +13883,7 @@ init_mergeConfig();
13864
13883
  init_helpers();
13865
13884
  init_constants();
13866
13885
  import { rspack as rspack10 } from "@rspack/core";
13867
- var version = "1.0.15";
13886
+ var version = "1.0.16";
13868
13887
  export {
13869
13888
  PLUGIN_CSS_NAME,
13870
13889
  PLUGIN_SWC_NAME,
@@ -23,7 +23,8 @@ export declare const getPublicPathFromCompiler: (compiler: Rspack.Compiler | Rsp
23
23
  export declare const canParse: (url: string) => boolean;
24
24
  export declare const ensureAssetPrefix: (url: string, assetPrefix?: Rspack.PublicPath) => string;
25
25
  export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'js', isProd: boolean, isServer?: boolean): NonNullable<FilenameConfig['js']>;
26
- export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: Exclude<keyof FilenameConfig, 'js'>, isProd: boolean, isServer?: boolean): string;
26
+ export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'css', isProd: boolean): NonNullable<FilenameConfig['css']>;
27
+ export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: Exclude<keyof FilenameConfig, 'js' | 'css'>, isProd: boolean, isServer?: boolean): string;
27
28
  export declare function partition<T>(array: T[], predicate: (value: T) => boolean): [T[], T[]];
28
29
  export declare const applyToCompiler: (compiler: Rspack.Compiler | Rspack.MultiCompiler, apply: (c: Rspack.Compiler, index: number) => void) => void;
29
30
  export declare const upperFirst: (str: string) => string;
@@ -25,6 +25,7 @@ export type ToolsHtmlPluginConfig = ConfigChainWithContext<HtmlRspackPlugin.Opti
25
25
  }>;
26
26
  export type ModifyRspackConfigUtils = ModifyChainUtils & {
27
27
  addRules: (rules: RspackRule | RspackRule[]) => void;
28
+ appendRules: (rules: RspackRule | RspackRule[]) => void;
28
29
  prependPlugins: (plugins: BundlerPluginInstance | BundlerPluginInstance[]) => void;
29
30
  appendPlugins: (plugins: BundlerPluginInstance | BundlerPluginInstance[]) => void;
30
31
  removePlugin: (pluginName: string) => void;
@@ -495,7 +496,7 @@ export type FilenameConfig = {
495
496
  * - dev: '[name].css'
496
497
  * - prod: '[name].[contenthash:8].css'
497
498
  */
498
- css?: string;
499
+ css?: NonNullable<Rspack.Configuration['output']>['cssFilename'];
499
500
  /**
500
501
  * The name of the SVG images.
501
502
  * @default '[name].[contenthash:8].svg'
@@ -51,6 +51,7 @@ export type ModifyWebpackChainUtils = ModifyChainUtils & {
51
51
  };
52
52
  export type ModifyWebpackConfigUtils = ModifyWebpackChainUtils & {
53
53
  addRules: (rules: RuleSetRule | RuleSetRule[]) => void;
54
+ appendRules: (rules: RuleSetRule | RuleSetRule[]) => void;
54
55
  prependPlugins: (plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void;
55
56
  appendPlugins: (plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void;
56
57
  removePlugin: (pluginName: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -68,7 +68,7 @@
68
68
  "dotenv": "16.4.5",
69
69
  "dotenv-expand": "11.0.6",
70
70
  "fs-extra": "^11.2.0",
71
- "html-rspack-plugin": "6.0.1",
71
+ "html-rspack-plugin": "6.0.2",
72
72
  "http-proxy-middleware": "^2.0.6",
73
73
  "jiti": "^1.21.6",
74
74
  "launch-editor-middleware": "^2.9.1",