@rsbuild/core 1.1.2 → 1.1.4

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.js CHANGED
@@ -1,5 +1,4 @@
1
- /*! For license information please see index.js.LICENSE.txt */
2
- let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
1
+ let pluginHelper_htmlPlugin, cssExtractPlugin, swcHelpersPath;
3
2
  import { fileURLToPath as __webpack_fileURLToPath__ } from "url";
4
3
  import { dirname as __webpack_dirname__ } from "path";
5
4
  import * as __WEBPACK_EXTERNAL_MODULE_crypto__ from "crypto";
@@ -12,11 +11,11 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_process__ from "node:process";
12
11
  import * as __WEBPACK_EXTERNAL_MODULE_os__ from "os";
13
12
  import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
14
13
  import * as __WEBPACK_EXTERNAL_MODULE__rspack_core__ from "@rspack/core";
15
- import * as __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__ from "../compiled/rslog/index.js";
16
- import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__ from "../compiled/picocolors/index.js";
17
14
  import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
18
- import * as __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js__ from "../compiled/rspack-chain/index.js";
15
+ import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__ from "../compiled/picocolors/index.js";
16
+ import * as __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__ from "../compiled/rslog/index.js";
19
17
  import * as __WEBPACK_EXTERNAL_MODULE_node_util_types__ from "node:util/types";
18
+ import * as __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js__ from "../compiled/rspack-chain/index.js";
20
19
  import * as __WEBPACK_EXTERNAL_MODULE_node_util__ from "node:util";
21
20
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_mrmime_index_js__ from "../compiled/mrmime/index.js";
22
21
  import * as __WEBPACK_EXTERNAL_MODULE_node_crypto__ from "node:crypto";
@@ -86,13 +85,13 @@ var EsmMode, __webpack_modules__ = {
86
85
  };
87
86
  module.exports = deepmerge;
88
87
  },
89
- "../../node_modules/.pnpm/dotenv-expand@11.0.6/node_modules/dotenv-expand/lib/main.js": function(module) {
88
+ "../../node_modules/.pnpm/dotenv-expand@11.0.7/node_modules/dotenv-expand/lib/main.js": function(module) {
90
89
  let DOTENV_SUBSTITUTION_REGEX = /(\\)?(\$)(?!\()(\{?)([\w.]+)(?::?-((?:\$\{(?:\$\{(?:\$\{[^}]*\}|[^}])*}|[^}])*}|[^}])+))?(\}?)/gi;
91
90
  function interpolate(value, processEnv, parsed) {
92
91
  return value.replace(DOTENV_SUBSTITUTION_REGEX, (match, escaped, dollarSign, openBrace, key, defaultValue, closeBrace)=>{
93
92
  if ('\\' === escaped) return match.slice(1);
94
93
  if (processEnv[key]) return processEnv[key] === parsed[key] ? processEnv[key] : interpolate(processEnv[key], processEnv, parsed);
95
- if (parsed[key]) return parsed[key] === value ? parsed[key] : interpolate(parsed[key], processEnv, parsed);
94
+ if (parsed[key] && parsed[key] !== value) return interpolate(parsed[key], processEnv, parsed);
96
95
  if (defaultValue) return defaultValue.startsWith('$') ? interpolate(defaultValue, processEnv, parsed) : defaultValue;
97
96
  return '';
98
97
  });
@@ -260,62 +259,6 @@ var EsmMode, __webpack_modules__ = {
260
259
  };
261
260
  module.exports.configDotenv = DotenvModule.configDotenv, module.exports._configVault = DotenvModule._configVault, module.exports._parseVault = DotenvModule._parseVault, module.exports.config = DotenvModule.config, module.exports.decrypt = DotenvModule.decrypt, module.exports.parse = DotenvModule.parse, module.exports.populate = DotenvModule.populate, module.exports = DotenvModule;
262
261
  },
263
- "../../node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js": function(module) {
264
- module.exports = function(str) {
265
- var match;
266
- if ('string' != typeof str || '' === str) return !1;
267
- for(; match = /(\\).|([@?!+*]\(.*\))/g.exec(str);){
268
- if (match[2]) return !0;
269
- str = str.slice(match.index + match[0].length);
270
- }
271
- return !1;
272
- };
273
- },
274
- "../../node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
275
- var isExtglob = __webpack_require__("../../node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js"), chars = {
276
- '{': '}',
277
- '(': ')',
278
- '[': ']'
279
- }, strictCheck = function(str) {
280
- if ('!' === str[0]) return !0;
281
- for(var index = 0, pipeIndex = -2, closeSquareIndex = -2, closeCurlyIndex = -2, closeParenIndex = -2, backSlashIndex = -2; index < str.length;){
282
- if ('*' === str[index] || '?' === str[index + 1] && /[\].+)]/.test(str[index]) || -1 !== closeSquareIndex && '[' === str[index] && ']' !== str[index + 1] && (closeSquareIndex < index && (closeSquareIndex = str.indexOf(']', index)), closeSquareIndex > index && (-1 === backSlashIndex || backSlashIndex > closeSquareIndex || -1 === (backSlashIndex = str.indexOf('\\', index)) || backSlashIndex > closeSquareIndex)) || -1 !== closeCurlyIndex && '{' === str[index] && '}' !== str[index + 1] && (closeCurlyIndex = str.indexOf('}', index)) > index && (-1 === (backSlashIndex = str.indexOf('\\', index)) || backSlashIndex > closeCurlyIndex) || -1 !== closeParenIndex && '(' === str[index] && '?' === str[index + 1] && /[:!=]/.test(str[index + 2]) && ')' !== str[index + 3] && (closeParenIndex = str.indexOf(')', index)) > index && (-1 === (backSlashIndex = str.indexOf('\\', index)) || backSlashIndex > closeParenIndex) || -1 !== pipeIndex && '(' === str[index] && '|' !== str[index + 1] && (pipeIndex < index && (pipeIndex = str.indexOf('|', index)), -1 !== pipeIndex && ')' !== str[pipeIndex + 1] && (closeParenIndex = str.indexOf(')', pipeIndex)) > pipeIndex && (-1 === (backSlashIndex = str.indexOf('\\', pipeIndex)) || backSlashIndex > closeParenIndex))) return !0;
283
- if ('\\' === str[index]) {
284
- var open = str[index + 1];
285
- index += 2;
286
- var close = chars[open];
287
- if (close) {
288
- var n = str.indexOf(close, index);
289
- -1 !== n && (index = n + 1);
290
- }
291
- if ('!' === str[index]) return !0;
292
- } else index++;
293
- }
294
- return !1;
295
- }, relaxedCheck = function(str) {
296
- if ('!' === str[0]) return !0;
297
- for(var index = 0; index < str.length;){
298
- if (/[*?{}()[\]]/.test(str[index])) return !0;
299
- if ('\\' === str[index]) {
300
- var open = str[index + 1];
301
- index += 2;
302
- var close = chars[open];
303
- if (close) {
304
- var n = str.indexOf(close, index);
305
- -1 !== n && (index = n + 1);
306
- }
307
- if ('!' === str[index]) return !0;
308
- } else index++;
309
- }
310
- return !1;
311
- };
312
- module.exports = function(str, options) {
313
- if ('string' != typeof str || '' === str) return !1;
314
- if (isExtglob(str)) return !0;
315
- var check = strictCheck;
316
- return options && !1 === options.strict && (check = relaxedCheck), check(str);
317
- };
318
- },
319
262
  crypto: function(module) {
320
263
  module.exports = __WEBPACK_EXTERNAL_MODULE_crypto__;
321
264
  },
