@rsbuild/core 1.4.10 → 1.4.11

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
@@ -914,7 +914,7 @@ for(var __webpack_i__ in (()=>{
914
914
  PLUGIN_SWC_NAME: ()=>PLUGIN_SWC_NAME,
915
915
  defaultAllowedOrigins: ()=>defaultAllowedOrigins,
916
916
  ensureAssetPrefix: ()=>ensureAssetPrefix,
917
- rspack: ()=>core_namespaceObject.rspack,
917
+ rspack: ()=>rspack_rspack,
918
918
  runCLI: ()=>runCLI,
919
919
  defineConfig: ()=>defineConfig
920
920
  });
@@ -935,7 +935,7 @@ for(var __webpack_i__ in (()=>{
935
935
  setCssExtractPlugin: ()=>setCssExtractPlugin,
936
936
  setHTMLPlugin: ()=>setHTMLPlugin
937
937
  });
938
- let core_namespaceObject = require("@rspack/core"), index_js_namespaceObject = require("../compiled/rslog/index.js"), external_node_path_namespaceObject = require("node:path");
938
+ let external_node_module_namespaceObject = require("node:module"), rspack_rspack = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__)('@rspack/core'), index_js_namespaceObject = require("../compiled/rslog/index.js"), external_node_path_namespaceObject = require("node:path");
939
939
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
940
940
  let external_node_url_namespaceObject = require("node:url");
941
941
  var cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
@@ -952,7 +952,7 @@ for(var __webpack_i__ in (()=>{
952
952
  node: [
953
953
  'node >= 16'
954
954
  ]
955
- }, HTML_REGEX = /\.html$/, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /^\?raw$/, INLINE_QUERY_REGEX = /^\?inline$/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
955
+ }, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /^\?raw$/, INLINE_QUERY_REGEX = /^\?inline$/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
956
956
  'woff',
957
957
  'woff2',
958
958
  'eot',
@@ -1257,6 +1257,8 @@ for(var __webpack_i__ in (()=>{
1257
1257
  return filename.media ?? `[name]${hash}[ext]`;
1258
1258
  case 'assets':
1259
1259
  return filename.assets ?? `[name]${hash}[ext]`;
1260
+ case 'wasm':
1261
+ return filename.wasm ?? '[hash].module.wasm';
1260
1262
  default:
1261
1263
  throw Error(`${picocolors_index_js_default().dim('[rsbuild:config]')} unknown key ${picocolors_index_js_default().yellow(type)} in ${picocolors_index_js_default().yellow('output.filename')}`);
1262
1264
  }
@@ -1873,7 +1875,7 @@ ${section.body}` : section.body).join("\n\n"));
1873
1875
  if (void 0 !== result) return result;
1874
1876
  }while (loc !== (loc = external_node_path_namespaceObject.dirname(loc)));
1875
1877
  }
1876
- let configCache = {}, external_node_module_namespaceObject = require("node:module"), OVERRIDE_PATHS = [
1878
+ let configCache = {}, OVERRIDE_PATHS = [
1877
1879
  'performance.removeConsole',
1878
1880
  'output.inlineScripts',
1879
1881
  'output.inlineStyles',
@@ -2277,7 +2279,7 @@ ${section.body}` : section.body).join("\n\n"));
2277
2279
  async function createContext(options, userConfig) {
2278
2280
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2279
2281
  return {
2280
- version: "1.4.10",
2282
+ version: "1.4.11",
2281
2283
  rootPath,
2282
2284
  distPath: '',
2283
2285
  cachePath,
@@ -2556,7 +2558,7 @@ ${section.body}` : section.body).join("\n\n"));
2556
2558
  plugin && (pluginHelper_htmlPlugin = plugin);
2557
2559
  }, getHTMLPlugin = ()=>(pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
2558
2560
  cssExtractPlugin = plugin;
2559
- }, getCssExtractPlugin = ()=>cssExtractPlugin || core_namespaceObject.rspack.CssExtractRspackPlugin;
2561
+ }, getCssExtractPlugin = ()=>cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin;
2560
2562
  async function modifyRspackConfig(context, rspackConfig, chainUtils) {
2561
2563
  var _utils_environment_config_tools;
2562
2564
  index_js_namespaceObject.logger.debug('modify Rspack config');
@@ -2607,11 +2609,10 @@ ${section.body}` : section.body).join("\n\n"));
2607
2609
  };
2608
2610
  }
2609
2611
  function getChainUtils(target, environment) {
2610
- let nodeEnv = process.env.NODE_ENV;
2611
2612
  return {
2612
- rspack: core_namespaceObject.rspack,
2613
+ rspack: rspack_rspack,
2613
2614
  environment,
2614
- env: nodeEnv,
2615
+ env: process.env.NODE_ENV,
2615
2616
  target,
2616
2617
  isDev: 'development' === environment.config.mode,
2617
2618
  isProd: 'production' === environment.config.mode,
@@ -2622,7 +2623,7 @@ ${section.body}` : section.body).join("\n\n"));
2622
2623
  };
2623
2624
  }
2624
2625
  async function generateRspackConfig({ target, context, environment }) {
2625
- let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = core_namespaceObject.rspack, rspackConfig = (await modifyBundlerChain(context, {
2626
+ let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = rspack_rspack, rspackConfig = (await modifyBundlerChain(context, {
2626
2627
  ...chainUtils,
2627
2628
  bundler: {
2628
2629
  BannerPlugin,
@@ -2839,9 +2840,9 @@ ${section.body}` : section.body).join("\n\n"));
2839
2840
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
2840
2841
  bundlerConfigs: rspackConfigs,
2841
2842
  environments: context.environments
2842
- }), !await isSatisfyRspackVersion(core_namespaceObject.rspack.rspackVersion)) throw Error(`${picocolors_index_js_default().dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${picocolors_index_js_default().green(rspackMinVersion)}`);
2843
- let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? (0, core_namespaceObject.rspack)(rspackConfigs) : (0, core_namespaceObject.rspack)(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
2844
- isVersionLogged || (index_js_namespaceObject.logger.debug(`use Rspack v${core_namespaceObject.rspack.rspackVersion}`), isVersionLogged = !0);
2843
+ }), !await isSatisfyRspackVersion(rspack_rspack.rspackVersion)) throw Error(`${picocolors_index_js_default().dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${picocolors_index_js_default().green(rspackMinVersion)}`);
2844
+ let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
2845
+ isVersionLogged || (index_js_namespaceObject.logger.debug(`use Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
2845
2846
  };
2846
2847
  return compiler.hooks.watchRun.tap('rsbuild:compiling', (compiler)=>{
2847
2848
  logRspackVersion(), isCompiling || function(compiler, context) {
@@ -2888,7 +2889,7 @@ ${section.body}` : section.body).join("\n\n"));
2888
2889
  context,
2889
2890
  compiler,
2890
2891
  bundlerConfigs: rspackConfigs,
2891
- MultiStatsCtor: core_namespaceObject.rspack.MultiStats
2892
+ MultiStatsCtor: rspack_rspack.MultiStats
2892
2893
  }), await context.hooks.onAfterCreateCompiler.callBatch({
2893
2894
  compiler,
2894
2895
  environments: context.environments
@@ -2909,16 +2910,19 @@ ${section.body}` : section.body).join("\n\n"));
2909
2910
  bundlerConfigs,
2910
2911
  compiler,
2911
2912
  isWatch: !!watch,
2912
- MultiStatsCtor: core_namespaceObject.rspack.MultiStats
2913
- }), watch) return compiler.watch({}, (err)=>{
2914
- err && index_js_namespaceObject.logger.error(err);
2915
- }), {
2916
- close: ()=>new Promise((resolve)=>{
2917
- compiler.close(()=>{
2918
- resolve();
2919
- });
2920
- })
2921
- };
2913
+ MultiStatsCtor: rspack_rspack.MultiStats
2914
+ }), watch) {
2915
+ let watchOptions = bundlerConfigs ? bundlerConfigs.map((options)=>options.watchOptions || {}) : [];
2916
+ return compiler.watch(watchOptions.length > 1 ? watchOptions : watchOptions[0] || {}, (err)=>{
2917
+ err && index_js_namespaceObject.logger.error(err);
2918
+ }), {
2919
+ close: ()=>new Promise((resolve)=>{
2920
+ compiler.close(()=>{
2921
+ resolve();
2922
+ });
2923
+ })
2924
+ };
2925
+ }
2922
2926
  let { stats } = await new Promise((resolve, reject)=>{
2923
2927
  compiler.run((err, stats)=>{
2924
2928
  compiler.close((closeErr)=>{
@@ -3139,7 +3143,7 @@ ${section.body}` : section.body).join("\n\n"));
3139
3143
  let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? picocolors_index_js_default().red : size > 100000 ? picocolors_index_js_default().yellow : picocolors_index_js_default().green, calcFileSize = (len)=>{
3140
3144
  let val = len / 1000;
3141
3145
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
3142
- }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? picocolors_index_js_default().cyan(assetName) : CSS_REGEX.test(assetName) ? picocolors_index_js_default().yellow(assetName) : HTML_REGEX.test(assetName) ? picocolors_index_js_default().green(assetName) : picocolors_index_js_default().magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
3146
+ }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? picocolors_index_js_default().cyan(assetName) : assetName.endsWith('.css') ? picocolors_index_js_default().yellow(assetName) : assetName.endsWith('.html') ? picocolors_index_js_default().green(assetName) : picocolors_index_js_default().magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
3143
3147
  async function printFileSizes(options, stats, rootPath, environmentName) {
3144
3148
  let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
3145
3149
  if (!showTotal && !showDetail) return logs;
@@ -4209,7 +4213,7 @@ ${section.body}` : section.body).join("\n\n"));
4209
4213
  traceOutput = 'perfetto' === traceLayer ? defaultRustTracePerfettoOutput : 'stdout';
4210
4214
  }
4211
4215
  let filter = "OVERVIEW" === (value = filterValue) ? 'info' : "ALL" === value ? 'trace' : value;
4212
- return await ensureFileDir(traceOutput), await core_namespaceObject.rspack.experiments.globalTrace.register(filter, traceLayer, traceOutput), traceOutput;
4216
+ return await ensureFileDir(traceOutput), await rspack_rspack.experiments.globalTrace.register(filter, traceLayer, traceOutput), traceOutput;
4213
4217
  }
4214
4218
  let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
4215
4219
  'split-by-experience': function(ctx) {
@@ -4828,7 +4832,7 @@ ${section.body}` : section.body).join("\n\n"));
4828
4832
  }(devConfig), middleware = await getCompilationMiddleware(this.compiler, {
4829
4833
  callbacks: {
4830
4834
  onInvalid: (token, fileName)=>{
4831
- if ('string' == typeof fileName && HTML_REGEX.test(fileName)) return void this.socketServer.sockWrite({
4835
+ if ('string' == typeof fileName && fileName.endsWith('.html')) return void this.socketServer.sockWrite({
4832
4836
  type: 'static-changed'
4833
4837
  }, token);
4834
4838
  this.socketServer.sockWrite({
@@ -5003,7 +5007,7 @@ ${section.body}` : section.body).join("\n\n"));
5003
5007
  var _childCompiler_options_experiments;
5004
5008
  return null == (_childCompiler_options_experiments = childCompiler.options.experiments) ? void 0 : _childCompiler_options_experiments.lazyCompilation;
5005
5009
  }) : null == (_compiler_options_experiments = compiler.options.experiments) ? void 0 : _compiler_options_experiments.lazyCompilation;
5006
- })() && middlewares.push(core_namespaceObject.rspack.experiments.lazyCompilationMiddleware(compiler));
5010
+ })() && middlewares.push(rspack_rspack.experiments.lazyCompilationMiddleware(compiler));
5007
5011
  }
5008
5012
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5009
5013
  base: server.base
@@ -5896,10 +5900,12 @@ ${section.body}` : section.body).join("\n\n"));
5896
5900
  aggregateTimeout: 0
5897
5901
  }), chain.performance.hints(!1), chain.module.parser.merge({
5898
5902
  javascript: {
5899
- exportsPresence: 'error'
5903
+ exportsPresence: 'error',
5904
+ typeReexportsPresence: 'tolerant'
5900
5905
  }
5901
5906
  }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), isDev && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)), 'rspack' === api.context.bundlerType && chain.experiments({
5902
5907
  ...chain.get('experiments'),
5908
+ typeReexportsPresence: !0,
5903
5909
  rspackFuture: {
5904
5910
  bundlerInfo: {
5905
5911
  force: !1
@@ -5992,7 +5998,7 @@ ${section.body}` : section.body).join("\n\n"));
5992
5998
  {
5993
5999
  name: 'rsbuild:output',
5994
6000
  setup (api) {
5995
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment })=>{
6001
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment, rspack })=>{
5996
6002
  var jsPath, isServer1, jsAsync;
5997
6003
  let { distPath, config } = environment, publicPath = function({ isDev, config, context }) {
5998
6004
  var _context_devServer, _context_devServer1, _context_devServer2;
@@ -6024,7 +6030,7 @@ ${section.body}` : section.body).join("\n\n"));
6024
6030
  let { copy } = config.output, options = Array.isArray(copy) ? {
6025
6031
  patterns: copy
6026
6032
  } : copy;
6027
- chain.plugin(CHAIN_ID.PLUGIN.COPY).use(core_namespaceObject.rspack.CopyRspackPlugin, [
6033
+ chain.plugin(CHAIN_ID.PLUGIN.COPY).use(rspack.CopyRspackPlugin, [
6028
6034
  options
6029
6035
  ]);
6030
6036
  }
@@ -6456,15 +6462,13 @@ ${section.body}` : section.body).join("\n\n"));
6456
6462
  {
6457
6463
  name: 'rsbuild:wasm',
6458
6464
  setup (api) {
6459
- api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
6460
- let { config } = environment, distPath = config.output.distPath.wasm;
6465
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isProd })=>{
6466
+ let { config } = environment, distPath = config.output.distPath.wasm, filename = external_node_path_namespaceObject.posix.join(distPath, getFilename(config, 'wasm', isProd));
6461
6467
  chain.experiments({
6462
6468
  ...chain.get('experiments'),
6463
6469
  asyncWebAssembly: !0
6464
- });
6465
- let wasmFilename = external_node_path_namespaceObject.posix.join(distPath, '[hash].module.wasm');
6466
- chain.output.webassemblyModuleFilename(wasmFilename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
6467
- filename: wasmFilename
6470
+ }), chain.output.webassemblyModuleFilename(filename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
6471
+ filename
6468
6472
  });
6469
6473
  });
6470
6474
  }
@@ -6668,9 +6672,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6668
6672
  name: 'rsbuild:minimize',
6669
6673
  setup (api) {
6670
6674
  let isRspack = 'rspack' === api.context.bundlerType;
6671
- api.modifyBundlerChain(async (chain, { environment, CHAIN_ID })=>{
6675
+ api.modifyBundlerChain(async (chain, { environment, CHAIN_ID, rspack })=>{
6672
6676
  let { config } = environment, { minifyJs, minifyCss, jsOptions, cssOptions } = parseMinifyOptions(config);
6673
- if (chain.optimization.minimize(minifyJs || minifyCss), minifyJs && isRspack && chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).use(core_namespaceObject.rspack.SwcJsMinimizerRspackPlugin, [
6677
+ if (chain.optimization.minimize(minifyJs || minifyCss), minifyJs && isRspack && chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).use(rspack.SwcJsMinimizerRspackPlugin, [
6674
6678
  ((config, jsOptions)=>{
6675
6679
  let options = {};
6676
6680
  options.minimizerOptions ||= {}, options.minimizerOptions.format ||= {};
@@ -6711,7 +6715,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6711
6715
  ])
6712
6716
  }
6713
6717
  }, mergedOptions = cssOptions ? cjs_default()(defaultOptions, cssOptions) : defaultOptions;
6714
- chain.optimization.minimizer(CHAIN_ID.MINIMIZER.CSS).use(core_namespaceObject.rspack.LightningCssMinimizerRspackPlugin, [
6718
+ chain.optimization.minimizer(CHAIN_ID.MINIMIZER.CSS).use(rspack.LightningCssMinimizerRspackPlugin, [
6715
6719
  mergedOptions
6716
6720
  ]).end();
6717
6721
  }
@@ -6721,11 +6725,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6721
6725
  {
6722
6726
  name: 'rsbuild:progress',
6723
6727
  setup (api) {
6724
- 'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
6728
+ 'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, rspack })=>{
6725
6729
  let { config } = environment, options = config.dev.progressBar;
6726
6730
  if (!options) return;
6727
6731
  let prefix = !0 !== options && void 0 !== options.id ? options.id : environment.name;
6728
- chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(core_namespaceObject.rspack.ProgressPlugin, [
6732
+ chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(rspack.ProgressPlugin, [
6729
6733
  {
6730
6734
  prefix,
6731
6735
  ...!0 === options ? {} : options
@@ -6784,6 +6788,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6784
6788
  isModule: 'unknown',
6785
6789
  env: {
6786
6790
  targets: browserslist
6791
+ },
6792
+ rspackExperiments: {
6793
+ collectTypeScriptInfo: {
6794
+ typeExports: !0,
6795
+ exportedEnum: !1
6796
+ }
6787
6797
  }
6788
6798
  };
6789
6799
  }({
@@ -7246,7 +7256,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7246
7256
  let { config } = environment;
7247
7257
  if (!(null == (_config_moduleFederation = config.moduleFederation) ? void 0 : _config_moduleFederation.options) || 'web' !== target) return;
7248
7258
  let { options } = config.moduleFederation;
7249
- chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(core_namespaceObject.rspack.container.ModuleFederationPlugin, [
7259
+ chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(rspack_rspack.container.ModuleFederationPlugin, [
7250
7260
  options
7251
7261
  ]), options.name && (options.exposes && chain.plugin('mf-patch-split-chunks').use(PatchSplitChunksPlugin, [
7252
7262
  options.name
@@ -7267,7 +7277,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7267
7277
  api.onBeforeBuild(({ isFirstCompile })=>{
7268
7278
  isFirstCompile && onStart();
7269
7279
  }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
7270
- traceOutput && (core_namespaceObject.rspack.experiments.globalTrace.cleanup(), index_js_namespaceObject.logger.info(`profile file saved to ${picocolors_index_js_default().cyan(traceOutput)}`));
7280
+ traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(), index_js_namespaceObject.logger.info(`profile file saved to ${picocolors_index_js_default().cyan(traceOutput)}`));
7271
7281
  });
7272
7282
  }
7273
7283
  },
@@ -7305,7 +7315,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7305
7315
  {
7306
7316
  name: 'rsbuild:sri',
7307
7317
  setup (api) {
7308
- api.modifyBundlerChain((chain, { environment, CHAIN_ID })=>{
7318
+ api.modifyBundlerChain((chain, { environment, CHAIN_ID, rspack })=>{
7309
7319
  if ('webpack' === api.context.bundlerType) return;
7310
7320
  let { config, htmlPaths } = environment;
7311
7321
  if (0 === Object.keys(htmlPaths).length) return;
@@ -7314,7 +7324,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7314
7324
  let crossorigin = chain.output.get('crossOriginLoading');
7315
7325
  (!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
7316
7326
  let { algorithm = 'sha384' } = sri;
7317
- chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(core_namespaceObject.rspack.experiments.SubresourceIntegrityPlugin, [
7327
+ chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(rspack.experiments.SubresourceIntegrityPlugin, [
7318
7328
  {
7319
7329
  enabled: !0,
7320
7330
  hashFuncNames: [
@@ -7920,11 +7930,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7920
7930
  ].includes(level) && (index_js_namespaceObject.logger.level = level);
7921
7931
  }
7922
7932
  let { npm_execpath } = process.env;
7923
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && index_js_namespaceObject.logger.log(), index_js_namespaceObject.logger.greet(` Rsbuild v1.4.10\n`);
7933
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && index_js_namespaceObject.logger.log(), index_js_namespaceObject.logger.greet(` Rsbuild v1.4.11\n`);
7924
7934
  try {
7925
7935
  !function() {
7926
7936
  let cli = ((name = "")=>new CAC(name))('rsbuild');
7927
- cli.help(), cli.version("1.4.10"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7937
+ cli.help(), cli.version("1.4.11"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7928
7938
  default: 'jiti'
7929
7939
  }).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
7930
7940
  type: [
@@ -7982,7 +7992,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7982
7992
  index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), index_js_namespaceObject.logger.error(err);
7983
7993
  }
7984
7994
  }
7985
- let src_version = "1.4.10";
7995
+ let src_version = "1.4.11";
7986
7996
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
7987
7997
  "PLUGIN_CSS_NAME",
7988
7998
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -1,13 +1,12 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
2
  let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin, isDockerCached, cachedResult;
3
- import { rspack } from "@rspack/core";
3
+ import { createRequire } from "node:module";
4
4
  import { logger } from "../compiled/rslog/index.js";
5
5
  import node_path, { dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, sep } from "node:path";
6
6
  import { URL as external_node_url_URL, fileURLToPath, pathToFileURL } from "node:url";
7
7
  import picocolors from "../compiled/picocolors/index.js";
8
8
  import node_fs, { constants as external_node_fs_constants, existsSync } from "node:fs";
9
9
  import { EventEmitter } from "events";
10
- import { createRequire } from "node:module";
11
10
  import node_os, { constants as external_node_os_constants } from "node:os";
12
11
  import node_process from "node:process";
13
12
  import rspack_chain from "../compiled/rspack-chain/index.js";
@@ -765,6 +764,7 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
765
764
  setCssExtractPlugin: ()=>setCssExtractPlugin,
766
765
  setHTMLPlugin: ()=>setHTMLPlugin
767
766
  });
767
+ let rspack_rspack = createRequire(import.meta.url)('@rspack/core');
768
768
  var cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
769
769
  let constants_filename = fileURLToPath(import.meta.url), constants_dirname = dirname(constants_filename), ROOT_DIST_DIR = 'dist', LOADER_PATH = join(constants_dirname), STATIC_PATH = join(constants_dirname, '../static'), COMPILED_PATH = join(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
770
770
  'chrome >= 87',
@@ -777,7 +777,7 @@ let constants_filename = fileURLToPath(import.meta.url), constants_dirname = dir
777
777
  node: [
778
778
  'node >= 16'
779
779
  ]
780
- }, HTML_REGEX = /\.html$/, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /^\?raw$/, INLINE_QUERY_REGEX = /^\?inline$/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
780
+ }, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /^\?raw$/, INLINE_QUERY_REGEX = /^\?inline$/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
781
781
  'woff',
782
782
  'woff2',
783
783
  'eot',
@@ -1079,6 +1079,8 @@ function getFilename(config, type, isProd, isServer) {
1079
1079
  return filename.media ?? `[name]${hash}[ext]`;
1080
1080
  case 'assets':
1081
1081
  return filename.assets ?? `[name]${hash}[ext]`;
1082
+ case 'wasm':
1083
+ return filename.wasm ?? '[hash].module.wasm';
1082
1084
  default:
1083
1085
  throw Error(`${picocolors.dim('[rsbuild:config]')} unknown key ${picocolors.yellow(type)} in ${picocolors.yellow('output.filename')}`);
1084
1086
  }
@@ -2092,7 +2094,7 @@ async function updateEnvironmentContext(context, configs) {
2092
2094
  async function createContext(options, userConfig) {
2093
2095
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2094
2096
  return {
2095
- version: "1.4.10",
2097
+ version: "1.4.11",
2096
2098
  rootPath,
2097
2099
  distPath: '',
2098
2100
  cachePath,
@@ -2417,7 +2419,7 @@ async function getConfigUtils(config, chainUtils) {
2417
2419
  }
2418
2420
  function getChainUtils(target, environment) {
2419
2421
  return {
2420
- rspack: rspack,
2422
+ rspack: rspack_rspack,
2421
2423
  environment,
2422
2424
  env: process.env.NODE_ENV,
2423
2425
  target,
@@ -2430,7 +2432,7 @@ function getChainUtils(target, environment) {
2430
2432
  };
2431
2433
  }
2432
2434
  async function generateRspackConfig({ target, context, environment }) {
2433
- let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = rspack, rspackConfig = (await modifyBundlerChain(context, {
2435
+ let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = rspack_rspack, rspackConfig = (await modifyBundlerChain(context, {
2434
2436
  ...chainUtils,
2435
2437
  bundler: {
2436
2438
  BannerPlugin,
@@ -2646,9 +2648,9 @@ async function createCompiler_createCompiler(options) {
2646
2648
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
2647
2649
  bundlerConfigs: rspackConfigs,
2648
2650
  environments: context.environments
2649
- }), !await isSatisfyRspackVersion(rspack.rspackVersion)) throw Error(`${picocolors.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${picocolors.green(rspackMinVersion)}`);
2650
- let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack(rspackConfigs) : rspack(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
2651
- isVersionLogged || (logger.debug(`use Rspack v${rspack.rspackVersion}`), isVersionLogged = !0);
2651
+ }), !await isSatisfyRspackVersion(rspack_rspack.rspackVersion)) throw Error(`${picocolors.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${picocolors.green(rspackMinVersion)}`);
2652
+ let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
2653
+ isVersionLogged || (logger.debug(`use Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
2652
2654
  };
2653
2655
  return compiler.hooks.watchRun.tap('rsbuild:compiling', (compiler)=>{
2654
2656
  logRspackVersion(), isCompiling || function(compiler, context) {
@@ -2695,7 +2697,7 @@ async function createCompiler_createCompiler(options) {
2695
2697
  context,
2696
2698
  compiler,
2697
2699
  bundlerConfigs: rspackConfigs,
2698
- MultiStatsCtor: rspack.MultiStats
2700
+ MultiStatsCtor: rspack_rspack.MultiStats
2699
2701
  }), await context.hooks.onAfterCreateCompiler.callBatch({
2700
2702
  compiler,
2701
2703
  environments: context.environments
@@ -2716,16 +2718,19 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
2716
2718
  bundlerConfigs,
2717
2719
  compiler,
2718
2720
  isWatch: !!watch,
2719
- MultiStatsCtor: rspack.MultiStats
2720
- }), watch) return compiler.watch({}, (err)=>{
2721
- err && logger.error(err);
2722
- }), {
2723
- close: ()=>new Promise((resolve)=>{
2724
- compiler.close(()=>{
2725
- resolve();
2726
- });
2727
- })
2728
- };
2721
+ MultiStatsCtor: rspack_rspack.MultiStats
2722
+ }), watch) {
2723
+ let watchOptions = bundlerConfigs ? bundlerConfigs.map((options)=>options.watchOptions || {}) : [];
2724
+ return compiler.watch(watchOptions.length > 1 ? watchOptions : watchOptions[0] || {}, (err)=>{
2725
+ err && logger.error(err);
2726
+ }), {
2727
+ close: ()=>new Promise((resolve)=>{
2728
+ compiler.close(()=>{
2729
+ resolve();
2730
+ });
2731
+ })
2732
+ };
2733
+ }
2729
2734
  let { stats } = await new Promise((resolve, reject)=>{
2730
2735
  compiler.run((err, stats)=>{
2731
2736
  compiler.close((closeErr)=>{
@@ -2944,7 +2949,7 @@ async function gzipSize(input) {
2944
2949
  let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? picocolors.red : size > 100000 ? picocolors.yellow : picocolors.green, calcFileSize = (len)=>{
2945
2950
  let val = len / 1000;
2946
2951
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
2947
- }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? picocolors.cyan(assetName) : CSS_REGEX.test(assetName) ? picocolors.yellow(assetName) : HTML_REGEX.test(assetName) ? picocolors.green(assetName) : picocolors.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
2952
+ }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? picocolors.cyan(assetName) : assetName.endsWith('.css') ? picocolors.yellow(assetName) : assetName.endsWith('.html') ? picocolors.green(assetName) : picocolors.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
2948
2953
  async function printFileSizes(options, stats, rootPath, environmentName) {
2949
2954
  let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
2950
2955
  if (!showTotal && !showDetail) return logs;
@@ -4010,7 +4015,7 @@ async function applyProfile(root, filterValue, traceLayer = 'perfetto', traceOut
4010
4015
  let timestamp = Date.now(), defaultOutputDir = node_path.join(root, `.rspack-profile-${timestamp}-${process.pid}`), defaultRustTracePerfettoOutput = node_path.join(defaultOutputDir, 'rspack.pftrace');
4011
4016
  traceOutput = 'perfetto' === traceLayer ? defaultRustTracePerfettoOutput : 'stdout';
4012
4017
  }
4013
- return await ensureFileDir(traceOutput), await rspack.experiments.globalTrace.register("OVERVIEW" === filterValue ? 'info' : "ALL" === filterValue ? 'trace' : filterValue, traceLayer, traceOutput), traceOutput;
4018
+ return await ensureFileDir(traceOutput), await rspack_rspack.experiments.globalTrace.register("OVERVIEW" === filterValue ? 'info' : "ALL" === filterValue ? 'trace' : filterValue, traceLayer, traceOutput), traceOutput;
4014
4019
  }
4015
4020
  let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
4016
4021
  'split-by-experience': function(ctx) {
@@ -4627,7 +4632,7 @@ class CompilationManager {
4627
4632
  }(devConfig), middleware = await getCompilationMiddleware(this.compiler, {
4628
4633
  callbacks: {
4629
4634
  onInvalid: (token, fileName)=>{
4630
- if ('string' == typeof fileName && HTML_REGEX.test(fileName)) return void this.socketServer.sockWrite({
4635
+ if ('string' == typeof fileName && fileName.endsWith('.html')) return void this.socketServer.sockWrite({
4631
4636
  type: 'static-changed'
4632
4637
  }, token);
4633
4638
  this.socketServer.sockWrite({
@@ -4800,7 +4805,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
4800
4805
  (helpers_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>{
4801
4806
  var _childCompiler_options_experiments;
4802
4807
  return null == (_childCompiler_options_experiments = childCompiler.options.experiments) ? void 0 : _childCompiler_options_experiments.lazyCompilation;
4803
- }) : null == (_compiler_options_experiments = compiler.options.experiments) ? void 0 : _compiler_options_experiments.lazyCompilation) && middlewares.push(rspack.experiments.lazyCompilationMiddleware(compiler));
4808
+ }) : null == (_compiler_options_experiments = compiler.options.experiments) ? void 0 : _compiler_options_experiments.lazyCompilation) && middlewares.push(rspack_rspack.experiments.lazyCompilationMiddleware(compiler));
4804
4809
  }
4805
4810
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
4806
4811
  base: server.base
@@ -5685,10 +5690,12 @@ async function applyDefaultPlugins(pluginManager, context) {
5685
5690
  aggregateTimeout: 0
5686
5691
  }), chain.performance.hints(!1), chain.module.parser.merge({
5687
5692
  javascript: {
5688
- exportsPresence: 'error'
5693
+ exportsPresence: 'error',
5694
+ typeReexportsPresence: 'tolerant'
5689
5695
  }
5690
5696
  }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), isDev && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)), 'rspack' === api.context.bundlerType && chain.experiments({
5691
5697
  ...chain.get('experiments'),
5698
+ typeReexportsPresence: !0,
5692
5699
  rspackFuture: {
5693
5700
  bundlerInfo: {
5694
5701
  force: !1
@@ -5781,7 +5788,7 @@ async function applyDefaultPlugins(pluginManager, context) {
5781
5788
  {
5782
5789
  name: 'rsbuild:output',
5783
5790
  setup (api) {
5784
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment })=>{
5791
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment, rspack })=>{
5785
5792
  var jsAsync;
5786
5793
  let { distPath, config } = environment, publicPath = function({ isDev, config, context }) {
5787
5794
  var _context_devServer, _context_devServer1, _context_devServer2;
@@ -6244,15 +6251,13 @@ async function applyDefaultPlugins(pluginManager, context) {
6244
6251
  {
6245
6252
  name: 'rsbuild:wasm',
6246
6253
  setup (api) {
6247
- api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
6248
- let { config } = environment, distPath = config.output.distPath.wasm;
6254
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isProd })=>{
6255
+ let { config } = environment, distPath = config.output.distPath.wasm, filename = posix.join(distPath, getFilename(config, 'wasm', isProd));
6249
6256
  chain.experiments({
6250
6257
  ...chain.get('experiments'),
6251
6258
  asyncWebAssembly: !0
6252
- });
6253
- let wasmFilename = posix.join(distPath, '[hash].module.wasm');
6254
- chain.output.webassemblyModuleFilename(wasmFilename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
6255
- filename: wasmFilename
6259
+ }), chain.output.webassemblyModuleFilename(filename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
6260
+ filename
6256
6261
  });
6257
6262
  });
6258
6263
  }
@@ -6357,7 +6362,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6357
6362
  config: config.tools.styleLoader
6358
6363
  });
6359
6364
  rule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
6360
- } else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
6365
+ } else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
6361
6366
  else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(node_path.join(LOADER_PATH, 'ignoreCssLoader.mjs'));
6362
6367
  let importLoaders = 0, updateRules = (callback)=>{
6363
6368
  callback(rule, 'normal'), callback(inlineRule, 'inline');
@@ -6434,7 +6439,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6434
6439
  let isStringExport = 'string' === cssLoaderOptions.exportType;
6435
6440
  if (isStringExport && rule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && rule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
6436
6441
  let extractPluginOptions = config.tools.cssExtract.pluginOptions, cssPath = config.output.distPath.css, cssFilename = getFilename(config, 'css', isProd), isCssFilenameFn = 'function' == typeof cssFilename, cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : 'async');
6437
- chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || rspack.CssExtractRspackPlugin, [
6442
+ chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin, [
6438
6443
  {
6439
6444
  filename: isCssFilenameFn ? (...args)=>{
6440
6445
  let name = cssFilename(...args);
@@ -6456,7 +6461,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6456
6461
  name: 'rsbuild:minimize',
6457
6462
  setup (api) {
6458
6463
  let isRspack = 'rspack' === api.context.bundlerType;
6459
- api.modifyBundlerChain(async (chain, { environment, CHAIN_ID })=>{
6464
+ api.modifyBundlerChain(async (chain, { environment, CHAIN_ID, rspack })=>{
6460
6465
  let { config } = environment, { minifyJs, minifyCss, jsOptions, cssOptions } = parseMinifyOptions(config);
6461
6466
  if (chain.optimization.minimize(minifyJs || minifyCss), minifyJs && isRspack && chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).use(rspack.SwcJsMinimizerRspackPlugin, [
6462
6467
  ((config, jsOptions)=>{
@@ -6509,7 +6514,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6509
6514
  {
6510
6515
  name: 'rsbuild:progress',
6511
6516
  setup (api) {
6512
- 'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
6517
+ 'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, rspack })=>{
6513
6518
  let { config } = environment, options = config.dev.progressBar;
6514
6519
  if (!options) return;
6515
6520
  let prefix = !0 !== options && void 0 !== options.id ? options.id : environment.name;
@@ -6571,6 +6576,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6571
6576
  isModule: 'unknown',
6572
6577
  env: {
6573
6578
  targets: browserslist
6579
+ },
6580
+ rspackExperiments: {
6581
+ collectTypeScriptInfo: {
6582
+ typeExports: !0,
6583
+ exportedEnum: !1
6584
+ }
6574
6585
  }
6575
6586
  };
6576
6587
  }({
@@ -7033,7 +7044,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7033
7044
  let { config } = environment;
7034
7045
  if (!(null == (_config_moduleFederation = config.moduleFederation) ? void 0 : _config_moduleFederation.options) || 'web' !== target) return;
7035
7046
  let { options } = config.moduleFederation;
7036
- chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(rspack.container.ModuleFederationPlugin, [
7047
+ chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(rspack_rspack.container.ModuleFederationPlugin, [
7037
7048
  options
7038
7049
  ]), options.name && (options.exposes && chain.plugin('mf-patch-split-chunks').use(PatchSplitChunksPlugin, [
7039
7050
  options.name
@@ -7054,7 +7065,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7054
7065
  api.onBeforeBuild(({ isFirstCompile })=>{
7055
7066
  isFirstCompile && onStart();
7056
7067
  }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
7057
- traceOutput && (rspack.experiments.globalTrace.cleanup(), logger.info(`profile file saved to ${picocolors.cyan(traceOutput)}`));
7068
+ traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(), logger.info(`profile file saved to ${picocolors.cyan(traceOutput)}`));
7058
7069
  });
7059
7070
  }
7060
7071
  },
@@ -7092,7 +7103,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7092
7103
  {
7093
7104
  name: 'rsbuild:sri',
7094
7105
  setup (api) {
7095
- api.modifyBundlerChain((chain, { environment, CHAIN_ID })=>{
7106
+ api.modifyBundlerChain((chain, { environment, CHAIN_ID, rspack })=>{
7096
7107
  if ('webpack' === api.context.bundlerType) return;
7097
7108
  let { config, htmlPaths } = environment;
7098
7109
  if (0 === Object.keys(htmlPaths).length) return;
@@ -7703,11 +7714,11 @@ async function runCLI() {
7703
7714
  ].includes(level) && (logger.level = level);
7704
7715
  }
7705
7716
  let { npm_execpath } = process.env;
7706
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.10\n`);
7717
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.11\n`);
7707
7718
  try {
7708
7719
  !function() {
7709
7720
  let cli = ((name = "")=>new CAC(name))('rsbuild');
7710
- cli.help(), cli.version("1.4.10"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7721
+ cli.help(), cli.version("1.4.11"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
7711
7722
  default: 'jiti'
7712
7723
  }).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
7713
7724
  type: [
@@ -7765,5 +7776,5 @@ async function runCLI() {
7765
7776
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
7766
7777
  }
7767
7778
  }
7768
- let src_version = "1.4.10";
7769
- export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack, runCLI, src_version as version };
7779
+ let src_version = "1.4.11";
7780
+ export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack_rspack as rspack, runCLI, src_version as version };
@@ -24,7 +24,6 @@ export declare const DEFAULT_ASSET_PREFIX = "/";
24
24
  export declare const DEFAULT_BASE_URL = "/";
25
25
  export declare const DEFAULT_WEB_BROWSERSLIST: string[];
26
26
  export declare const DEFAULT_BROWSERSLIST: Record<string, string[]>;
27
- export declare const HTML_REGEX: RegExp;
28
27
  export declare const JS_REGEX: RegExp;
29
28
  export declare const SCRIPT_REGEX: RegExp;
30
29
  export declare const CSS_REGEX: RegExp;
@@ -31,6 +31,7 @@ export declare const canParse: (url: string) => boolean;
31
31
  export declare const ensureAssetPrefix: (url: string, assetPrefix?: Rspack.PublicPath) => string;
32
32
  export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'js', isProd: boolean, isServer?: boolean): Rspack.Filename;
33
33
  export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'css', isProd: boolean): Rspack.CssFilename;
34
+ export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'wasm', isProd: boolean): Rspack.WebassemblyModuleFilename;
34
35
  export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: Exclude<keyof FilenameConfig, 'js' | 'css'>, isProd: boolean, isServer?: boolean): Rspack.AssetModuleFilename;
35
36
  export declare function partition<T>(array: T[], predicate: (value: T) => boolean): [T[], T[]];
36
37
  export declare const applyToCompiler: (compiler: Rspack.Compiler | Rspack.MultiCompiler, apply: (c: Rspack.Compiler, index: number) => void) => void;
@@ -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/core';
6
+ import { rspack } from './rspack';
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';
@@ -1,7 +1,4 @@
1
- /**
2
- * This file is used to get/set the global instance for html-plugin and css-extract plugin.
3
- */
4
- import { rspack } from '@rspack/core';
1
+ import { rspack } from './rspack';
5
2
  import type { HtmlRspackPlugin } from './types';
6
3
  /**
7
4
  * This method is used to override the Rsbuild default html-plugin (html-rspack-plugin).
@@ -0,0 +1,2 @@
1
+ declare const rspack: (typeof import("@rspack/core"))["rspack"];
2
+ export { rspack };
@@ -747,7 +747,12 @@ export type FilenameConfig = {
747
747
  */
748
748
  media?: Rspack.AssetModuleFilename;
749
749
  /**
750
- * the name of other assets, except for above (image, svg, font, html, wasm...)
750
+ * The name of Wasm files.
751
+ * @default '[hash].module.wasm'
752
+ */
753
+ wasm?: Rspack.WebassemblyModuleFilename;
754
+ /**
755
+ * The name of other assets, except for above (image, svg, font, html, wasm...)
751
756
  * @default '[name].[contenthash:8][ext]'
752
757
  */
753
758
  assets?: Rspack.AssetModuleFilename;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {