@rsbuild/core 1.1.2 → 1.1.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/bin/rsbuild.js +2 -10
- package/compiled/css-loader/index.js +46 -46
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss/index.js +135 -117
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +11 -11
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/client/hmr.js +10 -1
- package/dist/index.cjs +406 -453
- package/dist/index.js +309 -358
- package/dist-types/cli/commands.d.ts +1 -1
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/helpers/stats.d.ts +2 -3
- package/dist-types/index.d.ts +1 -0
- package/dist-types/internal.d.ts +0 -2
- package/package.json +4 -6
- package/dist/index.cjs.LICENSE.txt +0 -13
- package/dist/index.js.LICENSE.txt +0 -13
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
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.
|
|
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]
|
|
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
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1613
|
+
if (isMultiCompiler(compiler)) return {
|
|
1647
1614
|
children: compiler.compilers.map((compiler)=>compiler.options ? compiler.options.stats : void 0)
|
|
1648
|
-
}
|
|
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
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
'
|
|
1757
|
-
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)=>!!
|
|
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, {
|
|
@@ -2174,73 +2297,7 @@ let normalizePublicDirs = (publicDir)=>{
|
|
|
2174
2297
|
...publicDir
|
|
2175
2298
|
}
|
|
2176
2299
|
];
|
|
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)=>{
|
|
2300
|
+
}, RSBUILD_ALL_ENVIRONMENT_SYMBOL = 'RSBUILD_ALL_ENVIRONMENT_SYMBOL', isPluginMatchEnvironment = (pluginEnvironment, currentEnvironment)=>pluginEnvironment === currentEnvironment || pluginEnvironment === RSBUILD_ALL_ENVIRONMENT_SYMBOL, pluginDagSort = (plugins)=>{
|
|
2244
2301
|
let allLines = [];
|
|
2245
2302
|
function getPlugin(name) {
|
|
2246
2303
|
let targets = plugins.filter((item)=>item.instance.name === name);
|
|
@@ -2576,7 +2633,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2576
2633
|
async function createContext(options, userConfig, bundlerType) {
|
|
2577
2634
|
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
2635
|
return {
|
|
2579
|
-
version: "1.1.
|
|
2636
|
+
version: "1.1.3",
|
|
2580
2637
|
rootPath,
|
|
2581
2638
|
distPath: '',
|
|
2582
2639
|
cachePath,
|
|
@@ -2899,11 +2956,7 @@ function reduceConfigsMergeContext({ initial, config, ctx, mergeFn = Object.assi
|
|
|
2899
2956
|
mergeFn
|
|
2900
2957
|
}), initial) : config ?? initial;
|
|
2901
2958
|
}
|
|
2902
|
-
let
|
|
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)=>{
|
|
2959
|
+
let getCSSModulesLocalIdentName = (config, isProd)=>config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), normalizeCssLoaderOptions = (options, exportOnlyLocals)=>{
|
|
2907
2960
|
if (options.modules && exportOnlyLocals) {
|
|
2908
2961
|
let { modules } = options;
|
|
2909
2962
|
return modules = !0 === modules ? {
|
|
@@ -5329,7 +5382,9 @@ class SocketServer {
|
|
|
5329
5382
|
}
|
|
5330
5383
|
getStats(name) {
|
|
5331
5384
|
let curStats = this.stats[name];
|
|
5332
|
-
|
|
5385
|
+
if (!curStats) return null;
|
|
5386
|
+
let statsOptions = getStatsOptions(curStats.compilation.compiler);
|
|
5387
|
+
return curStats.toJson({
|
|
5333
5388
|
all: !1,
|
|
5334
5389
|
hash: !0,
|
|
5335
5390
|
assets: !0,
|
|
@@ -5339,8 +5394,9 @@ class SocketServer {
|
|
|
5339
5394
|
errorsCount: !0,
|
|
5340
5395
|
errorDetails: !1,
|
|
5341
5396
|
entrypoints: !0,
|
|
5342
|
-
children: !0
|
|
5343
|
-
|
|
5397
|
+
children: !0,
|
|
5398
|
+
...statsOptions
|
|
5399
|
+
});
|
|
5344
5400
|
}
|
|
5345
5401
|
sendStats({ force = !1, compilationId }) {
|
|
5346
5402
|
let stats = this.getStats(compilationId);
|
|
@@ -6141,12 +6197,8 @@ async function createCompiler_createCompiler(options) {
|
|
|
6141
6197
|
let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
|
|
6142
6198
|
children: !0,
|
|
6143
6199
|
timings: !0,
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
} : {
|
|
6147
|
-
preset: 'errors-warnings'
|
|
6148
|
-
},
|
|
6149
|
-
...'object' == typeof statsOptions ? statsOptions : {}
|
|
6200
|
+
preset: 'errors-warnings',
|
|
6201
|
+
...statsOptions
|
|
6150
6202
|
}), printTime = (c, index)=>{
|
|
6151
6203
|
if (c.time) {
|
|
6152
6204
|
let time = prettyTime(c.time / 1000), { name } = rspackConfigs[index], suffix = name ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.gray(` (${name})`) : '';
|
|
@@ -6802,187 +6854,86 @@ async function createRsbuild(options = {}) {
|
|
|
6802
6854
|
}
|
|
6803
6855
|
})), rsbuild;
|
|
6804
6856
|
}
|
|
6805
|
-
|
|
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)=>{
|
|
6857
|
+
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
6858
|
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
6859
|
}, applyServerOptions = (command)=>{
|
|
6915
6860
|
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
6861
|
};
|
|
6917
|
-
function
|
|
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() {
|
|
6862
|
+
async function runCLI() {
|
|
6974
6863
|
!function() {
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6864
|
+
!function() {
|
|
6865
|
+
if (!process.env.NODE_ENV) {
|
|
6866
|
+
let command = process.argv[2];
|
|
6867
|
+
process.env.NODE_ENV = [
|
|
6868
|
+
'build',
|
|
6869
|
+
'preview'
|
|
6870
|
+
].includes(command) ? 'production' : 'development';
|
|
6871
|
+
}
|
|
6872
|
+
}();
|
|
6873
|
+
let { npm_execpath } = process.env;
|
|
6874
|
+
(!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.3\n`);
|
|
6982
6875
|
}();
|
|
6983
|
-
|
|
6984
|
-
|
|
6876
|
+
try {
|
|
6877
|
+
!function() {
|
|
6878
|
+
program.name('rsbuild').usage('<command> [options]').version("1.1.3");
|
|
6879
|
+
let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
|
|
6880
|
+
[
|
|
6881
|
+
devCommand,
|
|
6882
|
+
buildCommand,
|
|
6883
|
+
previewCommand,
|
|
6884
|
+
inspectCommand
|
|
6885
|
+
].forEach(applyCommonOptions), [
|
|
6886
|
+
devCommand,
|
|
6887
|
+
previewCommand
|
|
6888
|
+
].forEach(applyServerOptions), devCommand.description('starting the dev server').action(async (options)=>{
|
|
6889
|
+
try {
|
|
6890
|
+
let rsbuild = await init({
|
|
6891
|
+
cliOptions: options
|
|
6892
|
+
});
|
|
6893
|
+
await (null == rsbuild ? void 0 : rsbuild.startDevServer());
|
|
6894
|
+
} catch (err) {
|
|
6895
|
+
__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);
|
|
6896
|
+
}
|
|
6897
|
+
}), buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the app for production').action(async (options)=>{
|
|
6898
|
+
try {
|
|
6899
|
+
let rsbuild = await init({
|
|
6900
|
+
cliOptions: options,
|
|
6901
|
+
isBuildWatch: options.watch
|
|
6902
|
+
}), buildInstance = await (null == rsbuild ? void 0 : rsbuild.build({
|
|
6903
|
+
watch: options.watch
|
|
6904
|
+
}));
|
|
6905
|
+
options.watch && buildInstance && onBeforeRestartServer(buildInstance.close);
|
|
6906
|
+
} catch (err) {
|
|
6907
|
+
__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);
|
|
6908
|
+
}
|
|
6909
|
+
}), previewCommand.description('preview the production build locally').action(async (options)=>{
|
|
6910
|
+
try {
|
|
6911
|
+
let rsbuild = await init({
|
|
6912
|
+
cliOptions: options
|
|
6913
|
+
});
|
|
6914
|
+
await (null == rsbuild ? void 0 : rsbuild.preview());
|
|
6915
|
+
} catch (err) {
|
|
6916
|
+
__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);
|
|
6917
|
+
}
|
|
6918
|
+
}), 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)=>{
|
|
6919
|
+
try {
|
|
6920
|
+
let rsbuild = await init({
|
|
6921
|
+
cliOptions: options
|
|
6922
|
+
});
|
|
6923
|
+
await (null == rsbuild ? void 0 : rsbuild.inspectConfig({
|
|
6924
|
+
verbose: options.verbose,
|
|
6925
|
+
outputPath: options.output,
|
|
6926
|
+
writeToDisk: !0
|
|
6927
|
+
}));
|
|
6928
|
+
} catch (err) {
|
|
6929
|
+
__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);
|
|
6930
|
+
}
|
|
6931
|
+
}), program.parse();
|
|
6932
|
+
}();
|
|
6933
|
+
} catch (err) {
|
|
6934
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
6935
|
+
}
|
|
6985
6936
|
}
|
|
6986
|
-
let src_version = "1.1.
|
|
6937
|
+
let src_version = "1.1.3";
|
|
6987
6938
|
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 };
|
|
6939
|
+
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 };
|