@@ -1427,6 +1370,10 @@ __webpack_require__.n = function(module) {
1427
1370
  value: !0
1428
1371
  });
1429
1372
  };
1373
+ var internal_namespaceObject = {};
1374
+ __webpack_require__.r(internal_namespaceObject), __webpack_require__.d(internal_namespaceObject, {
1375
+ setHTMLPlugin: ()=>setHTMLPlugin
1376
+ });
1430
1377
  var provider_helpers_namespaceObject = {};
1431
1378
  __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(provider_helpers_namespaceObject, {
1432
1379
  chainToConfig: ()=>chainToConfig,
@@ -1446,14 +1393,12 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
1446
1393
  setCssExtractPlugin: ()=>setCssExtractPlugin,
1447
1394
  stringifyConfig: ()=>stringifyConfig
1448
1395
  });
1449
- var internal_namespaceObject = {};
1450
- __webpack_require__.r(internal_namespaceObject), __webpack_require__.d(internal_namespaceObject, {
1451
- prepareCli: ()=>prepareCli,
1452
- runCli: ()=>runCli,
1453
- setHTMLPlugin: ()=>setHTMLPlugin
1454
- });
1455
- let { program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/index.js");
1456
- var external_node_path_ = __webpack_require__("node:path"), cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs), constants_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
1396
+ let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), setHTMLPlugin = (plugin)=>{
1397
+ plugin && (pluginHelper_htmlPlugin = plugin);
1398
+ }, getHTMLPlugin = ()=>(!pluginHelper_htmlPlugin && (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
1399
+ cssExtractPlugin = plugin;
1400
+ }, getCssExtractPlugin = ()=>cssExtractPlugin ? cssExtractPlugin : __WEBPACK_EXTERNAL_MODULE__rspack_core__.default.CssExtractRspackPlugin;
1401
+ var external_node_fs_ = __webpack_require__("node:fs"), external_node_path_ = __webpack_require__("node:path"), main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@11.0.7/node_modules/dotenv-expand/lib/main.js"), cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs), constants_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
1457
1402
  let ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constants_dirname), STATIC_PATH = (0, external_node_path_.join)(constants_dirname, '../static'), COMPILED_PATH = (0, external_node_path_.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
1458
1403
  'chrome >= 87',
1459
1404
  'edge >= 88',
@@ -1499,8 +1444,26 @@ let ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constant
1499
1444
  'aac',
1500
1445
  'm4a',
1501
1446
  'opus'
1502
- ];
1503
- var external_node_fs_ = __webpack_require__("node:fs");
1447
+ ], isDebug = ()=>{
1448
+ if (!process.env.DEBUG) return !1;
1449
+ let values = process.env.DEBUG.toLocaleLowerCase().split(',');
1450
+ return [
1451
+ 'rsbuild',
1452
+ 'builder',
1453
+ '*'
1454
+ ].some((key)=>values.includes(key));
1455
+ };
1456
+ isDebug() && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level = 'verbose');
1457
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.override({
1458
+ debug: (message, ...args)=>{
1459
+ if ('verbose' !== __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level) return;
1460
+ let time = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.gray(`${function() {
1461
+ let now = new Date(), hours = String(now.getHours()).padStart(2, '0'), minutes = String(now.getMinutes()).padStart(2, '0'), seconds = String(now.getSeconds()).padStart(2, '0');
1462
+ return `${hours}:${minutes}:${seconds}`;
1463
+ }()}`);
1464
+ console.log(` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.magenta('rsbuild')} ${time} ${message}`, ...args);
1465
+ }
1466
+ });
1504
1467
  let isFileSync = (filePath)=>{
1505
1468
  try {
1506
1469
  var _fs_statSync;
@@ -1564,8 +1527,12 @@ function formatMessage(stats, verbose) {
1564
1527
  }
1565
1528
  let file = stats.file || stats.moduleName;
1566
1529
  return file ? `File: ${file}\n` : '';
1567
- }(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '';
1568
- message = `${fileName}${mainMessage}${details}${stack}`;
1530
+ }(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
1531
+ let traceStr = '';
1532
+ if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
1533
+ return traceStr;
1534
+ }(stats);
1535
+ message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
1569
1536
  } else message = stats;
1570
1537
  message = (lines = (lines = (message = function(message) {
1571
1538
  let hint = 'You may need an appropriate loader to handle this file type.';
@@ -1643,9 +1610,13 @@ let hintNodePolyfill = (message)=>{
1643
1610
  return statsData.warningsCount && (null === (_statsData_warnings = statsData.warnings) || void 0 === _statsData_warnings ? void 0 : _statsData_warnings.length) === 0 ? null === (_statsData_children = statsData.children) || void 0 === _statsData_children ? void 0 : _statsData_children.reduce((warnings, curr)=>warnings.concat(curr.warnings || []), []) : statsData.warnings;
1644
1611
  };
1645
1612
  function getStatsOptions(compiler) {
1646
- return isMultiCompiler(compiler) ? {
1613
+ if (isMultiCompiler(compiler)) return {
1647
1614
  children: compiler.compilers.map((compiler)=>compiler.options ? compiler.options.stats : void 0)
1648
- } : compiler.options ? compiler.options.stats : void 0;
1615
+ };
1616
+ let { stats } = compiler.options;
1617
+ return 'string' == typeof stats ? {
1618
+ preset: stats
1619
+ } : 'object' == typeof stats ? stats : {};
1649
1620
  }
1650
1621
  function formatStats(statsData, hasErrors) {
1651
1622
  let verbose = 'verbose' === __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level;
@@ -1747,27 +1718,108 @@ let camelCase = (input)=>input.replace(/[-_](\w)/g, (_, c)=>c.toUpperCase()), pr
1747
1718
  if (seconds < 60) return `${format(seconds.toFixed(1))} s`;
1748
1719
  let minutes = seconds / 60;
1749
1720
  return `${format(minutes.toFixed(2))} m`;
1750
- }, isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI, isDebug = ()=>{
1751
- if (!process.env.DEBUG) return !1;
1752
- let values = process.env.DEBUG.toLocaleLowerCase().split(',');
1753
- return [
1754
- 'rsbuild',
1755
- 'builder',
1756
- '*'
1757
- ].some((key)=>values.includes(key));
1758
- };
1759
- isDebug() && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level = 'verbose');
1760
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.override({
1761
- debug: (message, ...args)=>{
1762
- if ('verbose' !== __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level) return;
1763
- let time = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.gray(`${function() {
1764
- let now = new Date(), hours = String(now.getHours()).padStart(2, '0'), minutes = String(now.getMinutes()).padStart(2, '0'), seconds = String(now.getSeconds()).padStart(2, '0');
1765
- return `${hours}:${minutes}:${seconds}`;
1766
- }()}`);
1767
- console.log(` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.magenta('rsbuild')} ${time} ${message}`, ...args);
1721
+ }, isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
1722
+ function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1723
+ 'PUBLIC_'
1724
+ ] } = {}) {
1725
+ if ('local' === mode) throw Error("'local' cannot be used as a value for env mode, because \".env.local\" represents a temporary local file. Please use another value.");
1726
+ let filePaths = [
1727
+ '.env',
1728
+ '.env.local',
1729
+ `.env.${mode}`,
1730
+ `.env.${mode}.local`
1731
+ ].map((filename)=>(0, external_node_path_.join)(cwd, filename)).filter(isFileSync), parsed = {};
1732
+ for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(external_node_fs_.default.readFileSync(envPath)));
1733
+ parsed.NODE_ENV && (process.env.NODE_ENV = parsed.NODE_ENV), (0, lib_main.expand)({
1734
+ parsed
1735
+ });
1736
+ let publicVars = {}, rawPublicVars = {};
1737
+ for (let key of Object.keys(process.env))if (prefixes.some((prefix)=>key.startsWith(prefix))) {
1738
+ let val = process.env[key];
1739
+ publicVars[`import.meta.env.${key}`] = JSON.stringify(val), publicVars[`process.env.${key}`] = JSON.stringify(val), rawPublicVars[key] = val;
1768
1740
  }
1769
- });
1770
- let OVERRIDE_PATHS = [
1741
+ let cleaned = !1;
1742
+ return {
1743
+ parsed,
1744
+ cleanup: ()=>{
1745
+ if (!cleaned) {
1746
+ for (let key of Object.keys(parsed)){
1747
+ if ('NODE_ENV' !== key) process.env[key] === parsed[key] && delete process.env[key];
1748
+ }
1749
+ cleaned = !0;
1750
+ }
1751
+ },
1752
+ filePaths,
1753
+ publicVars,
1754
+ rawPublicVars
1755
+ };
1756
+ }
1757
+ class BrowserslistError extends Error {
1758
+ constructor(message){
1759
+ var obj, key, value;
1760
+ super(message), obj = this, value = void 0, (key = "browserslist") in obj ? Object.defineProperty(obj, key, {
1761
+ value: value,
1762
+ enumerable: !0,
1763
+ configurable: !0,
1764
+ writable: !0
1765
+ }) : obj[key] = value, this.name = 'BrowserslistError', this.browserslist = !0, Error.captureStackTrace && Error.captureStackTrace(this, BrowserslistError);
1766
+ }
1767
+ }
1768
+ let isFileCache = {};
1769
+ function isFile(file) {
1770
+ if (file in isFileCache) return isFileCache[file];
1771
+ let result = external_node_fs_.default.existsSync(file) && external_node_fs_.default.statSync(file).isFile();
1772
+ return isFileCache[file] = result, result;
1773
+ }
1774
+ function parsePackage(file) {
1775
+ let config = JSON.parse(external_node_fs_.default.readFileSync(file).toString().replace(/^\uFEFF/m, ''));
1776
+ if (config.browserlist && !config.browserslist) throw new BrowserslistError(`\`browserlist\` key instead of \`browserslist\` in ${file}`);
1777
+ let list = config.browserslist;
1778
+ for(let i in Array.isArray(list) && (list = {
1779
+ defaults: list
1780
+ }), 'string' == typeof list && (list = parseConfig(list)), list)!function(section) {
1781
+ let FORMAT = 'Browserslist config should be a string or an array of strings with browser queries';
1782
+ if (Array.isArray(section)) {
1783
+ for(let i = 0; i < section.length; i++)if ('string' != typeof section[i]) throw new BrowserslistError(FORMAT);
1784
+ } else if ('string' != typeof section) throw new BrowserslistError(FORMAT);
1785
+ }(list[i]);
1786
+ return list;
1787
+ }
1788
+ let IS_SECTION = /^\s*\[(.+)]\s*$/;
1789
+ function parseConfig(string) {
1790
+ let result = {
1791
+ defaults: []
1792
+ }, sections = [
1793
+ 'defaults'
1794
+ ];
1795
+ return string.toString().replace(/#[^\n]*/g, '').split(/\n|,/).map((line)=>line.trim()).filter((line)=>'' !== line).forEach((line)=>{
1796
+ let matched = line.match(IS_SECTION);
1797
+ matched ? (sections = matched[1].trim().split(' ')).forEach((section)=>{
1798
+ if (result[section]) throw new BrowserslistError(`Duplicate section ${section} in Browserslist config`);
1799
+ result[section] = [];
1800
+ }) : sections.forEach((section)=>{
1801
+ result[section].push(line);
1802
+ });
1803
+ }), result;
1804
+ }
1805
+ function parsePackageOrReadConfig(file) {
1806
+ return 'package.json' === external_node_path_.default.basename(file) ? parsePackage(file) : function(file) {
1807
+ if (!isFile(file)) throw new BrowserslistError(`Can't read ${file} config`);
1808
+ return parseConfig(external_node_fs_.default.readFileSync(file, 'utf-8'));
1809
+ }(file);
1810
+ }
1811
+ function pickEnv(config, opts) {
1812
+ let name;
1813
+ return 'object' != typeof config ? config : ('string' == typeof opts.env ? name = opts.env : process.env.BROWSERSLIST_ENV ? name = process.env.BROWSERSLIST_ENV : process.env.NODE_ENV ? name = process.env.NODE_ENV : name = 'production', config[name] || config.defaults);
1814
+ }
1815
+ function eachParent(file, callback) {
1816
+ let dir = isFile(file) ? external_node_path_.default.dirname(file) : file, loc = external_node_path_.default.resolve(dir);
1817
+ do {
1818
+ let result = callback(loc);
1819
+ if (void 0 !== result) return result;
1820
+ }while (loc !== (loc = external_node_path_.default.dirname(loc)));
1821
+ }
1822
+ let configCache = {}, OVERRIDE_PATHS = [
1771
1823
  'performance.removeConsole',
1772
1824
  'output.inlineScripts',
1773
1825
  'output.inlineStyles',
@@ -1806,8 +1858,78 @@ let OVERRIDE_PATHS = [
1806
1858
  merged[key] = mergeConfig_merge(x[key], y[key], childPath);
1807
1859
  }
1808
1860
  return merged;
1809
- }, mergeRsbuildConfig = (...configs)=>2 === configs.length ? mergeConfig_merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>mergeConfig_merge(result, config), {});
1810
- var is_glob = __webpack_require__("../../node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js"), is_glob_default = __webpack_require__.n(is_glob);
1861
+ }, mergeRsbuildConfig = (...configs)=>2 === configs.length ? mergeConfig_merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>mergeConfig_merge(result, config), {}), commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? external_node_path_.default.isAbsolute(envDir) ? envDir : external_node_path_.default.resolve(cwd, envDir) : cwd;
1862
+ async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
1863
+ cliOptions && (commonOpts = cliOptions);
1864
+ try {
1865
+ var _config_server, _config_dev, _config_dev1;
1866
+ let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
1867
+ cwd: getEnvDir(root, commonOpts.envDir),
1868
+ mode: commonOpts.envMode
1869
+ });
1870
+ onBeforeRestartServer(envs.cleanup);
1871
+ let { content: config, filePath: configFilePath } = await config_loadConfig({
1872
+ cwd: root,
1873
+ path: commonOpts.config,
1874
+ envMode: commonOpts.envMode
1875
+ }), command = process.argv[2];
1876
+ if ('dev' === command || isBuildWatch) {
1877
+ let files = [
1878
+ ...envs.filePaths
1879
+ ];
1880
+ if (configFilePath && files.push(configFilePath), null === (_config_dev1 = config.dev) || void 0 === _config_dev1 ? void 0 : _config_dev1.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
1881
+ if ('reload-server' !== watchFilesConfig.type) continue;
1882
+ let paths = castArray(watchFilesConfig.paths);
1883
+ watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
1884
+ }
1885
+ watchFilesForRestart(files, root, isBuildWatch);
1886
+ }
1887
+ return config.source ||= {}, config.source.define = {
1888
+ ...envs.publicVars,
1889
+ ...config.source.define
1890
+ }, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.open && !(null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) && (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0), createRsbuild({
1891
+ cwd: root,
1892
+ rsbuildConfig: config,
1893
+ environment: commonOpts.environment
1894
+ });
1895
+ } catch (err) {
1896
+ if (isRestart) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
1897
+ else throw err;
1898
+ }
1899
+ }
1900
+ let cleaners = [], onBeforeRestartServer = (cleaner)=>{
1901
+ cleaners.push(cleaner);
1902
+ }, clearConsole = ()=>{
1903
+ isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
1904
+ }, beforeRestart = async ({ filePath, clear = !0 } = {})=>{
1905
+ if (clear && clearConsole(), filePath) {
1906
+ let filename = external_node_path_.default.basename(filePath);
1907
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(`Restart server because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(filename)} is changed.\n`);
1908
+ } else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info('Restarting server...\n');
1909
+ for (let cleaner of cleaners)await cleaner();
1910
+ cleaners = [];
1911
+ }, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
1912
+ await beforeRestart({
1913
+ filePath,
1914
+ clear
1915
+ });
1916
+ let rsbuild = await init({
1917
+ isRestart: !0
1918
+ });
1919
+ if (!!rsbuild) await rsbuild.startDevServer();
1920
+ }, restartBuild = async ({ filePath, clear = !0 } = {})=>{
1921
+ await beforeRestart({
1922
+ filePath,
1923
+ clear
1924
+ });
1925
+ let rsbuild = await init({
1926
+ isRestart: !0,
1927
+ isBuildWatch: !0
1928
+ });
1929
+ if (!!rsbuild) onBeforeRestartServer((await rsbuild.build({
1930
+ watch: !0
1931
+ })).close);
1932
+ };
1811
1933
  async function setupWatchFiles(options) {
1812
1934
  let { dev, server, root, compileMiddlewareAPI } = options, { hmr, liveReload } = dev;
1813
1935
  if (!hmr && !liveReload || !compileMiddlewareAPI) return;
@@ -1847,8 +1969,9 @@ function prepareWatchOptions(paths, options = {}, type) {
1847
1969
  type
1848
1970
  };
1849
1971
  }
1972
+ let GLOB_REGEX = /[*?{}[\]()!@+|]/, isGlob = (str)=>GLOB_REGEX.test(str);
1850
1973
  async function createChokidar(pathOrGlobs, root, options) {
1851
- let chokidar = await import("../compiled/chokidar/index.js"), watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!is_glob_default()(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
1974
+ let chokidar = await import("../compiled/chokidar/index.js"), watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!isGlob(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
1852
1975
  if (globPatterns.length) {
1853
1976
  let tinyglobby = await import("../compiled/tinyglobby/index.js"), { glob } = tinyglobby.default || tinyglobby;
1854
1977
  for (let file of (await glob(globPatterns, {
@@ -2045,7 +2168,7 @@ async function watchFilesForRestart(files, root, isBuildWatch, watchOptions) {
2045
2168
  });
2046
2169
  watcher.on('add', callback), watcher.on('change', callback), watcher.on('unlink', callback);
2047
2170
  }
2048
- async function config_loadConfig({ cwd = process.cwd(), path, envMode } = {}) {
2171
+ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta } = {}) {
2049
2172
  let configExport;
2050
2173
  let configFilePath = resolveConfigPath(cwd, path);
2051
2174
  if (!configFilePath) return {
@@ -2077,7 +2200,8 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode } = {}) {
2077
2200
  let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
2078
2201
  env: nodeEnv,
2079
2202
  command,
2080
- envMode: envMode || nodeEnv
2203
+ envMode: envMode || nodeEnv,
2204
+ meta
2081
2205
  });
2082
2206
  if (void 0 === result) throw Error('The config function must return a config object.');
2083
2207
  return {
@@ -2174,73 +2298,7 @@ let normalizePublicDirs = (publicDir)=>{
2174
2298
  ...publicDir
2175
2299
  }
2176
2300
  ];
2177
- };
2178
- class BrowserslistError extends Error {
2179
- constructor(message){
2180
- var obj, key, value;
2181
- super(message), obj = this, value = void 0, (key = "browserslist") in obj ? Object.defineProperty(obj, key, {
2182
- value: value,
2183
- enumerable: !0,
2184
- configurable: !0,
2185
- writable: !0
2186
- }) : obj[key] = value, this.name = 'BrowserslistError', this.browserslist = !0, Error.captureStackTrace && Error.captureStackTrace(this, BrowserslistError);
2187
- }
2188
- }
2189
- let isFileCache = {};
2190
- function isFile(file) {
2191
- if (file in isFileCache) return isFileCache[file];
2192
- let result = external_node_fs_.default.existsSync(file) && external_node_fs_.default.statSync(file).isFile();
2193
- return isFileCache[file] = result, result;
2194
- }
2195
- function parsePackage(file) {
2196
- let config = JSON.parse(external_node_fs_.default.readFileSync(file).toString().replace(/^\uFEFF/m, ''));
2197
- if (config.browserlist && !config.browserslist) throw new BrowserslistError(`\`browserlist\` key instead of \`browserslist\` in ${file}`);
2198
- let list = config.browserslist;
2199
- for(let i in Array.isArray(list) && (list = {
2200
- defaults: list
2201
- }), 'string' == typeof list && (list = parseConfig(list)), list)!function(section) {
2202
- let FORMAT = 'Browserslist config should be a string or an array of strings with browser queries';
2203
- if (Array.isArray(section)) {
2204
- for(let i = 0; i < section.length; i++)if ('string' != typeof section[i]) throw new BrowserslistError(FORMAT);
2205
- } else if ('string' != typeof section) throw new BrowserslistError(FORMAT);
2206
- }(list[i]);
2207
- return list;
2208
- }
2209
- let IS_SECTION = /^\s*\[(.+)]\s*$/;
2210
- function parseConfig(string) {
2211
- let result = {
2212
- defaults: []
2213
- }, sections = [
2214
- 'defaults'
2215
- ];
2216
- return string.toString().replace(/#[^\n]*/g, '').split(/\n|,/).map((line)=>line.trim()).filter((line)=>'' !== line).forEach((line)=>{
2217
- let matched = line.match(IS_SECTION);
2218
- matched ? (sections = matched[1].trim().split(' ')).forEach((section)=>{
2219
- if (result[section]) throw new BrowserslistError(`Duplicate section ${section} in Browserslist config`);
2220
- result[section] = [];
2221
- }) : sections.forEach((section)=>{
2222
- result[section].push(line);
2223
- });
2224
- }), result;
2225
- }
2226
- function parsePackageOrReadConfig(file) {
2227
- return 'package.json' === external_node_path_.default.basename(file) ? parsePackage(file) : function(file) {
2228
- if (!isFile(file)) throw new BrowserslistError(`Can't read ${file} config`);
2229
- return parseConfig(external_node_fs_.default.readFileSync(file, 'utf-8'));
2230
- }(file);
2231
- }
2232
- function pickEnv(config, opts) {
2233
- let name;
2234
- return 'object' != typeof config ? config : ('string' == typeof opts.env ? name = opts.env : process.env.BROWSERSLIST_ENV ? name = process.env.BROWSERSLIST_ENV : process.env.NODE_ENV ? name = process.env.NODE_ENV : name = 'production', config[name] || config.defaults);
2235
- }
2236
- function eachParent(file, callback) {
2237
- let dir = isFile(file) ? external_node_path_.default.dirname(file) : file, loc = external_node_path_.default.resolve(dir);
2238
- do {
2239
- let result = callback(loc);
2240
- if (void 0 !== result) return result;
2241
- }while (loc !== (loc = external_node_path_.default.dirname(loc)));
2242
- }
2243
- let configCache = {}, RSBUILD_ALL_ENVIRONMENT_SYMBOL = 'RSBUILD_ALL_ENVIRONMENT_SYMBOL', isPluginMatchEnvironment = (pluginEnvironment, currentEnvironment)=>pluginEnvironment === currentEnvironment || pluginEnvironment === RSBUILD_ALL_ENVIRONMENT_SYMBOL, pluginDagSort = (plugins)=>{
2301
+ }, RSBUILD_ALL_ENVIRONMENT_SYMBOL = 'RSBUILD_ALL_ENVIRONMENT_SYMBOL', isPluginMatchEnvironment = (pluginEnvironment, currentEnvironment)=>pluginEnvironment === currentEnvironment || pluginEnvironment === RSBUILD_ALL_ENVIRONMENT_SYMBOL, pluginDagSort = (plugins)=>{
2244
2302
  let allLines = [];
2245
2303
  function getPlugin(name) {
2246
2304
  let targets = plugins.filter((item)=>item.instance.name === name);
@@ -2576,7 +2634,7 @@ async function updateEnvironmentContext(context, configs) {
2576
2634
  async function createContext(options, userConfig, bundlerType) {
2577
2635
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache');
2578
2636
  return {
2579
- version: "1.1.2",
2637
+ version: "1.1.4",
2580
2638
  rootPath,
2581
2639
  distPath: '',
2582
2640
  cachePath,
@@ -2899,11 +2957,7 @@ function reduceConfigsMergeContext({ initial, config, ctx, mergeFn = Object.assi
2899
2957
  mergeFn
2900
2958
  }), initial) : config ?? initial;
2901
2959
  }
2902
- let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), setHTMLPlugin = (plugin)=>{
2903
- plugin && (pluginHelper_htmlPlugin = plugin);
2904
- }, getHTMLPlugin = ()=>(!pluginHelper_htmlPlugin && (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
2905
- cssExtractPlugin = plugin;
2906
- }, getCssExtractPlugin = ()=>cssExtractPlugin ? cssExtractPlugin : __WEBPACK_EXTERNAL_MODULE__rspack_core__.default.CssExtractRspackPlugin, getCSSModulesLocalIdentName = (config, isProd)=>config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), normalizeCssLoaderOptions = (options, exportOnlyLocals)=>{
2960
+ let getCSSModulesLocalIdentName = (config, isProd)=>config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), normalizeCssLoaderOptions = (options, exportOnlyLocals)=>{
2907
2961
  if (options.modules && exportOnlyLocals) {
2908
2962
  let { modules } = options;
2909
2963
  return modules = !0 === modules ? {
@@ -2987,62 +3041,56 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2987
3041
  config: config.tools.cssLoader,
2988
3042
  mergeFn: cjs_default()
2989
3043
  }), !emitCss);
2990
- };
2991
- async function applyCSSRule({ rule, config, context, utils: { target, isProd, CHAIN_ID, environment } }) {
2992
- let emitCss = config.output.emitCss ?? 'web' === target;
2993
- if (emitCss) {
2994
- if (config.output.injectStyles) {
2995
- let styleLoaderOptions = reduceConfigs({
2996
- initial: {},
2997
- config: config.tools.styleLoader
2998
- });
2999
- rule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
3000
- } else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(getCssExtractPlugin().loader).options(config.tools.cssExtract.loaderOptions);
3001
- } else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(external_node_path_.default.join(LOADER_PATH, 'ignoreCssLoader.cjs'));
3002
- let importLoaders = 0;
3003
- if (rule.use(CHAIN_ID.USE.CSS).loader(getCompiledPath('css-loader')), emitCss) {
3004
- var _postcssLoaderOptions_postcssOptions_plugins, _postcssLoaderOptions_postcssOptions;
3005
- if ('rspack' === context.bundlerType && !1 !== config.tools.lightningcssLoader) {
3006
- importLoaders++;
3007
- let userOptions = !0 === config.tools.lightningcssLoader ? {} : config.tools.lightningcssLoader, initialOptions = {
3008
- targets: environment.browserslist
3009
- };
3010
- 'production' === config.mode && config.output.injectStyles && (initialOptions.minify = !0);
3011
- let loaderOptions = reduceConfigs({
3012
- initial: initialOptions,
3013
- config: userOptions
3014
- });
3015
- rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(loaderOptions);
3016
- }
3017
- let postcssLoaderOptions = await getPostcssLoaderOptions({
3018
- config,
3019
- root: context.rootPath
3020
- });
3021
- ('function' == typeof postcssLoaderOptions.postcssOptions || (null === (_postcssLoaderOptions_postcssOptions = postcssLoaderOptions.postcssOptions) || void 0 === _postcssLoaderOptions_postcssOptions ? void 0 : null === (_postcssLoaderOptions_postcssOptions_plugins = _postcssLoaderOptions_postcssOptions.plugins) || void 0 === _postcssLoaderOptions_postcssOptions_plugins ? void 0 : _postcssLoaderOptions_postcssOptions_plugins.length)) && (importLoaders++, rule.use(CHAIN_ID.USE.POSTCSS).loader(getCompiledPath('postcss-loader')).options(postcssLoaderOptions));
3022
- }
3023
- let localIdentName = getCSSModulesLocalIdentName(config, isProd), cssLoaderOptions = getCSSLoaderOptions({
3024
- config,
3025
- importLoaders,
3026
- localIdentName,
3027
- emitCss
3028
- });
3029
- rule.use(CHAIN_ID.USE.CSS).options(cssLoaderOptions), rule.merge({
3030
- sideEffects: !0
3031
- }), rule.resolve.preferRelative(!0);
3032
- }
3033
- let pluginCss = ()=>({
3044
+ }, pluginCss = ()=>({
3034
3045
  name: 'rsbuild:css',
3035
3046
  setup (api) {
3036
3047
  api.modifyBundlerChain({
3037
3048
  order: 'pre',
3038
- handler: async (chain, utils)=>{
3039
- let rule = chain.module.rule(utils.CHAIN_ID.RULE.CSS), { config } = utils.environment;
3040
- rule.test(CSS_REGEX).type('javascript/auto'), await applyCSSRule({
3041
- rule,
3042
- utils,
3049
+ handler: async (chain, { target, isProd, CHAIN_ID, environment })=>{
3050
+ let rule = chain.module.rule(CHAIN_ID.RULE.CSS), { config } = environment;
3051
+ rule.test(CSS_REGEX).type('javascript/auto').dependency({
3052
+ not: 'url'
3053
+ });
3054
+ let emitCss = config.output.emitCss ?? 'web' === target;
3055
+ if (emitCss) {
3056
+ if (config.output.injectStyles) {
3057
+ let styleLoaderOptions = reduceConfigs({
3058
+ initial: {},
3059
+ config: config.tools.styleLoader
3060
+ });
3061
+ rule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
3062
+ } else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(getCssExtractPlugin().loader).options(config.tools.cssExtract.loaderOptions);
3063
+ } else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(external_node_path_.default.join(LOADER_PATH, 'ignoreCssLoader.cjs'));
3064
+ let importLoaders = 0;
3065
+ if (rule.use(CHAIN_ID.USE.CSS).loader(getCompiledPath('css-loader')), emitCss) {
3066
+ var _postcssLoaderOptions_postcssOptions_plugins, _postcssLoaderOptions_postcssOptions;
3067
+ if ('rspack' === api.context.bundlerType && !1 !== config.tools.lightningcssLoader) {
3068
+ importLoaders++;
3069
+ let userOptions = !0 === config.tools.lightningcssLoader ? {} : config.tools.lightningcssLoader, initialOptions = {
3070
+ targets: environment.browserslist
3071
+ };
3072
+ 'production' === config.mode && config.output.injectStyles && (initialOptions.minify = !0);
3073
+ let loaderOptions = reduceConfigs({
3074
+ initial: initialOptions,
3075
+ config: userOptions
3076
+ });
3077
+ rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(loaderOptions);
3078
+ }
3079
+ let postcssLoaderOptions = await getPostcssLoaderOptions({
3080
+ config,
3081
+ root: api.context.rootPath
3082
+ });
3083
+ ('function' == typeof postcssLoaderOptions.postcssOptions || (null === (_postcssLoaderOptions_postcssOptions = postcssLoaderOptions.postcssOptions) || void 0 === _postcssLoaderOptions_postcssOptions ? void 0 : null === (_postcssLoaderOptions_postcssOptions_plugins = _postcssLoaderOptions_postcssOptions.plugins) || void 0 === _postcssLoaderOptions_postcssOptions_plugins ? void 0 : _postcssLoaderOptions_postcssOptions_plugins.length)) && (importLoaders++, rule.use(CHAIN_ID.USE.POSTCSS).loader(getCompiledPath('postcss-loader')).options(postcssLoaderOptions));
3084
+ }
3085
+ let localIdentName = getCSSModulesLocalIdentName(config, isProd), cssLoaderOptions = getCSSLoaderOptions({
3043
3086
  config,
3044
- context: api.context
3087
+ importLoaders,
3088
+ localIdentName,
3089
+ emitCss
3045
3090
  });
3091
+ rule.use(CHAIN_ID.USE.CSS).options(cssLoaderOptions), rule.merge({
3092
+ sideEffects: !0
3093
+ }), rule.resolve.preferRelative(!0);
3046
3094
  }
3047
3095
  });
3048
3096
  }
@@ -3848,7 +3896,7 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (inp
3848
3896
  let trailingSlashBase = addTrailingSlash(base);
3849
3897
  return path.startsWith(trailingSlashBase) ? path.slice(trailingSlashBase.length - 1) : path;
3850
3898
  }, getRoutes = (context)=>Object.values(context.environments).reduce((prev, environmentContext)=>{
3851
- let { distPath, config } = environmentContext, distPrefix = external_node_path_.posix.relative(context.distPath, distPath), routes = formatRoutes(environmentContext.htmlPaths, context.normalizedConfig.server.base, external_node_path_.posix.join(distPrefix, config.output.distPath.html), config.html.outputStructure);
3899
+ let { distPath, config } = environmentContext, distPrefix = (0, external_node_path_.relative)(context.distPath, distPath).split(external_node_path_.sep).join('/'), routes = formatRoutes(environmentContext.htmlPaths, context.normalizedConfig.server.base, external_node_path_.posix.join(distPrefix, config.output.distPath.html), config.html.outputStructure);
3852
3900
  return prev.concat(...routes);
3853
3901
  }, []), formatRoutes = (entry, base, distPathPrefix, outputStructure)=>{
3854
3902
  let prefix = joinUrlSegments(base, formatPrefix(distPathPrefix));
@@ -4668,7 +4716,9 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4668
4716
  order: 'pre',
4669
4717
  handler: async (chain, { CHAIN_ID, isDev, target, environment })=>{
4670
4718
  var browserslist, target1;
4671
- let { config, browserslist: browserslist1 } = environment, cacheRoot = external_node_path_.default.join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).type('javascript/auto'), dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
4719
+ let { config, browserslist: browserslist1 } = environment, cacheRoot = external_node_path_.default.join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).type('javascript/auto').dependency({
4720
+ not: 'url'
4721
+ }), dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
4672
4722
  or: [
4673
4723
  'text/javascript',
4674
4724
  'application/javascript'
@@ -5329,7 +5379,9 @@ class SocketServer {
5329
5379
  }
5330
5380
  getStats(name) {
5331
5381
  let curStats = this.stats[name];
5332
- return curStats ? curStats.toJson({
5382
+ if (!curStats) return null;
5383
+ let statsOptions = getStatsOptions(curStats.compilation.compiler);
5384
+ return curStats.toJson({
5333
5385
  all: !1,
5334
5386
  hash: !0,
5335
5387
  assets: !0,
@@ -5339,8 +5391,10 @@ class SocketServer {
5339
5391
  errorsCount: !0,
5340
5392
  errorDetails: !1,
5341
5393
  entrypoints: !0,
5342
- children: !0
5343
- }) : null;
5394
+ children: !0,
5395
+ moduleTrace: !0,
5396
+ ...statsOptions
5397
+ });
5344
5398
  }
5345
5399
  sendStats({ force = !1, compilationId }) {
5346
5400
  let stats = this.getStats(compilationId);
@@ -6140,13 +6194,10 @@ async function createCompiler_createCompiler(options) {
6140
6194
  let done = (stats)=>{
6141
6195
  let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
6142
6196
  children: !0,
6197
+ moduleTrace: !0,
6143
6198
  timings: !0,
6144
- ...'string' == typeof statsOptions ? {
6145
- preset: statsOptions
6146
- } : {
6147
- preset: 'errors-warnings'
6148
- },
6149
- ...'object' == typeof statsOptions ? statsOptions : {}
6199
+ preset: 'errors-warnings',
6200
+ ...statsOptions
6150
6201
  }), printTime = (c, index)=>{
6151
6202
  if (c.time) {
6152
6203
  let time = prettyTime(c.time / 1000), { name } = rspackConfigs[index], suffix = name ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.gray(` (${name})`) : '';
@@ -6802,187 +6853,86 @@ async function createRsbuild(options = {}) {
6802
6853
  }
6803
6854
  })), rsbuild;
6804
6855
  }
6805
- var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@11.0.6/node_modules/dotenv-expand/lib/main.js");
6806
- function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
6807
- 'PUBLIC_'
6808
- ] } = {}) {
6809
- if ('local' === mode) throw Error("'local' cannot be used as a value for env mode, because \".env.local\" represents a temporary local file. Please use another value.");
6810
- let filePaths = [
6811
- '.env',
6812
- '.env.local',
6813
- `.env.${mode}`,
6814
- `.env.${mode}.local`
6815
- ].map((filename)=>(0, external_node_path_.join)(cwd, filename)).filter(isFileSync), parsed = {};
6816
- for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(external_node_fs_.default.readFileSync(envPath)));
6817
- parsed.NODE_ENV && (process.env.NODE_ENV = parsed.NODE_ENV), (0, lib_main.expand)({
6818
- parsed
6819
- });
6820
- let publicVars = {}, rawPublicVars = {};
6821
- for (let key of Object.keys(process.env))if (prefixes.some((prefix)=>key.startsWith(prefix))) {
6822
- let val = process.env[key];
6823
- publicVars[`import.meta.env.${key}`] = JSON.stringify(val), publicVars[`process.env.${key}`] = JSON.stringify(val), rawPublicVars[key] = val;
6824
- }
6825
- let cleaned = !1;
6826
- return {
6827
- parsed,
6828
- cleanup: ()=>{
6829
- if (!cleaned) {
6830
- for (let key of Object.keys(parsed)){
6831
- if ('NODE_ENV' !== key) process.env[key] === parsed[key] && delete process.env[key];
6832
- }
6833
- cleaned = !0;
6834
- }
6835
- },
6836
- filePaths,
6837
- publicVars,
6838
- rawPublicVars
6839
- };
6840
- }
6841
- let commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? external_node_path_.default.isAbsolute(envDir) ? envDir : external_node_path_.default.resolve(cwd, envDir) : cwd;
6842
- async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
6843
- cliOptions && (commonOpts = cliOptions);
6844
- try {
6845
- var _config_server, _config_dev, _config_dev1;
6846
- let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
6847
- cwd: getEnvDir(root, commonOpts.envDir),
6848
- mode: commonOpts.envMode
6849
- });
6850
- onBeforeRestartServer(envs.cleanup);
6851
- let { content: config, filePath: configFilePath } = await config_loadConfig({
6852
- cwd: root,
6853
- path: commonOpts.config,
6854
- envMode: commonOpts.envMode
6855
- }), command = process.argv[2];
6856
- if ('dev' === command || isBuildWatch) {
6857
- let files = [
6858
- ...envs.filePaths
6859
- ];
6860
- if (configFilePath && files.push(configFilePath), null === (_config_dev1 = config.dev) || void 0 === _config_dev1 ? void 0 : _config_dev1.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
6861
- if ('reload-server' !== watchFilesConfig.type) continue;
6862
- let paths = castArray(watchFilesConfig.paths);
6863
- watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
6864
- }
6865
- watchFilesForRestart(files, root, isBuildWatch);
6866
- }
6867
- return config.source ||= {}, config.source.define = {
6868
- ...envs.publicVars,
6869
- ...config.source.define
6870
- }, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.open && !(null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) && (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0), createRsbuild({
6871
- cwd: root,
6872
- rsbuildConfig: config,
6873
- environment: commonOpts.environment
6874
- });
6875
- } catch (err) {
6876
- if (isRestart) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
6877
- else throw err;
6878
- }
6879
- }
6880
- let cleaners = [], onBeforeRestartServer = (cleaner)=>{
6881
- cleaners.push(cleaner);
6882
- }, clearConsole = ()=>{
6883
- isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
6884
- }, beforeRestart = async ({ filePath, clear = !0 } = {})=>{
6885
- if (clear && clearConsole(), filePath) {
6886
- let filename = external_node_path_.default.basename(filePath);
6887
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(`Restart server because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(filename)} is changed.\n`);
6888
- } else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info('Restarting server...\n');
6889
- for (let cleaner of cleaners)await cleaner();
6890
- cleaners = [];
6891
- }, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
6892
- await beforeRestart({
6893
- filePath,
6894
- clear
6895
- });
6896
- let rsbuild = await init({
6897
- isRestart: !0
6898
- });
6899
- if (!!rsbuild) await rsbuild.startDevServer();
6900
- }, restartBuild = async ({ filePath, clear = !0 } = {})=>{
6901
- await beforeRestart({
6902
- filePath,
6903
- clear
6904
- });
6905
- let rsbuild = await init({
6906
- isRestart: !0,
6907
- isBuildWatch: !0
6908
- });
6909
- if (!!rsbuild) onBeforeRestartServer((await rsbuild.build({
6910
- watch: !0
6911
- })).close);
6912
- }, applyCommonOptions = (command)=>{
6856
+ let { program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/index.js"), applyCommonOptions = (command)=>{
6913
6857
  command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').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('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', (str, prev)=>prev ? prev.concat(str.split(',')) : str.split(',')).option('--env-dir <dir>', 'specify the directory to load `.env` files');
6914
6858
  }, applyServerOptions = (command)=>{
6915
6859
  command.option('-o --open [url]', 'open the page in browser on startup').option('--port <port>', 'specify a port number for server to listen').option('--host <host>', 'specify the host that the server listens to');
6916
6860
  };
6917
- function runCli() {
6918
- program.name('rsbuild').usage('<command> [options]').version("1.1.2");
6919
- let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
6920
- [
6921
- devCommand,
6922
- buildCommand,
6923
- previewCommand,
6924
- inspectCommand
6925
- ].forEach(applyCommonOptions), [
6926
- devCommand,
6927
- previewCommand
6928
- ].forEach(applyServerOptions), devCommand.description('starting the dev server').action(async (options)=>{
6929
- try {
6930
- let rsbuild = await init({
6931
- cliOptions: options
6932
- });
6933
- await (null == rsbuild ? void 0 : rsbuild.startDevServer());
6934
- } catch (err) {
6935
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start dev server.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6936
- }
6937
- }), buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the app for production').action(async (options)=>{
6938
- try {
6939
- let rsbuild = await init({
6940
- cliOptions: options,
6941
- isBuildWatch: options.watch
6942
- }), buildInstance = await (null == rsbuild ? void 0 : rsbuild.build({
6943
- watch: options.watch
6944
- }));
6945
- options.watch && buildInstance && onBeforeRestartServer(buildInstance.close);
6946
- } catch (err) {
6947
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to build.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6948
- }
6949
- }), previewCommand.description('preview the production build locally').action(async (options)=>{
6950
- try {
6951
- let rsbuild = await init({
6952
- cliOptions: options
6953
- });
6954
- await (null == rsbuild ? void 0 : rsbuild.preview());
6955
- } catch (err) {
6956
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start preview server.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6957
- }
6958
- }), inspectCommand.description('inspect the Rspack and Rsbuild configs').option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action(async (options)=>{
6959
- try {
6960
- let rsbuild = await init({
6961
- cliOptions: options
6962
- });
6963
- await (null == rsbuild ? void 0 : rsbuild.inspectConfig({
6964
- verbose: options.verbose,
6965
- outputPath: options.output,
6966
- writeToDisk: !0
6967
- }));
6968
- } catch (err) {
6969
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to inspect config.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6970
- }
6971
- }), program.parse();
6972
- }
6973
- function prepareCli() {
6861
+ async function runCLI() {
6974
6862
  !function() {
6975
- if (!process.env.NODE_ENV) {
6976
- let command = process.argv[2];
6977
- process.env.NODE_ENV = [
6978
- 'build',
6979
- 'preview'
6980
- ].includes(command) ? 'production' : 'development';
6981
- }
6863
+ !function() {
6864
+ if (!process.env.NODE_ENV) {
6865
+ let command = process.argv[2];
6866
+ process.env.NODE_ENV = [
6867
+ 'build',
6868
+ 'preview'
6869
+ ].includes(command) ? 'production' : 'development';
6870
+ }
6871
+ }();
6872
+ let { npm_execpath } = process.env;
6873
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.4\n`);
6982
6874
  }();
6983
- let { npm_execpath } = process.env;
6984
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.2\n`);
6875
+ try {
6876
+ !function() {
6877
+ program.name('rsbuild').usage('<command> [options]').version("1.1.4");
6878
+ let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
6879
+ [
6880
+ devCommand,
6881
+ buildCommand,
6882
+ previewCommand,
6883
+ inspectCommand
6884
+ ].forEach(applyCommonOptions), [
6885
+ devCommand,
6886
+ previewCommand
6887
+ ].forEach(applyServerOptions), devCommand.description('starting the dev server').action(async (options)=>{
6888
+ try {
6889
+ let rsbuild = await init({
6890
+ cliOptions: options
6891
+ });
6892
+ await (null == rsbuild ? void 0 : rsbuild.startDevServer());
6893
+ } catch (err) {
6894
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start dev server.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6895
+ }
6896
+ }), buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the app for production').action(async (options)=>{
6897
+ try {
6898
+ let rsbuild = await init({
6899
+ cliOptions: options,
6900
+ isBuildWatch: options.watch
6901
+ }), buildInstance = await (null == rsbuild ? void 0 : rsbuild.build({
6902
+ watch: options.watch
6903
+ }));
6904
+ options.watch && buildInstance && onBeforeRestartServer(buildInstance.close);
6905
+ } catch (err) {
6906
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to build.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6907
+ }
6908
+ }), previewCommand.description('preview the production build locally').action(async (options)=>{
6909
+ try {
6910
+ let rsbuild = await init({
6911
+ cliOptions: options
6912
+ });
6913
+ await (null == rsbuild ? void 0 : rsbuild.preview());
6914
+ } catch (err) {
6915
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start preview server.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6916
+ }
6917
+ }), inspectCommand.description('inspect the Rspack and Rsbuild configs').option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action(async (options)=>{
6918
+ try {
6919
+ let rsbuild = await init({
6920
+ cliOptions: options
6921
+ });
6922
+ await (null == rsbuild ? void 0 : rsbuild.inspectConfig({
6923
+ verbose: options.verbose,
6924
+ outputPath: options.output,
6925
+ writeToDisk: !0
6926
+ }));
6927
+ } catch (err) {
6928
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to inspect config.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6929
+ }
6930
+ }), program.parse();
6931
+ }();
6932
+ } catch (err) {
6933
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
6934
+ }
6985
6935
  }
6986
- let src_version = "1.1.2";
6936
+ let src_version = "1.1.4";
6987
6937
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack;
6988
- export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, internal_namespaceObject as __internalHelper, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
6938
+ export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, internal_namespaceObject as __internalHelper, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };