@rsbuild/core 2.3.2 → 2.3.3

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/m.js CHANGED
@@ -4,7 +4,7 @@ import { rspackRequire, moduleFactories, compatGetDefaultExport, createFakeNames
4
4
  import { rspack as core_rspack } from "@rspack/core";
5
5
  import node_util, { format as external_node_util_format, promisify, stripVTControlCharacters } from "node:util";
6
6
  import node_path, { dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, resolve as external_node_path_resolve, sep } from "node:path";
7
- import { builtinModules, createRequire, createRequire as __rspack_createRequire } from "node:module";
7
+ import { createRequire, isBuiltin, createRequire as __rspack_createRequire } from "node:module";
8
8
  import node_fs, { existsSync, readFileSync } from "node:fs";
9
9
  import node_os, { constants } from "node:os";
10
10
  import node_process from "node:process";
@@ -292,8 +292,8 @@ moduleFactories.add({
292
292
  };
293
293
  };
294
294
  },
295
- "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/index.js" (module) {
296
- let yaml, { resolve } = __rspack_createRequire_require("node:path"), config = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lilconfig/3.1.3/8e9a79516bf61f8427342cef50cdad2cdc2572f42288ba8053b88eadfdc0ebef/node_modules/lilconfig/src/index.js"), loadOptions = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/options.js"), loadPlugins = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/plugins.js"), req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/req.js");
295
+ "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/index.js" (module) {
296
+ let yaml, { resolve } = __rspack_createRequire_require("node:path"), config = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lilconfig/3.1.3/8e9a79516bf61f8427342cef50cdad2cdc2572f42288ba8053b88eadfdc0ebef/node_modules/lilconfig/src/index.js"), loadOptions = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/options.js"), loadPlugins = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/plugins.js"), req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/req.js");
297
297
  async function processResult(ctx, result) {
298
298
  let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
299
299
  default: obj
@@ -366,8 +366,8 @@ moduleFactories.add({
366
366
  });
367
367
  };
368
368
  },
369
- "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/options.js" (module) {
370
- let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/req.js");
369
+ "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/options.js" (module) {
370
+ let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/req.js");
371
371
  module.exports = async function options(config, file) {
372
372
  if (config.parser && 'string' == typeof config.parser) try {
373
373
  config.parser = await req(config.parser, file);
@@ -387,8 +387,8 @@ moduleFactories.add({
387
387
  return config;
388
388
  };
389
389
  },
390
- "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/plugins.js" (module) {
391
- let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/req.js");
390
+ "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/plugins.js" (module) {
391
+ let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/req.js");
392
392
  async function load(plugin, options, file) {
393
393
  try {
394
394
  if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
@@ -404,7 +404,7 @@ moduleFactories.add({
404
404
  }), list;
405
405
  };
406
406
  },
407
- "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/req.js" (module) {
407
+ "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/req.js" (module) {
408
408
  let tsx, jiti, { createRequire } = __rspack_createRequire_require("node:module"), { pathToFileURL } = __rspack_createRequire_require("node:url"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
409
409
  module.exports = async function req(name, rootFile = __rspack_import_meta_filename__) {
410
410
  let url = createRequire(rootFile).resolve(name);
@@ -1993,8 +1993,8 @@ class RspackChain extends ChainedMap {
1993
1993
  ]);
1994
1994
  }
1995
1995
  }
1996
- let vendors_require = createRequire(import.meta.url);
1997
- var cjs_0_default = compatGetDefaultExport(rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/deepmerge/4.3.1/56471899410038644780b3527c5076e78d3f57091a0da3ac0daf6d994929353d/node_modules/deepmerge/dist/cjs.js"));
1996
+ let vendors_require = createRequire(import.meta.url), cjs_0 = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/deepmerge/4.3.1/56471899410038644780b3527c5076e78d3f57091a0da3ac0daf6d994929353d/node_modules/deepmerge/dist/cjs.js");
1997
+ var cjs_0_default = compatGetDefaultExport(cjs_0);
1998
1998
  let setNodeEnv = (env)=>{
1999
1999
  process.env.NODE_ENV = env;
2000
2000
  }, isCI = ()=>!!process.env.CI && 'false' !== process.env.CI, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), objectPrototype = Object.prototype, helpers_getProto = Object.getPrototypeOf, isPlainObject = (obj)=>{
@@ -2079,11 +2079,8 @@ function resolveFileName(stats, logger) {
2079
2079
  let file = stats.file || stats.moduleName;
2080
2080
  if (file) return removeLoaderChainDelimiter(file, logger);
2081
2081
  if (stats.moduleIdentifier) {
2082
- let matched = stats.moduleIdentifier.match(/(?:!|^)([^!]+)$/);
2083
- if (matched) {
2084
- let fileName = matched.pop();
2085
- if (fileName) return removeLoaderChainDelimiter(fileName, logger);
2086
- }
2082
+ let fileName = stats.moduleIdentifier.slice(stats.moduleIdentifier.lastIndexOf('!') + 1);
2083
+ if (fileName) return removeLoaderChainDelimiter(fileName, logger);
2087
2084
  }
2088
2085
  return '';
2089
2086
  }
@@ -2095,12 +2092,12 @@ function formatModuleTrace(stats, errorFile, root, level, logger) {
2095
2092
  let formatted = removeLoaderChainDelimiter(errorFile, logger);
2096
2093
  moduleNames[0] !== formatted && moduleNames.unshift(formatted);
2097
2094
  }
2098
- let trace = moduleNames.slice().reverse().map((name)=>formatDiagnosticPath(name, root));
2095
+ let trace = moduleNames.toReversed();
2099
2096
  return trace.length > 4 && !isVerbose(logger) && (trace = [
2100
2097
  ...trace.slice(0, 2),
2101
2098
  `... (${trace.length - 2 - 2} hidden)`,
2102
2099
  ...trace.slice(trace.length - 2)
2103
- ]), color.dim(`Import traces (entry → ${level}):\n ${trace.join('\n ')} ${color.bold(color.red('×'))}`);
2100
+ ]), color.dim(`Import traces (entry → ${level}):\n ${trace.map((name)=>formatDiagnosticPath(name, root)).join('\n ')} ${color.bold(color.red('×'))}`);
2104
2101
  }
2105
2102
  function hintUnknownFiles(message) {
2106
2103
  let hint = 'You may need an appropriate loader to handle this file type.';
@@ -2109,37 +2106,45 @@ function hintUnknownFiles(message) {
2109
2106
  for (let plugin of [
2110
2107
  {
2111
2108
  test: /File: .+\.s(c|a)ss/,
2112
- hint: createPluginHint('sass', 'Sass')
2109
+ name: 'sass',
2110
+ keyword: 'Sass'
2113
2111
  },
2114
2112
  {
2115
2113
  test: /File: .+\.less/,
2116
- hint: createPluginHint('less', 'Less')
2114
+ name: 'less',
2115
+ keyword: 'Less'
2117
2116
  },
2118
2117
  {
2119
2118
  test: /File: .+\.styl(us)?/,
2120
- hint: createPluginHint('stylus', 'Stylus')
2119
+ name: 'stylus',
2120
+ keyword: 'Stylus'
2121
2121
  },
2122
2122
  {
2123
2123
  test: /File: .+\.vue?/,
2124
- hint: createPluginHint('vue', 'Vue')
2124
+ name: 'vue',
2125
+ keyword: 'Vue'
2125
2126
  },
2126
2127
  {
2127
2128
  test: /File: .+\.svelte?/,
2128
- hint: createPluginHint('svelte', 'Svelte')
2129
+ name: 'svelte',
2130
+ keyword: 'Svelte'
2129
2131
  },
2130
2132
  {
2131
2133
  test: /File: .+\.mdx/,
2132
- hint: createPluginHint('mdx', 'MDX')
2134
+ name: 'mdx',
2135
+ keyword: 'MDX'
2133
2136
  },
2134
2137
  {
2135
2138
  test: /File: .+\.toml/,
2136
- hint: createPluginHint('toml', 'TOML')
2139
+ name: 'toml',
2140
+ keyword: 'TOML'
2137
2141
  },
2138
2142
  {
2139
2143
  test: /File: .+\.yaml/,
2140
- hint: createPluginHint('yaml', 'YAML')
2144
+ name: 'yaml',
2145
+ keyword: 'YAML'
2141
2146
  }
2142
- ])if (plugin.test.test(message)) return message.replace(hint, plugin.hint);
2147
+ ])if (plugin.test.test(message)) return message.replace(hint, createPluginHint(plugin.name, plugin.keyword));
2143
2148
  return message;
2144
2149
  }
2145
2150
  function formatStatsError(stats, root, level = 'error', logger) {
@@ -2147,11 +2152,11 @@ function formatStatsError(stats, root, level = 'error', logger) {
2147
2152
  if (!fileName) return '';
2148
2153
  let DATA_URI_PREFIX = "data:text/javascript,";
2149
2154
  if (fileName.startsWith(DATA_URI_PREFIX)) {
2150
- let snippet = fileName.replace(DATA_URI_PREFIX, '');
2155
+ let snippet = fileName.slice(DATA_URI_PREFIX.length);
2151
2156
  return snippet.length > 30 && (snippet = `${snippet.slice(0, 30)}...`), `File: ${color.cyan('data-uri virtual module')} ${color.dim(`(${snippet})`)}\n`;
2152
2157
  }
2153
2158
  let prefix = root + sep;
2154
- return (fileName = fileName.startsWith(prefix) ? fileName.replace(prefix, `.${sep}`) : formatDiagnosticPath(fileName, root), /:\d+:\d+/.test(fileName)) ? `File: ${color.cyan(fileName)}\n` : stats.loc ? `File: ${color.cyan(`${fileName}:${stats.loc}`)}\n` : `File: ${color.cyan(`${fileName}:1:1`)}\n`;
2159
+ return (fileName = fileName.startsWith(prefix) ? `.${sep}${fileName.slice(prefix.length)}` : formatDiagnosticPath(fileName, root), /:\d+:\d+/.test(fileName)) ? `File: ${color.cyan(fileName)}\n` : stats.loc ? `File: ${color.cyan(`${fileName}:${stats.loc}`)}\n` : `File: ${color.cyan(`${fileName}:1:1`)}\n`;
2155
2160
  })(fileName, stats, root)}${stats.message}`, verbose = isVerbose(logger);
2156
2161
  if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level || isVerbose(logger)) {
2157
2162
  let moduleTrace = formatModuleTrace(stats, fileName, root, level, logger);
@@ -2178,7 +2183,7 @@ function formatStatsError(stats, root, level = 'error', logger) {
2178
2183
  let matchArray = stripVTControlCharacters(message).match(/Can't resolve '(\w+)'/);
2179
2184
  if (!matchArray) return message;
2180
2185
  let moduleName = matchArray[1];
2181
- return moduleName && builtinModules.includes(moduleName) ? getTips(moduleName) : message;
2186
+ return moduleName && isBuiltin(moduleName) ? getTips(moduleName) : message;
2182
2187
  })(message = hintUnknownFiles(message)))).split('\n');
2183
2188
  return (message = (lines = lines.filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n')).trim();
2184
2189
  }
@@ -2247,7 +2252,11 @@ function formatStats(stats, hasErrors, root, logger) {
2247
2252
  }
2248
2253
  return {};
2249
2254
  }
2250
- let removeLoaderChainDelimiter = (moduleId, logger)=>isVerbose(logger) ? moduleId : moduleId.split('!=!')[0];
2255
+ let removeLoaderChainDelimiter = (moduleId, logger)=>{
2256
+ if (isVerbose(logger)) return moduleId;
2257
+ let index = moduleId.indexOf('!=!');
2258
+ return -1 === index ? moduleId : moduleId.slice(0, index);
2259
+ };
2251
2260
  function createEnvironmentAsyncHook() {
2252
2261
  let preGroup = [], postGroup = [], defaultGroup = [], tapEnvironment = ({ environment, handler: cb })=>{
2253
2262
  isFunction(cb) ? defaultGroup.push({
@@ -2533,7 +2542,7 @@ async function pathExists(path) {
2533
2542
  async function isFileExists(file) {
2534
2543
  return node_fs.promises.access(file, node_fs.constants.F_OK).then(()=>!0).catch(()=>!1);
2535
2544
  }
2536
- async function fileExistsByCompilation({ inputFileSystem }, filePath) {
2545
+ function fileExistsByCompilation({ inputFileSystem }, filePath) {
2537
2546
  return new Promise((resolve)=>{
2538
2547
  inputFileSystem ? inputFileSystem.stat(filePath, (err, stats)=>{
2539
2548
  err ? resolve(!1) : resolve(!!stats?.isFile());
@@ -2587,8 +2596,14 @@ let OVERRIDE_PATHS = new Set([
2587
2596
  'provider',
2588
2597
  'customLogger'
2589
2598
  ]), merge = (x, y, path = '')=>{
2590
- let realKey;
2591
- if (realKey = path.startsWith('environments.') ? path.split('.').slice(2).join('.') : path, OVERRIDE_PATHS.has(realKey) || realKey.startsWith('output.filename.')) return y ?? x;
2599
+ if (((key)=>{
2600
+ let realKey = key;
2601
+ if (key.startsWith('environments.')) {
2602
+ let index = key.indexOf('.', 13);
2603
+ realKey = -1 === index ? '' : key.slice(index + 1);
2604
+ }
2605
+ return OVERRIDE_PATHS.has(realKey) || realKey.startsWith('output.filename.');
2606
+ })(path)) return y ?? x;
2592
2607
  if (void 0 === x) return isPlainObject(y) ? cloneDeep(y) : y;
2593
2608
  if (void 0 === y) return isPlainObject(x) ? cloneDeep(x) : x;
2594
2609
  let typeX = typeof x, typeY = typeof y;
@@ -2873,7 +2888,11 @@ let isEnvironmentMatch = (pluginEnvironment, specifiedEnvironment)=>pluginEnviro
2873
2888
  function createPluginManager(logger) {
2874
2889
  let plugins = [];
2875
2890
  return {
2876
- getPlugins: (options = {})=>plugins.filter((plugin)=>isEnvironmentMatch(plugin.environment, options.environment)).map(({ instance })=>instance),
2891
+ getPlugins: (options = {})=>{
2892
+ let result = [];
2893
+ for (let plugin of plugins)isEnvironmentMatch(plugin.environment, options.environment) && result.push(plugin.instance);
2894
+ return result;
2895
+ },
2877
2896
  getAllPluginsWithMeta: ()=>plugins,
2878
2897
  addPlugins: (newPlugins, options)=>{
2879
2898
  let { before, environment } = options || {};
@@ -2902,11 +2921,6 @@ async function initPlugins({ context, pluginManager }) {
2902
2921
  let plugins = pluginManager.getAllPluginsWithMeta();
2903
2922
  plugins = ((plugins)=>{
2904
2923
  let allLines = [], pluginNames = new Set(plugins.map((item)=>item.instance.name));
2905
- function getPlugin(name) {
2906
- let targets = plugins.filter((item)=>item.instance.name === name);
2907
- if (!targets.length) throw Error(`${color.dim('[rsbuild:plugin]')} Plugin "${color.yellow(name)}" not existed`);
2908
- return targets;
2909
- }
2910
2924
  for (let plugin of plugins){
2911
2925
  if (plugin.instance.pre) for (let pre of plugin.instance.pre)pre && pluginNames.has(pre) && allLines.push([
2912
2926
  pre,
@@ -2917,10 +2931,23 @@ async function initPlugins({ context, pluginManager }) {
2917
2931
  post
2918
2932
  ]);
2919
2933
  }
2920
- let endPoints = new Set(allLines.map((line)=>line[1])), zeroEndPoints = plugins.filter((item)=>!endPoints.has(item.instance.name)), sortedPoint = [], sortedPluginNames = new Set();
2921
- for(; zeroEndPoints.length;){
2922
- let { name } = zeroEndPoints[0].instance, pluginInstances = getPlugin(name);
2923
- sortedPoint.push(...pluginInstances), sortedPluginNames.add(name), endPoints = new Set((allLines = allLines.filter((line)=>line[0] !== name)).map((line)=>line[1])), zeroEndPoints = plugins.filter((item)=>!sortedPluginNames.has(item.instance.name) && !endPoints.has(item.instance.name));
2934
+ if (0 === allLines.length && pluginNames.size === plugins.length) return plugins.slice();
2935
+ let pluginsByName = new Map();
2936
+ for (let plugin of plugins){
2937
+ let { name } = plugin.instance, group = pluginsByName.get(name);
2938
+ group ? group.push(plugin) : pluginsByName.set(name, [
2939
+ plugin
2940
+ ]);
2941
+ }
2942
+ function getPlugin(name) {
2943
+ let targets = pluginsByName.get(name) ?? [];
2944
+ if (!targets.length) throw Error(`${color.dim('[rsbuild:plugin]')} Plugin "${color.yellow(name)}" not existed`);
2945
+ return targets;
2946
+ }
2947
+ let endPoints = new Set(allLines.map((line)=>line[1])), zeroEndPoint = plugins.find((item)=>!endPoints.has(item.instance.name)), sortedPoint = [], sortedPluginNames = new Set();
2948
+ for(; zeroEndPoint;){
2949
+ let { name } = zeroEndPoint.instance, pluginInstances = getPlugin(name);
2950
+ sortedPoint.push(...pluginInstances), sortedPluginNames.add(name), endPoints = new Set((allLines = allLines.filter((line)=>line[0] !== name)).map((line)=>line[1])), zeroEndPoint = plugins.find((item)=>!sortedPluginNames.has(item.instance.name) && !endPoints.has(item.instance.name));
2924
2951
  }
2925
2952
  if (allLines.length) {
2926
2953
  let restInRingPoints = {};
@@ -3033,7 +3060,7 @@ function initPluginAPI({ context, pluginManager }) {
3033
3060
  }, GLOBAL_EXPOSED_KEY = Symbol('global-exposed'), exposed = new Map(), expose = (id, api, options)=>{
3034
3061
  let exposedAPIs = exposed.get(id) ?? new Map(), key = options?.environment ?? GLOBAL_EXPOSED_KEY;
3035
3062
  exposedAPIs.set(key, api), exposed.set(id, exposedAPIs);
3036
- }, transformId = 0, transformer = {}, processAssetsFns = [], resolveFns = [];
3063
+ }, transformId = 0, transformer = {}, preTransformIds = new Set(), processAssetsFns = [], resolveFns = [];
3037
3064
  hooks.modifyBundlerChain.tap((chain, { target, environment })=>{
3038
3065
  let pluginName = 'RsbuildCorePlugin';
3039
3066
  chain.plugin(pluginName).use(class {
@@ -3079,13 +3106,17 @@ function initPluginAPI({ context, pluginManager }) {
3079
3106
  logger: context.logger,
3080
3107
  transform: (0, (descriptor, handler)=>{
3081
3108
  let id = `rsbuild-transform-${transformId++}`;
3082
- transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
3109
+ transformer[id] = handler, void 0 !== descriptor.as && 'pre' === descriptor.order && preTransformIds.add(id), hooks.modifyBundlerChain.tapEnvironment({
3083
3110
  environment: environment,
3084
3111
  handler: (chain, { target, environment: environmentContext })=>{
3085
3112
  if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environmentContext.name)) return;
3086
3113
  let rule = chain.module.rule(id);
3087
- descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.order && 'default' !== descriptor.order ? rule.enforce(descriptor.order) : descriptor.enforce && rule.enforce(descriptor.enforce);
3088
- let loaderPath = join(LOADER_PATH, descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs'), use = rule.use(id).loader(loaderPath).options({
3114
+ if (preTransformIds.has(id)) {
3115
+ let firstRuleName = chain.module.rules.order().order.find((name)=>!preTransformIds.has(name));
3116
+ firstRuleName && rule.before(firstRuleName);
3117
+ }
3118
+ void 0 !== descriptor.as && rule.set('as', descriptor.as), descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.order && 'default' !== descriptor.order ? rule.enforce(descriptor.order) : descriptor.enforce && rule.enforce(descriptor.enforce);
3119
+ let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = join(LOADER_PATH, loaderName), use = rule.use(id).loader(loaderPath).options({
3089
3120
  id,
3090
3121
  getEnvironment: ()=>environmentContext
3091
3122
  });
@@ -3175,7 +3206,8 @@ function initPluginAPI({ context, pluginManager }) {
3175
3206
  });
3176
3207
  }
3177
3208
  function getAbsoluteDistPath(cwd, config) {
3178
- return ensureAbsolutePath(cwd, config.output?.distPath?.root ?? "dist");
3209
+ let dirRoot = config.output?.distPath?.root ?? "dist";
3210
+ return ensureAbsolutePath(cwd, dirRoot);
3179
3211
  }
3180
3212
  let browsersListCache = new Map();
3181
3213
  function getBrowserslist(path) {
@@ -3258,7 +3290,7 @@ async function createContext(options, userConfig, logger, loadConfigResult) {
3258
3290
  return config;
3259
3291
  })(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, hooks = initHooks();
3260
3292
  return {
3261
- version: "2.3.2",
3293
+ version: "2.3.3",
3262
3294
  rootPath,
3263
3295
  configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
3264
3296
  configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
@@ -3346,7 +3378,7 @@ async function emitConfigFiles({ bundlerConfigs, environmentConfigs, extraConfig
3346
3378
  };
3347
3379
  }),
3348
3380
  ...bundlerConfigs.map(({ name, content })=>{
3349
- let outputFilePath = join(outputPath, `rspack.config.${name}.mjs`);
3381
+ let outputFile = `rspack.config.${name}.mjs`, outputFilePath = join(outputPath, outputFile);
3350
3382
  return node_fs.existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
3351
3383
  path: outputFilePath,
3352
3384
  label: `Rspack Config (${name})`,
@@ -3691,11 +3723,12 @@ function getConfigUtils(getCurrentConfig, chainUtils) {
3691
3723
  };
3692
3724
  }
3693
3725
  function getChainUtils(target, environment, environments) {
3726
+ let nodeEnv = process.env.NODE_ENV || '';
3694
3727
  return {
3695
3728
  rspack: core_rspack,
3696
3729
  environment,
3697
3730
  environments,
3698
- env: process.env.NODE_ENV || '',
3731
+ env: nodeEnv,
3699
3732
  target,
3700
3733
  isDev: 'development' === environment.config.mode,
3701
3734
  isProd: 'production' === environment.config.mode,
@@ -3871,14 +3904,14 @@ function cutPath(originalFilePath, root) {
3871
3904
  return parts.length > 3 ? parts.slice(-3).join(sep) : parts.join(sep);
3872
3905
  }
3873
3906
  function isLikelyFile(filePath) {
3874
- return (filePath.split(sep).pop() || '').includes('.');
3907
+ return filePath.slice(filePath.lastIndexOf(sep) + 1).includes('.');
3875
3908
  }
3876
3909
  function formatFileList(paths, rootPath) {
3877
3910
  let files = paths.filter(isLikelyFile);
3878
3911
  0 === files.length && paths.length > 0 && (files = [
3879
3912
  paths[0]
3880
3913
  ]);
3881
- let fileInfo = files.slice(0, 1).map((file)=>cutPath(file, rootPath)).join(', ');
3914
+ let fileInfo = files.length ? cutPath(files[0], rootPath) : '';
3882
3915
  return files.length > 1 ? `${fileInfo} and ${files.length - 1} more` : fileInfo;
3883
3916
  }
3884
3917
  function printBuildLog(compiler, context, lazyModules) {
@@ -3904,9 +3937,9 @@ async function createCompiler_createCompiler(options) {
3904
3937
  bundlerConfigs: rspackConfigs,
3905
3938
  environments: context.environments
3906
3939
  }), (version = core_rspack.rspackVersion).includes('-canary') && (version = version.split('-canary')[0]), !(!(version && /^[\d.]+$/.test(version)) || ((version1, version2)=>{
3907
- let parts1 = version1.split('.').map(Number), parts2 = version2.split('.').map(Number), len = Math.max(parts1.length, parts2.length);
3940
+ let parts1 = version1.split('.'), parts2 = version2.split('.'), len = Math.max(parts1.length, parts2.length);
3908
3941
  for(let i = 0; i < len; i++){
3909
- let item1 = parts1[i] ?? 0, item2 = parts2[i] ?? 0;
3942
+ let item1 = Number(parts1[i] ?? 0), item2 = Number(parts2[i] ?? 0);
3910
3943
  if (item1 > item2) return 1;
3911
3944
  if (item1 < item2) return -1;
3912
3945
  }
@@ -3986,7 +4019,7 @@ async function createCompiler_createCompiler(options) {
3986
4019
  let isFirstCompile = !0, { environmentList } = context;
3987
4020
  onBeforeCompile({
3988
4021
  compiler,
3989
- beforeEnvironmentCompile: async (buildIndex)=>{
4022
+ beforeEnvironmentCompile: (buildIndex)=>{
3990
4023
  let environment = environmentList[buildIndex];
3991
4024
  return context.hooks.onBeforeEnvironmentCompile.callBatch({
3992
4025
  environment: environment.name,
@@ -4000,7 +4033,7 @@ async function createCompiler_createCompiler(options) {
4000
4033
  ]
4001
4034
  });
4002
4035
  },
4003
- beforeCompile: async ()=>context.hooks.onBeforeDevCompile.callBatch({
4036
+ beforeCompile: ()=>context.hooks.onBeforeDevCompile.callBatch({
4004
4037
  bundlerConfigs,
4005
4038
  environments: context.environments,
4006
4039
  isFirstCompile,
@@ -4066,14 +4099,14 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (inp
4066
4099
  let commonDistPath = getCommonParentPath(environmentWithHtml.map((item)=>item.distPath));
4067
4100
  return environmentWithHtml.reduce((prev, environmentContext)=>{
4068
4101
  let { distPath, config } = environmentContext, distPrefix = relative(commonDistPath, distPath).split(sep).join('/'), routes = formatRoutes(environmentContext.htmlPaths, context.normalizedConfig.server.base, posix.join(distPrefix, config.output.distPath.html), config.html.outputStructure);
4069
- return prev.concat(...routes);
4102
+ return prev.concat(routes);
4070
4103
  }, []);
4071
4104
  }, formatRoutes = (entry, base, distPathPrefix, outputStructure)=>{
4072
- let prefix = joinUrlPath(base, formatPrefix(distPathPrefix));
4073
- return Object.keys(entry).map((entryName)=>({
4105
+ let prefix = joinUrlPath(base, formatPrefix(distPathPrefix)), entryNames = Object.keys(entry), index = entryNames.indexOf('index');
4106
+ return index > 0 && (entryNames.splice(index, 1), entryNames.unshift('index')), entryNames.map((entryName)=>({
4074
4107
  entryName,
4075
4108
  pathname: prefix + ('index' === entryName && 'nested' !== outputStructure ? '' : entryName)
4076
- })).sort((a)=>'index' === a.entryName ? -1 : 1);
4109
+ }));
4077
4110
  }, formatName = (name)=>name ? `(${name.length > 20 ? `${name.slice(0, 19)}…` : name})` : name;
4078
4111
  function getURLMessages(urls, routes, { maxRoutes = 10, showAllRoutes, cliShortcutsEnabled }) {
4079
4112
  let prevName, routeLimit = showAllRoutes ? 1 / 0 : void 0 === maxRoutes ? 10 : 1 / 0 === maxRoutes ? maxRoutes : Math.max(0, Math.floor(maxRoutes)), printableRoutes = 0 === routeLimit ? [] : routes.slice(0, routeLimit), moreEntries = routeLimit > 0 ? routes.length - printableRoutes.length : 0, nameCount = 0;
@@ -4423,8 +4456,8 @@ function loadEnv({ cwd = process.cwd(), mode = process.env.NODE_ENV || '', prefi
4423
4456
  });
4424
4457
  let publicVars = {}, rawPublicVars = {};
4425
4458
  for (let key of Object.keys(processEnv))if (prefixes.some((prefix)=>key.startsWith(prefix))) {
4426
- let val = processEnv[key];
4427
- publicVars[`import.meta.env.${key}`] = JSON.stringify(val), publicVars[`process.env.${key}`] = JSON.stringify(val), rawPublicVars[key] = val;
4459
+ let val = processEnv[key], serialized = JSON.stringify(val);
4460
+ publicVars[`import.meta.env.${key}`] = serialized, publicVars[`process.env.${key}`] = serialized, rawPublicVars[key] = val;
4428
4461
  }
4429
4462
  let cleaned = !1;
4430
4463
  return {
@@ -5021,8 +5054,9 @@ function parseMinifyOptions(config) {
5021
5054
  cssOptions: minify.cssOptions
5022
5055
  };
5023
5056
  }
5024
- var postcss_load_config_src_default = compatGetDefaultExport(rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/3982c00e478b1022695fb90618a4bf86beec38a06e2b0c0a97aeacbed78f1172/node_modules/postcss-load-config/src/index.js"));
5025
- async function getLightningCSSLoaderOptions(config, targets, minify) {
5057
+ let postcss_load_config_src = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/0c96146f27b5be84aebd61df108bee07abfdc2dd46aa3cb0cd89aa03287d40cd/node_modules/postcss-load-config/src/index.js");
5058
+ var postcss_load_config_src_default = compatGetDefaultExport(postcss_load_config_src);
5059
+ function getLightningCSSLoaderOptions(config, targets, minify) {
5026
5060
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
5027
5061
  targets,
5028
5062
  errorRecovery: !0
@@ -5702,7 +5736,7 @@ async function getMetaTags(entryName, config, templateContent) {
5702
5736
  return templateContent && metaTags.charset && /<meta\b(?:[^>"']|"[^"]*"|'[^']*')*?\scharset\s*=/i.test(templateContent) && delete metaTags.charset, metaTags;
5703
5737
  }
5704
5738
  function getTemplateParameters(entryName, config, assetPrefix) {
5705
- return async (compilation, assets, assetTags, pluginOptions)=>{
5739
+ return (compilation, assets, assetTags, pluginOptions)=>{
5706
5740
  let { mountId, templateParameters } = config.html, rspackConfig = compilation.options;
5707
5741
  return reduceConfigsWithContext({
5708
5742
  initial: {
@@ -5745,10 +5779,12 @@ function updateSourceMappingURL({ source, compilation, publicPath, type, config
5745
5779
  }
5746
5780
  function getMatchedAsset(name, assets, tests) {
5747
5781
  let asset;
5748
- if (tests.some((test)=>isFunction(test) ? !!(asset ??= assets[name]) && test({
5782
+ for (let test of tests)if (isFunction(test)) {
5783
+ if ((asset ??= assets[name]) && test({
5749
5784
  name,
5750
5785
  size: asset.size()
5751
- }) : test.exec(name))) return asset ?? assets[name];
5786
+ })) return asset;
5787
+ } else if (test.test(name)) return asset ?? assets[name];
5752
5788
  }
5753
5789
  function getInlineTests(config) {
5754
5790
  let isProd = 'production' === config.mode, { inlineStyles, inlineScripts } = config.output, scriptTests = [], styleTests = [];
@@ -5846,18 +5882,22 @@ let getServerUrlFromClientConfig = async (config, context)=>{
5846
5882
  let protocol = client.protocol ? `${'wss' === client.protocol ? 'https' : 'http'}:` : '', hostname = await getHostInUrl(client.host || devServer.hostname), port = client.port && '<port>' !== client.port ? client.port : devServer.port;
5847
5883
  return `${protocol}//${hostname}:${port}`;
5848
5884
  };
5849
- function recursiveChunkGroup(chunkGroup, visited = new Set()) {
5850
- if (visited.has(chunkGroup)) return [];
5885
+ function recursiveChunkGroup(chunkGroup, visited, names) {
5886
+ if (visited.has(chunkGroup)) return;
5851
5887
  visited.add(chunkGroup);
5852
5888
  let parents = chunkGroup.getParents();
5853
- return parents.length ? parents.flatMap((chunkParent)=>recursiveChunkGroup(chunkParent, visited)) : [
5854
- chunkGroup.name
5855
- ];
5889
+ if (!parents.length) {
5890
+ let { name } = chunkGroup;
5891
+ name && names.add(name);
5892
+ return;
5893
+ }
5894
+ for (let parent of parents)recursiveChunkGroup(parent, visited, names);
5856
5895
  }
5857
5896
  function recursiveChunkEntryNames(chunk) {
5858
- let [...chunkGroups] = chunk.groupsIterable;
5897
+ let names = new Set(), visited = new Set();
5898
+ for (let chunkGroup of chunk.groupsIterable)recursiveChunkGroup(chunkGroup, visited, names);
5859
5899
  return [
5860
- ...new Set(chunkGroups.flatMap((chunkGroup)=>recursiveChunkGroup(chunkGroup)).filter((name)=>!!name))
5900
+ ...names
5861
5901
  ];
5862
5902
  }
5863
5903
  function isChunksFiltered(chunkName, includeChunks, excludeChunks) {
@@ -5867,7 +5907,7 @@ function doesChunkBelongToHtml({ chunk, htmlPluginData }) {
5867
5907
  let { options } = htmlPluginData.plugin;
5868
5908
  return recursiveChunkEntryNames(chunk).some((chunkName)=>isChunksFiltered(chunkName, options?.chunks, options?.excludeChunks));
5869
5909
  }
5870
- let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(rspackRequire.bind(rspackRequire, "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/rspack-manifest-plugin/5.2.2/7effcc0bb8833fe538e43fc501c2e2f26971eb61bf9b4827f15ff72c12352aed/node_modules/rspack-manifest-plugin/dist/index.js"))), isCSSPath = (filePath)=>filePath.endsWith('.css');
5910
+ let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(rspackRequire.bind(rspackRequire, "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/rspack-manifest-plugin/5.2.2/17497e64d22a6c2a8eb2700029cf278579ead3c64963d770513f8f60bb2e2fa4/node_modules/rspack-manifest-plugin/dist/index.js"))), isCSSPath = (filePath)=>filePath.endsWith('.css');
5871
5911
  function normalizeManifestObjectConfig(manifest) {
5872
5912
  let defaultOptions = {
5873
5913
  prefix: !0,
@@ -6012,6 +6052,7 @@ function generateLinks(options, type, compilation, data, HTMLCount, isDev) {
6012
6052
  chunk.auxiliaryFiles ?? []
6013
6053
  ])for (let file of files)isDev && file.endsWith('.hot-update.js') || file.endsWith('.map') || uniqueFiles.add(file);
6014
6054
  let sortedFilteredFiles = ((files, include, exclude)=>{
6055
+ if (!include && !exclude) return files;
6015
6056
  let includeRegExp = [], excludeRegExp = [], includeFn = [], excludeFn = [];
6016
6057
  if (include) for (let item of helpers_castArray(include))'string' == typeof item ? includeRegExp.push(new RegExp(item)) : isFunction(item) ? includeFn.push(item) : includeRegExp.push(item);
6017
6058
  if (exclude) for (let item of helpers_castArray(exclude))'string' == typeof item ? excludeRegExp.push(new RegExp(item)) : isFunction(item) ? excludeFn.push(item) : excludeRegExp.push(item);
@@ -6498,7 +6539,7 @@ function getContentType(str) {
6498
6539
  }
6499
6540
  let BYTES_RANGE_REGEXP = /^ *bytes/i;
6500
6541
  function getValueContentRangeHeader(type, size, range) {
6501
- return `${type} ${range ? `${range.start}-${range.end}` : '*'}:${size}`.replace(':', '/');
6542
+ return `${type} ${range ? `${range.start}-${range.end}` : '*'}/${size}`;
6502
6543
  }
6503
6544
  function parseHttpDate(date) {
6504
6545
  let timestamp = date && Date.parse(date);
@@ -6709,7 +6750,7 @@ function setupMemoryFileSystemCleanup(fileSystem, compilers) {
6709
6750
  compilation.hash !== lastHash && (generation++, lastHash = compilation.hash);
6710
6751
  let outputPath = compilation.getPath(compiler.outputPath);
6711
6752
  for (let name of getAssetNames(compilation)){
6712
- let queryIndex = name.indexOf('?'), filePath = join(outputPath, -1 === queryIndex ? name : name.slice(0, queryIndex));
6753
+ let queryIndex = name.indexOf('?'), filename = -1 === queryIndex ? name : name.slice(0, queryIndex), filePath = join(outputPath, filename);
6713
6754
  lastSeen.set(filePath, generation);
6714
6755
  }
6715
6756
  for (let [filePath, seen] of lastSeen)if (!(seen >= generation - 1) && (lastSeen.delete(filePath), !lastSeenByCompiler.some((assets)=>assets.has(filePath)))) try {
@@ -6982,12 +7023,12 @@ let closeCode = [
6982
7023
  49
6983
7024
  ];
6984
7025
  function ansiHTML(text) {
6985
- let ansiCodes = [], ret = text.replace(/\x1B\[([0-9;]+)m/g, (_match, sequences)=>{
7026
+ let openSpans = 0, ret = text.replace(/\x1B\[([0-9;]+)m/g, (_match, sequences)=>{
6986
7027
  let style = '';
6987
7028
  for (let seq of sequences.split(';'))styles[seq] && (style += `${styles[seq]};`);
6988
- return style ? (ansiCodes.push(sequences), `<span style="${style}">`) : closeCode.includes(Number(sequences)) && ansiCodes.length > 0 ? (ansiCodes.pop(), '</span>') : '';
7029
+ return style ? (openSpans++, `<span style="${style}">`) : closeCode.includes(Number(sequences)) && openSpans > 0 ? (openSpans--, '</span>') : '';
6989
7030
  });
6990
- return ansiCodes.length > 0 && (ret += Array(ansiCodes.length + 1).join('</span>')), ret;
7031
+ return openSpans > 0 && (ret += '</span>'.repeat(openSpans)), ret;
6991
7032
  }
6992
7033
  function formatDisplayPath(filePath, isAbsolute, root) {
6993
7034
  if (NODE_MODULES_REGEX.test(filePath)) for (let needle of [
@@ -7041,7 +7082,7 @@ class SocketServer {
7041
7082
  upgrade = (req, socket, head)=>{
7042
7083
  if (!this.wsServer.shouldHandle(req)) return;
7043
7084
  let query = parseQueryString(req);
7044
- this.context.environmentList.map(({ webSocketToken })=>webSocketToken).includes(query.token) ? this.wsServer.handleUpgrade(req, socket, head, (connection)=>{
7085
+ this.context.environmentList.some(({ webSocketToken })=>webSocketToken === query.token) ? this.wsServer.handleUpgrade(req, socket, head, (connection)=>{
7045
7086
  this.wsServer.emit('connection', connection, req);
7046
7087
  }) : socket.destroy();
7047
7088
  };
@@ -7468,11 +7509,12 @@ function gzipMiddleware_gzipMiddleware({ filter, level = node_zlib.constants.Z_B
7468
7509
  let start = ()=>{
7469
7510
  if (started) return;
7470
7511
  if (started = !0, ((res)=>{
7512
+ let index;
7471
7513
  if (res.getHeader('Content-Encoding')) return !1;
7472
7514
  let contentType = res.getHeader('Content-Type');
7473
7515
  if (!contentType) return !1;
7474
7516
  let contentTypeValue = String(contentType);
7475
- if (!CONTENT_TYPE_REGEX.test(contentTypeValue) || 'text/event-stream' === contentTypeValue.split(';', 1)[0].trim().toLowerCase()) return !1;
7517
+ if (!CONTENT_TYPE_REGEX.test(contentTypeValue) || 'text/event-stream' === (-1 === (index = contentTypeValue.indexOf(';')) ? contentTypeValue : contentTypeValue.slice(0, index)).trim().toLowerCase()) return !1;
7476
7518
  let size = res.getHeader('Content-Length');
7477
7519
  return void 0 === size || Number(size) > 1024;
7478
7520
  })(res)) {
@@ -7585,7 +7627,7 @@ let faviconFallbackMiddleware = (req, res, next)=>{
7585
7627
  return;
7586
7628
  }
7587
7629
  next();
7588
- }, middlewares_isFileExists = async (filePath, outputFileSystem)=>new Promise((resolve)=>{
7630
+ }, middlewares_isFileExists = (filePath, outputFileSystem)=>new Promise((resolve)=>{
7589
7631
  outputFileSystem.stat(filePath, (_error, stats)=>{
7590
7632
  resolve(!!stats?.isFile());
7591
7633
  });
@@ -7705,11 +7747,10 @@ let isModuleNamespaceObject = (moduleExports)=>'[object Module]' === Object.prot
7705
7747
  let normalizedModuleExports = null !== moduleExports && ('object' == typeof moduleExports || 'function' == typeof moduleExports) ? moduleExports : {
7706
7748
  default: moduleExports
7707
7749
  }, exports = [
7708
- ...new Set([
7709
- 'default',
7710
- ...Object.keys(normalizedModuleExports)
7711
- ])
7712
- ], syntheticModule = new SyntheticModule(exports, ()=>{
7750
+ 'default'
7751
+ ];
7752
+ for (let name of Object.keys(normalizedModuleExports))'default' !== name && exports.push(name);
7753
+ let syntheticModule = new SyntheticModule(exports, ()=>{
7713
7754
  for (let name of exports)if ('default' === name) {
7714
7755
  let defaultExport = isModuleNamespaceObject(normalizedModuleExports) && 'default' in normalizedModuleExports ? normalizedModuleExports.default : moduleExports;
7715
7756
  syntheticModule.setExport(name, defaultExport);
@@ -7734,7 +7775,14 @@ class BasicRunner {
7734
7775
  }
7735
7776
  getRequire() {
7736
7777
  let entryRequire = this.requirers.get('entry');
7737
- return (currentDirectory, modulePath, context = {})=>entryRequire(currentDirectory, Array.isArray(modulePath) ? modulePath : modulePath.split('?')[0], context);
7778
+ return (currentDirectory, modulePath, context = {})=>{
7779
+ let p = modulePath;
7780
+ if ('string' == typeof modulePath) {
7781
+ let index = modulePath.indexOf('?');
7782
+ -1 !== index && (p = modulePath.slice(0, index));
7783
+ }
7784
+ return entryRequire(currentDirectory, p, context);
7785
+ };
7738
7786
  }
7739
7787
  getFile(modulePath, currentDirectory) {
7740
7788
  if (Array.isArray(modulePath)) return {
@@ -8608,11 +8656,7 @@ function applyDefaultPlugins(pluginManager, context) {
8608
8656
  name: 'rsbuild:source-map',
8609
8657
  setup (api) {
8610
8658
  let normalizeExtractOptions = (extract = {})=>{
8611
- let hasLegacyJs = 'js' in extract, hasFlatFields = [
8612
- 'test',
8613
- 'include',
8614
- 'exclude'
8615
- ].some((key)=>void 0 !== extract[key]);
8659
+ let hasLegacyJs = 'js' in extract, hasFlatFields = void 0 !== extract.test || void 0 !== extract.include || void 0 !== extract.exclude;
8616
8660
  if (!1 === extract.js) return !1;
8617
8661
  if (hasLegacyJs && !hasFlatFields) {
8618
8662
  var target;
@@ -8681,10 +8725,10 @@ function applyDefaultPlugins(pluginManager, context) {
8681
8725
  ...chain.get('experiments'),
8682
8726
  newCache: !0
8683
8727
  }), cacheEnabled = !0;
8684
- let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, environment, cacheConfig.buildDependencies), cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${await helpers_hash(JSON.stringify(cacheConfig.cacheDigest))}` : `${environment.name}-${env}`;
8728
+ let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, environment, cacheConfig.buildDependencies), useDigest = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length, cacheVersion = `rsbuild-2.3.3-${environment.name}-${env}`;
8685
8729
  chain.cache({
8686
8730
  type: 'persistent',
8687
- version: cacheVersion,
8731
+ version: useDigest ? `${cacheVersion}-${await helpers_hash(JSON.stringify(cacheConfig.cacheDigest))}` : cacheVersion,
8688
8732
  storage: {
8689
8733
  type: 'filesystem',
8690
8734
  directory: cacheDirectory
@@ -9697,10 +9741,8 @@ try {
9697
9741
  bodyTags
9698
9742
  };
9699
9743
  }), api.modifyBundlerChain((chain, { CHAIN_ID, environment, isDev })=>{
9700
- let { config, htmlPaths } = environment;
9701
- if (0 === Object.keys(htmlPaths).length) return;
9702
- let { performance: { preload, prefetch } } = config;
9703
- if (!preload && !prefetch) return;
9744
+ let { config, htmlPaths } = environment, { performance: { preload, prefetch } } = config;
9745
+ if (!preload && !prefetch || 0 === Object.keys(htmlPaths).length) return;
9704
9746
  let HTMLCount = chain.entryPoints.values().length, excludes = ((config)=>{
9705
9747
  let { scriptTests, styleTests } = getInlineTests(config);
9706
9748
  return [
@@ -9941,11 +9983,15 @@ try {
9941
9983
  }), api.modifyHTMLTags({
9942
9984
  order: 'post',
9943
9985
  handler: ({ headTags, bodyTags }, { environment })=>{
9944
- let { config } = environment, { nonce } = config.security, allTags = [
9986
+ let { config } = environment, { nonce } = config.security;
9987
+ if (!nonce) return {
9988
+ headTags,
9989
+ bodyTags
9990
+ };
9991
+ for (let tag of [
9945
9992
  ...headTags,
9946
9993
  ...bodyTags
9947
- ];
9948
- if (nonce) for (let tag of allTags)isNonceTag(tag) && (tag.attrs ??= {}, tag.attrs.nonce = nonce);
9994
+ ])isNonceTag(tag) && (tag.attrs ??= {}, tag.attrs.nonce = nonce);
9949
9995
  return {
9950
9996
  headTags,
9951
9997
  bodyTags
@@ -10021,13 +10067,13 @@ async function createRsbuild(options = {}) {
10021
10067
  let isFirstCompile = !0, { environmentList } = context;
10022
10068
  onBeforeCompile({
10023
10069
  compiler,
10024
- beforeCompile: async ()=>context.hooks.onBeforeBuild.callBatch({
10070
+ beforeCompile: ()=>context.hooks.onBeforeBuild.callBatch({
10025
10071
  bundlerConfigs: rspackConfigs,
10026
10072
  environments: context.environments,
10027
10073
  isWatch,
10028
10074
  isFirstCompile
10029
10075
  }),
10030
- beforeEnvironmentCompile: async (buildIndex)=>{
10076
+ beforeEnvironmentCompile: (buildIndex)=>{
10031
10077
  let environment = environmentList[buildIndex];
10032
10078
  return context.hooks.onBeforeEnvironmentCompile.callBatch({
10033
10079
  environment: environment.name,
@@ -10432,7 +10478,7 @@ let applyServerOptions = (command)=>{
10432
10478
  };
10433
10479
  function setupCommands(argv) {
10434
10480
  let cli = ((name = "")=>new CAC(name))('rsbuild');
10435
- cli.version("2.3.2"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
10481
+ cli.version("2.3.3"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
10436
10482
  default: 'auto'
10437
10483
  }).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
10438
10484
  type: [
@@ -10497,7 +10543,7 @@ function setupCommands(argv) {
10497
10543
  }
10498
10544
  function showGreeting() {
10499
10545
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
10500
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.3.2\n`);
10546
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.3.3\n`);
10501
10547
  }
10502
10548
  function setupLogLevel(argv) {
10503
10549
  if (argv.length <= 3) return;
@@ -10519,5 +10565,5 @@ function runCLI({ argv = process.argv } = {}) {
10519
10565
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
10520
10566
  }
10521
10567
  }
10522
- let src_version = "2.3.2";
10568
+ let src_version = "2.3.3";
10523
10569
  export { core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };