@rsbuild/core 1.2.19 → 1.3.0-beta.1
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/compiled/css-loader/index.js +20 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-chain/index.d.ts +1 -1
- package/compiled/rspack-chain/index.js +66 -66
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/client/overlay.js +9 -6
- package/dist/index.cjs +252 -262
- package/dist/index.js +252 -262
- package/dist/transformLoader.mjs +20 -16
- package/dist/transformRawLoader.mjs +20 -16
- package/dist-types/config.d.ts +0 -2
- package/dist-types/configChain.d.ts +11 -5
- package/dist-types/helpers/index.d.ts +0 -1
- package/dist-types/restart.d.ts +18 -0
- package/dist-types/server/cliShortcuts.d.ts +1 -1
- package/dist-types/server/helper.d.ts +10 -0
- package/dist-types/types/config.d.ts +9 -0
- package/dist-types/types/context.d.ts +10 -8
- package/dist-types/types/rsbuild.d.ts +2 -2
- package/package.json +4 -4
- package/types.d.ts +28 -0
- package/dist-types/cli/prepare.d.ts +0 -1
- package/dist-types/server/restart.d.ts +0 -14
package/dist/index.js
CHANGED
|
@@ -1072,7 +1072,7 @@ async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
|
1072
1072
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`failed to empty dir: ${dir}`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(err);
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
1075
|
-
let hintNodePolyfill = (message)=>{
|
|
1075
|
+
let formatFileName = (fileName)=>/:\d+:\d+/.test(fileName) ? `File: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(fileName)}\n` : `File: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(fileName)}:1:1\n`, hintNodePolyfill = (message)=>{
|
|
1076
1076
|
let getTips = (moduleName)=>{
|
|
1077
1077
|
let tips = [
|
|
1078
1078
|
`Tip: "${moduleName}" is a built-in Node.js module. It cannot be imported in client-side code.`,
|
|
@@ -1134,11 +1134,11 @@ function formatMessage(stats, verbose) {
|
|
|
1134
1134
|
let matched = stats.moduleIdentifier.match(/(?:\!|^)([^!]+)$/);
|
|
1135
1135
|
if (matched) {
|
|
1136
1136
|
let fileName = matched.pop();
|
|
1137
|
-
if (fileName) return
|
|
1137
|
+
if (fileName) return formatFileName(fileName);
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
1140
|
let file = stats.file || stats.moduleName;
|
|
1141
|
-
return file ?
|
|
1141
|
+
return file ? formatFileName(file) : '';
|
|
1142
1142
|
}(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
|
|
1143
1143
|
let traceStr = '';
|
|
1144
1144
|
if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
|
|
@@ -1220,10 +1220,10 @@ function formatStats(statsData, hasErrors) {
|
|
|
1220
1220
|
}, verbose);
|
|
1221
1221
|
return {
|
|
1222
1222
|
message: function(errors) {
|
|
1223
|
-
let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red('
|
|
1223
|
+
let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red('Build error: '));
|
|
1224
1224
|
if (!errors.length) return `${title}\n${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow("For more details, please setting 'stats.errors: true' ")}`;
|
|
1225
|
-
let
|
|
1226
|
-
return `${title}\n${
|
|
1225
|
+
let text = `${errors.join('\n\n')}\n`;
|
|
1226
|
+
return `${title}\n${text}`;
|
|
1227
1227
|
}(errors),
|
|
1228
1228
|
level: 'error'
|
|
1229
1229
|
};
|
|
@@ -1233,7 +1233,7 @@ function formatStats(statsData, hasErrors) {
|
|
|
1233
1233
|
warnings: getAllStatsWarnings(statsData)
|
|
1234
1234
|
}, verbose);
|
|
1235
1235
|
if (warnings.length) {
|
|
1236
|
-
let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('Compile
|
|
1236
|
+
let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('Compile warning: \n'));
|
|
1237
1237
|
return {
|
|
1238
1238
|
message: `${title}${warnings.join('\n\n')}\n`,
|
|
1239
1239
|
level: 'warning'
|
|
@@ -1443,10 +1443,14 @@ let configCache = {}, OVERRIDE_PATHS = [
|
|
|
1443
1443
|
x,
|
|
1444
1444
|
y
|
|
1445
1445
|
];
|
|
1446
|
-
if (pair.some(Array.isArray)) return [
|
|
1446
|
+
if (pair.some(Array.isArray)) return 'output.copy' !== path || pair.every(Array.isArray) ? [
|
|
1447
1447
|
...castArray(x),
|
|
1448
1448
|
...castArray(y)
|
|
1449
|
-
]
|
|
1449
|
+
] : Array.isArray(x) ? merge({
|
|
1450
|
+
patterns: x
|
|
1451
|
+
}, y, path) : merge(x, {
|
|
1452
|
+
patterns: y
|
|
1453
|
+
}, path);
|
|
1450
1454
|
if (pair.some(isFunction)) return pair;
|
|
1451
1455
|
if (!isPlainObject(x) || !isPlainObject(y)) return y;
|
|
1452
1456
|
let merged = {};
|
|
@@ -1458,146 +1462,7 @@ let configCache = {}, OVERRIDE_PATHS = [
|
|
|
1458
1462
|
merged[key] = merge(x[key], y[key], childPath);
|
|
1459
1463
|
}
|
|
1460
1464
|
return merged;
|
|
1461
|
-
}, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}),
|
|
1462
|
-
var _config_server;
|
|
1463
|
-
let { content: config, filePath } = await config_loadConfig({
|
|
1464
|
-
cwd: root,
|
|
1465
|
-
path: commonOpts.config,
|
|
1466
|
-
envMode: commonOpts.envMode,
|
|
1467
|
-
loader: commonOpts.configLoader
|
|
1468
|
-
});
|
|
1469
|
-
return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), 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.open = commonOpts.open), commonOpts.host && (config.server.host = commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
|
|
1470
|
-
...config.dev.watchFiles ? castArray(config.dev.watchFiles) : [],
|
|
1471
|
-
{
|
|
1472
|
-
paths: filePath,
|
|
1473
|
-
type: 'reload-server'
|
|
1474
|
-
}
|
|
1475
|
-
]), config;
|
|
1476
|
-
};
|
|
1477
|
-
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
1478
|
-
cliOptions && (commonOpts = cliOptions);
|
|
1479
|
-
try {
|
|
1480
|
-
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
|
|
1481
|
-
cwd: root,
|
|
1482
|
-
rsbuildConfig: ()=>init_loadConfig(root),
|
|
1483
|
-
environment: commonOpts.environment,
|
|
1484
|
-
loadEnv: {
|
|
1485
|
-
cwd: getEnvDir(root, commonOpts.envDir),
|
|
1486
|
-
mode: commonOpts.envMode
|
|
1487
|
-
}
|
|
1488
|
-
});
|
|
1489
|
-
return rsbuild.onBeforeCreateCompiler(()=>{
|
|
1490
|
-
let command = process.argv[2];
|
|
1491
|
-
if ('dev' === command || isBuildWatch) {
|
|
1492
|
-
var _config_dev;
|
|
1493
|
-
let files = [], config = rsbuild.getNormalizedConfig();
|
|
1494
|
-
if (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
1495
|
-
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
1496
|
-
let paths = castArray(watchFilesConfig.paths);
|
|
1497
|
-
watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
|
|
1498
|
-
}
|
|
1499
|
-
watchFilesForRestart(files, root, isBuildWatch);
|
|
1500
|
-
}
|
|
1501
|
-
}), rsbuild;
|
|
1502
|
-
} catch (err) {
|
|
1503
|
-
if (isRestart) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
1504
|
-
else throw err;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
let cleaners = [], onBeforeRestartServer = (cleaner)=>{
|
|
1508
|
-
cleaners.push(cleaner);
|
|
1509
|
-
}, clearConsole = ()=>{
|
|
1510
|
-
isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
|
|
1511
|
-
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
1512
|
-
if (clear && clearConsole(), filePath) {
|
|
1513
|
-
let filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(filePath);
|
|
1514
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restarting ${id} because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(filename)} has changed\n`);
|
|
1515
|
-
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restarting ${id}...\n`);
|
|
1516
|
-
for (let cleaner of cleaners)await cleaner();
|
|
1517
|
-
cleaners = [];
|
|
1518
|
-
}, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
|
|
1519
|
-
await beforeRestart({
|
|
1520
|
-
filePath,
|
|
1521
|
-
clear,
|
|
1522
|
-
id: 'server'
|
|
1523
|
-
});
|
|
1524
|
-
let rsbuild = await init({
|
|
1525
|
-
isRestart: !0
|
|
1526
|
-
});
|
|
1527
|
-
rsbuild && await rsbuild.startDevServer();
|
|
1528
|
-
}, restartBuild = async ({ filePath, clear = !0 } = {})=>{
|
|
1529
|
-
await beforeRestart({
|
|
1530
|
-
filePath,
|
|
1531
|
-
clear,
|
|
1532
|
-
id: 'build'
|
|
1533
|
-
});
|
|
1534
|
-
let rsbuild = await init({
|
|
1535
|
-
isRestart: !0,
|
|
1536
|
-
isBuildWatch: !0
|
|
1537
|
-
});
|
|
1538
|
-
rsbuild && onBeforeRestartServer((await rsbuild.build({
|
|
1539
|
-
watch: !0
|
|
1540
|
-
})).close);
|
|
1541
|
-
};
|
|
1542
|
-
async function setupWatchFiles(options) {
|
|
1543
|
-
let { dev, server, root, compileMiddlewareAPI } = options, { hmr, liveReload } = dev;
|
|
1544
|
-
if (!hmr && !liveReload || !compileMiddlewareAPI) return;
|
|
1545
|
-
let closeDevFilesWatcher = await watchDevFiles(dev, compileMiddlewareAPI, root), serverFilesWatcher = await function(serverConfig, compileMiddlewareAPI, root) {
|
|
1546
|
-
let publicDirs = normalizePublicDirs(serverConfig.publicDir);
|
|
1547
|
-
if (!publicDirs.length) return;
|
|
1548
|
-
let watchPaths = publicDirs.filter((item)=>item.watch).map((item)=>item.name);
|
|
1549
|
-
if (watchPaths.length) return startWatchFiles(prepareWatchOptions(watchPaths), compileMiddlewareAPI, root);
|
|
1550
|
-
}(server, compileMiddlewareAPI, root);
|
|
1551
|
-
return {
|
|
1552
|
-
async close () {
|
|
1553
|
-
await Promise.all([
|
|
1554
|
-
null == closeDevFilesWatcher ? void 0 : closeDevFilesWatcher(),
|
|
1555
|
-
null == serverFilesWatcher ? void 0 : serverFilesWatcher.close()
|
|
1556
|
-
]);
|
|
1557
|
-
}
|
|
1558
|
-
};
|
|
1559
|
-
}
|
|
1560
|
-
async function watchDevFiles(devConfig, compileMiddlewareAPI, root) {
|
|
1561
|
-
let { watchFiles } = devConfig;
|
|
1562
|
-
if (!watchFiles) return;
|
|
1563
|
-
let watchers = [];
|
|
1564
|
-
for (let { paths, options, type } of castArray(watchFiles)){
|
|
1565
|
-
let watchOptions = prepareWatchOptions(paths, options, type), watcher = await startWatchFiles(watchOptions, compileMiddlewareAPI, root);
|
|
1566
|
-
watcher && watchers.push(watcher);
|
|
1567
|
-
}
|
|
1568
|
-
return async ()=>{
|
|
1569
|
-
for (let watcher of watchers)await watcher.close();
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
|
-
function prepareWatchOptions(paths, options = {}, type) {
|
|
1573
|
-
return {
|
|
1574
|
-
paths: 'string' == typeof paths ? [
|
|
1575
|
-
paths
|
|
1576
|
-
] : paths,
|
|
1577
|
-
options,
|
|
1578
|
-
type
|
|
1579
|
-
};
|
|
1580
|
-
}
|
|
1581
|
-
let GLOB_REGEX = /[*?{}[\]()!@+|]/, isGlob = (str)=>GLOB_REGEX.test(str);
|
|
1582
|
-
async function createChokidar(pathOrGlobs, root, options) {
|
|
1583
|
-
let chokidar = await import("../compiled/chokidar/index.js"), watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!isGlob(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
|
|
1584
|
-
if (globPatterns.length) {
|
|
1585
|
-
let tinyglobby = await import("../compiled/tinyglobby/index.js"), { glob } = tinyglobby.default || tinyglobby;
|
|
1586
|
-
for (let file of (await glob(globPatterns, {
|
|
1587
|
-
cwd: root,
|
|
1588
|
-
absolute: !0
|
|
1589
|
-
})))watchFiles.add(file);
|
|
1590
|
-
}
|
|
1591
|
-
return chokidar.watch(Array.from(watchFiles), options);
|
|
1592
|
-
}
|
|
1593
|
-
async function startWatchFiles({ paths, options, type = 'reload-page' }, compileMiddlewareAPI, root) {
|
|
1594
|
-
if ('reload-page' !== type) return;
|
|
1595
|
-
let watcher = await createChokidar(paths, root, options);
|
|
1596
|
-
return watcher.on('change', ()=>{
|
|
1597
|
-
compileMiddlewareAPI.sockWrite('static-changed');
|
|
1598
|
-
}), watcher;
|
|
1599
|
-
}
|
|
1600
|
-
let config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), getDefaultDevConfig = ()=>({
|
|
1465
|
+
}, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), getDefaultDevConfig = ()=>({
|
|
1601
1466
|
hmr: !0,
|
|
1602
1467
|
liveReload: !0,
|
|
1603
1468
|
assetPrefix: DEFAULT_ASSET_PREFIX,
|
|
@@ -1766,27 +1631,6 @@ let resolveConfigPath = (root, customConfig)=>{
|
|
|
1766
1631
|
}
|
|
1767
1632
|
return null;
|
|
1768
1633
|
};
|
|
1769
|
-
async function watchFilesForRestart(files, root, isBuildWatch, watchOptions) {
|
|
1770
|
-
var func;
|
|
1771
|
-
let timeoutId;
|
|
1772
|
-
if (!files.length) return;
|
|
1773
|
-
let watcher = await createChokidar(files, root, {
|
|
1774
|
-
ignoreInitial: !0,
|
|
1775
|
-
ignorePermissionErrors: !0,
|
|
1776
|
-
...watchOptions
|
|
1777
|
-
}), callback = (func = async (filePath)=>{
|
|
1778
|
-
await watcher.close(), isBuildWatch ? await restartBuild({
|
|
1779
|
-
filePath
|
|
1780
|
-
}) : await restartDevServer({
|
|
1781
|
-
filePath
|
|
1782
|
-
});
|
|
1783
|
-
}, timeoutId = null, (...args)=>{
|
|
1784
|
-
null !== timeoutId && clearTimeout(timeoutId), timeoutId = setTimeout(()=>{
|
|
1785
|
-
func(...args);
|
|
1786
|
-
}, 300);
|
|
1787
|
-
});
|
|
1788
|
-
watcher.on('add', callback), watcher.on('change', callback), watcher.on('unlink', callback);
|
|
1789
|
-
}
|
|
1790
1634
|
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1791
1635
|
let configExport;
|
|
1792
1636
|
let configFilePath = resolveConfigPath(cwd, path);
|
|
@@ -2280,7 +2124,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2280
2124
|
async function createContext(options, userConfig) {
|
|
2281
2125
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
2282
2126
|
return {
|
|
2283
|
-
version: "1.
|
|
2127
|
+
version: "1.3.0-beta.1",
|
|
2284
2128
|
rootPath,
|
|
2285
2129
|
distPath: '',
|
|
2286
2130
|
cachePath,
|
|
@@ -2446,9 +2290,13 @@ let configChain_CHAIN_ID = {
|
|
|
2446
2290
|
JS_DATA_URI: 'js-data-uri',
|
|
2447
2291
|
TS: 'ts',
|
|
2448
2292
|
CSS: 'css',
|
|
2293
|
+
CSS_RAW: 'css-raw',
|
|
2449
2294
|
LESS: 'less',
|
|
2295
|
+
LESS_RAW: 'less-raw',
|
|
2450
2296
|
SASS: 'sass',
|
|
2297
|
+
SASS_RAW: 'sass-raw',
|
|
2451
2298
|
STYLUS: 'stylus',
|
|
2299
|
+
STYLUS_RAW: 'stylus-raw',
|
|
2452
2300
|
SVG: 'svg',
|
|
2453
2301
|
PUG: 'pug',
|
|
2454
2302
|
VUE: 'vue',
|
|
@@ -2498,8 +2346,7 @@ let configChain_CHAIN_ID = {
|
|
|
2498
2346
|
MINI_CSS_EXTRACT: 'mini-css-extract',
|
|
2499
2347
|
VUE_LOADER_PLUGIN: 'vue-loader-plugin',
|
|
2500
2348
|
REACT_FAST_REFRESH: 'react-fast-refresh',
|
|
2501
|
-
SUBRESOURCE_INTEGRITY: 'subresource-integrity'
|
|
2502
|
-
AUTO_SET_ROOT_SIZE: 'auto-set-root-size'
|
|
2349
|
+
SUBRESOURCE_INTEGRITY: 'subresource-integrity'
|
|
2503
2350
|
},
|
|
2504
2351
|
MINIMIZER: {
|
|
2505
2352
|
JS: 'js',
|
|
@@ -2670,7 +2517,10 @@ let pluginCache = ()=>({
|
|
|
2670
2517
|
cache: {
|
|
2671
2518
|
type: 'persistent',
|
|
2672
2519
|
version: cacheVersion,
|
|
2673
|
-
|
|
2520
|
+
storage: {
|
|
2521
|
+
type: 'filesystem',
|
|
2522
|
+
directory: cacheDirectory
|
|
2523
|
+
},
|
|
2674
2524
|
buildDependencies: Object.values(buildDependencies).flat()
|
|
2675
2525
|
}
|
|
2676
2526
|
})) : chain.cache({
|
|
@@ -2875,7 +2725,9 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2875
2725
|
let rule = chain.module.rule(CHAIN_ID.RULE.CSS), { config } = environment;
|
|
2876
2726
|
rule.test(CSS_REGEX).type("javascript/auto").dependency({
|
|
2877
2727
|
not: 'url'
|
|
2878
|
-
})
|
|
2728
|
+
}).resourceQuery({
|
|
2729
|
+
not: /raw/
|
|
2730
|
+
}), chain.module.rule(CHAIN_ID.RULE.CSS_RAW).test(CSS_REGEX).type('asset/source').resourceQuery(/raw/);
|
|
2879
2731
|
let emitCss = config.output.emitCss ?? 'web' === target;
|
|
2880
2732
|
if (emitCss) {
|
|
2881
2733
|
if (config.output.injectStyles) {
|
|
@@ -2934,20 +2786,32 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2934
2786
|
name: 'rsbuild:define',
|
|
2935
2787
|
setup (api) {
|
|
2936
2788
|
api.modifyBundlerChain((chain, { CHAIN_ID, bundler, environment })=>{
|
|
2937
|
-
let { config } = environment, baseUrl = JSON.stringify(config.server.base), assetPrefix = JSON.stringify(getPublicPathFromChain(chain, !1)),
|
|
2789
|
+
let { config } = environment, baseUrl = JSON.stringify(config.server.base), assetPrefix = JSON.stringify(getPublicPathFromChain(chain, !1)), mergedDefine = {
|
|
2938
2790
|
'import.meta.env.MODE': JSON.stringify(config.mode),
|
|
2939
2791
|
'import.meta.env.DEV': 'development' === config.mode,
|
|
2940
2792
|
'import.meta.env.PROD': 'production' === config.mode,
|
|
2941
2793
|
'import.meta.env.BASE_URL': baseUrl,
|
|
2942
2794
|
'import.meta.env.ASSET_PREFIX': assetPrefix,
|
|
2943
2795
|
'process.env.BASE_URL': baseUrl,
|
|
2944
|
-
'process.env.ASSET_PREFIX': assetPrefix
|
|
2796
|
+
'process.env.ASSET_PREFIX': assetPrefix,
|
|
2797
|
+
...config.source.define
|
|
2945
2798
|
};
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2799
|
+
!function(define) {
|
|
2800
|
+
let value = define['process.env'];
|
|
2801
|
+
if (!value) return;
|
|
2802
|
+
let check = (value)=>{
|
|
2803
|
+
let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
|
|
2804
|
+
pathKey && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`[rsbuild:config] The "source.define" option includes an object with the key ${JSON.stringify(pathKey)} under "process.env", indicating potential exposure of all environment variables. This can lead to security risks and should be avoided.`));
|
|
2805
|
+
};
|
|
2806
|
+
if ('object' == typeof value) {
|
|
2807
|
+
check(value);
|
|
2808
|
+
return;
|
|
2950
2809
|
}
|
|
2810
|
+
if ('string' == typeof value) try {
|
|
2811
|
+
check(JSON.parse(value));
|
|
2812
|
+
} catch (error) {}
|
|
2813
|
+
}(mergedDefine), chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [
|
|
2814
|
+
mergedDefine
|
|
2951
2815
|
]);
|
|
2952
2816
|
});
|
|
2953
2817
|
}
|
|
@@ -3002,7 +2866,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
|
3002
2866
|
groupAssetsByChunk: !1,
|
|
3003
2867
|
groupAssetsByExtension: !1,
|
|
3004
2868
|
groupAssetsByEmitStatus: !1
|
|
3005
|
-
}), exclude = options.exclude ?? excludeAsset, filteredAssets = origin.assets.filter((asset)=>{
|
|
2869
|
+
}), exclude = options.exclude ?? excludeAsset, filteredAssets = (origin.assets || []).filter((asset)=>{
|
|
3006
2870
|
let assetInfo = {
|
|
3007
2871
|
name: asset.name,
|
|
3008
2872
|
size: asset.size
|
|
@@ -3527,7 +3391,7 @@ let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
|
3527
3391
|
for (let file of chunkFiles){
|
|
3528
3392
|
file.isInitial ? file.path.endsWith('.css') ? initialCSS.push(file.path) : initialJS.push(file.path) : file.path.endsWith('.css') ? asyncCSS.push(file.path) : asyncJS.push(file.path);
|
|
3529
3393
|
let relatedLICENSE = licenseMap.get(file.path);
|
|
3530
|
-
|
|
3394
|
+
if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
|
|
3531
3395
|
}
|
|
3532
3396
|
let entryManifest = {};
|
|
3533
3397
|
assets.size && (entryManifest.assets = Array.from(assets));
|
|
@@ -4540,65 +4404,27 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4540
4404
|
chain.optimization.splitChunks(splitChunksOptions);
|
|
4541
4405
|
});
|
|
4542
4406
|
}
|
|
4543
|
-
}),
|
|
4544
|
-
'stylesheet',
|
|
4545
|
-
'preload',
|
|
4546
|
-
'modulepreload'
|
|
4547
|
-
].includes(rel), pluginSri = ()=>({
|
|
4407
|
+
}), pluginSri = ()=>({
|
|
4548
4408
|
name: 'rsbuild:sri',
|
|
4549
4409
|
setup (api) {
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4410
|
+
api.modifyBundlerChain((chain, { environment, CHAIN_ID })=>{
|
|
4411
|
+
if ('webpack' === api.context.bundlerType) return;
|
|
4412
|
+
let { config, htmlPaths } = environment;
|
|
4413
|
+
if (0 === Object.keys(htmlPaths).length) return;
|
|
4414
|
+
let { sri } = config.security;
|
|
4415
|
+
if (!('auto' === sri.enable ? 'production' === config.mode : sri.enable)) return;
|
|
4416
|
+
let crossorigin = chain.output.get('crossOriginLoading');
|
|
4417
|
+
(!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
|
|
4553
4418
|
let { algorithm = 'sha384' } = sri;
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
...tags.headTags,
|
|
4562
|
-
...tags.bodyTags
|
|
4563
|
-
]){
|
|
4564
|
-
let url = '';
|
|
4565
|
-
if (!tag.attrs || ("script" === tag.tag && 'string' == typeof tag.attrs.src ? url = tag.attrs.src : 'link' === tag.tag && isSriLinkRel(tag.attrs.rel) && 'string' == typeof tag.attrs.href && (url = tag.attrs.href), !url)) continue;
|
|
4566
|
-
let assetName = getAssetName(url, assetPrefix);
|
|
4567
|
-
assetName && (tag.attrs.integrity ??= `${placeholder}${assetName}`);
|
|
4568
|
-
}
|
|
4569
|
-
return tags;
|
|
4570
|
-
}
|
|
4571
|
-
});
|
|
4572
|
-
let replaceIntegrity = (htmlContent, assets, algorithm, integrityCache)=>{
|
|
4573
|
-
let matches = htmlContent.matchAll(/integrity="RSBUILD_INTEGRITY_PLACEHOLDER:([^"]+)"/g), replacedHtml = htmlContent, calcIntegrity = (algorithm, assetName, data)=>{
|
|
4574
|
-
if (integrityCache.has(assetName)) return integrityCache.get(assetName);
|
|
4575
|
-
let hash = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash(algorithm).update(data).digest().toString('base64'), integrity = `${algorithm}-${hash}`;
|
|
4576
|
-
return integrityCache.set(assetName, integrity), integrity;
|
|
4577
|
-
};
|
|
4578
|
-
for (let match of matches){
|
|
4579
|
-
let assetName = match[1];
|
|
4580
|
-
if (assetName) {
|
|
4581
|
-
if (assets[assetName]) {
|
|
4582
|
-
let integrity = calcIntegrity(algorithm, assetName, assets[assetName].buffer());
|
|
4583
|
-
replacedHtml = replacedHtml.replaceAll(`integrity="${placeholder}${assetName}"`, `integrity="${integrity}"`);
|
|
4584
|
-
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`[rsbuild:sri] failed to generate integrity for ${assetName}.`), replacedHtml = replacedHtml.replace(`integrity="${placeholder}${assetName}"`, '');
|
|
4419
|
+
chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.experiments.SubresourceIntegrityPlugin, [
|
|
4420
|
+
{
|
|
4421
|
+
enabled: !0,
|
|
4422
|
+
hashFuncNames: [
|
|
4423
|
+
algorithm
|
|
4424
|
+
],
|
|
4425
|
+
htmlPlugin: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(COMPILED_PATH, 'html-rspack-plugin/index.js')
|
|
4585
4426
|
}
|
|
4586
|
-
|
|
4587
|
-
return replacedHtml;
|
|
4588
|
-
};
|
|
4589
|
-
api.processAssets({
|
|
4590
|
-
stage: 'report'
|
|
4591
|
-
}, ({ assets, sources, environment })=>{
|
|
4592
|
-
let { htmlPaths } = environment;
|
|
4593
|
-
if (0 === Object.keys(htmlPaths).length) return;
|
|
4594
|
-
let algorithm = getAlgorithm(environment);
|
|
4595
|
-
if (!algorithm) return;
|
|
4596
|
-
let integrityCache = new Map();
|
|
4597
|
-
for (let asset of Object.keys(assets)){
|
|
4598
|
-
if (!HTML_REGEX.test(asset)) continue;
|
|
4599
|
-
let htmlContent = assets[asset].source();
|
|
4600
|
-
htmlContent.includes(placeholder) && (assets[asset] = new sources.RawSource(replaceIntegrity(htmlContent, assets, algorithm, integrityCache)));
|
|
4601
|
-
}
|
|
4427
|
+
]);
|
|
4602
4428
|
});
|
|
4603
4429
|
}
|
|
4604
4430
|
}), swc_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), builtinSwcLoaderName = 'builtin:swc-loader', pluginSwc = ()=>({
|
|
@@ -5014,6 +4840,167 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
|
5014
4840
|
rspackConfigs
|
|
5015
4841
|
};
|
|
5016
4842
|
}
|
|
4843
|
+
let commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(cwd, envDir) : cwd, init_loadConfig = async (root)=>{
|
|
4844
|
+
var _config_server;
|
|
4845
|
+
let { content: config, filePath } = await config_loadConfig({
|
|
4846
|
+
cwd: root,
|
|
4847
|
+
path: commonOpts.config,
|
|
4848
|
+
envMode: commonOpts.envMode,
|
|
4849
|
+
loader: commonOpts.configLoader
|
|
4850
|
+
});
|
|
4851
|
+
return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), 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.open = commonOpts.open), commonOpts.host && (config.server.host = commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
|
|
4852
|
+
...config.dev.watchFiles ? castArray(config.dev.watchFiles) : [],
|
|
4853
|
+
{
|
|
4854
|
+
paths: filePath,
|
|
4855
|
+
type: 'reload-server'
|
|
4856
|
+
}
|
|
4857
|
+
]), config;
|
|
4858
|
+
};
|
|
4859
|
+
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
4860
|
+
cliOptions && (commonOpts = cliOptions);
|
|
4861
|
+
try {
|
|
4862
|
+
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
|
|
4863
|
+
cwd: root,
|
|
4864
|
+
rsbuildConfig: ()=>init_loadConfig(root),
|
|
4865
|
+
environment: commonOpts.environment,
|
|
4866
|
+
loadEnv: {
|
|
4867
|
+
cwd: getEnvDir(root, commonOpts.envDir),
|
|
4868
|
+
mode: commonOpts.envMode
|
|
4869
|
+
}
|
|
4870
|
+
});
|
|
4871
|
+
return rsbuild.onBeforeCreateCompiler(()=>{
|
|
4872
|
+
var _config_dev;
|
|
4873
|
+
if ('dev' !== rsbuild.context.action && !isBuildWatch) return;
|
|
4874
|
+
let files = [], config = rsbuild.getNormalizedConfig();
|
|
4875
|
+
if (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
4876
|
+
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
4877
|
+
let paths = castArray(watchFilesConfig.paths);
|
|
4878
|
+
watchFilesConfig.options ? watchFilesForRestart({
|
|
4879
|
+
files: paths,
|
|
4880
|
+
rsbuild,
|
|
4881
|
+
isBuildWatch,
|
|
4882
|
+
watchOptions: watchFilesConfig.options
|
|
4883
|
+
}) : files.push(...paths);
|
|
4884
|
+
}
|
|
4885
|
+
watchFilesForRestart({
|
|
4886
|
+
files,
|
|
4887
|
+
rsbuild,
|
|
4888
|
+
isBuildWatch
|
|
4889
|
+
});
|
|
4890
|
+
}), rsbuild;
|
|
4891
|
+
} catch (err) {
|
|
4892
|
+
if (isRestart) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
4893
|
+
else throw err;
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
async function setupWatchFiles(options) {
|
|
4897
|
+
let { dev, server, root, compileMiddlewareAPI } = options, { hmr, liveReload } = dev;
|
|
4898
|
+
if (!hmr && !liveReload || !compileMiddlewareAPI) return;
|
|
4899
|
+
let closeDevFilesWatcher = await watchDevFiles(dev, compileMiddlewareAPI, root), serverFilesWatcher = await function(serverConfig, compileMiddlewareAPI, root) {
|
|
4900
|
+
let publicDirs = normalizePublicDirs(serverConfig.publicDir);
|
|
4901
|
+
if (!publicDirs.length) return;
|
|
4902
|
+
let watchPaths = publicDirs.filter((item)=>item.watch).map((item)=>item.name);
|
|
4903
|
+
if (watchPaths.length) return startWatchFiles(prepareWatchOptions(watchPaths), compileMiddlewareAPI, root);
|
|
4904
|
+
}(server, compileMiddlewareAPI, root);
|
|
4905
|
+
return {
|
|
4906
|
+
async close () {
|
|
4907
|
+
await Promise.all([
|
|
4908
|
+
null == closeDevFilesWatcher ? void 0 : closeDevFilesWatcher(),
|
|
4909
|
+
null == serverFilesWatcher ? void 0 : serverFilesWatcher.close()
|
|
4910
|
+
]);
|
|
4911
|
+
}
|
|
4912
|
+
};
|
|
4913
|
+
}
|
|
4914
|
+
async function watchDevFiles(devConfig, compileMiddlewareAPI, root) {
|
|
4915
|
+
let { watchFiles } = devConfig;
|
|
4916
|
+
if (!watchFiles) return;
|
|
4917
|
+
let watchers = [];
|
|
4918
|
+
for (let { paths, options, type } of castArray(watchFiles)){
|
|
4919
|
+
let watchOptions = prepareWatchOptions(paths, options, type), watcher = await startWatchFiles(watchOptions, compileMiddlewareAPI, root);
|
|
4920
|
+
watcher && watchers.push(watcher);
|
|
4921
|
+
}
|
|
4922
|
+
return async ()=>{
|
|
4923
|
+
for (let watcher of watchers)await watcher.close();
|
|
4924
|
+
};
|
|
4925
|
+
}
|
|
4926
|
+
function prepareWatchOptions(paths, options = {}, type) {
|
|
4927
|
+
return {
|
|
4928
|
+
paths: 'string' == typeof paths ? [
|
|
4929
|
+
paths
|
|
4930
|
+
] : paths,
|
|
4931
|
+
options,
|
|
4932
|
+
type
|
|
4933
|
+
};
|
|
4934
|
+
}
|
|
4935
|
+
let GLOB_REGEX = /[*?{}[\]()!@+|]/, isGlob = (str)=>GLOB_REGEX.test(str);
|
|
4936
|
+
async function createChokidar(pathOrGlobs, root, options) {
|
|
4937
|
+
let chokidar = await import("../compiled/chokidar/index.js"), watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!isGlob(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
|
|
4938
|
+
if (globPatterns.length) {
|
|
4939
|
+
let tinyglobby = await import("../compiled/tinyglobby/index.js"), { glob } = tinyglobby.default || tinyglobby;
|
|
4940
|
+
for (let file of (await glob(globPatterns, {
|
|
4941
|
+
cwd: root,
|
|
4942
|
+
absolute: !0
|
|
4943
|
+
})))watchFiles.add(file);
|
|
4944
|
+
}
|
|
4945
|
+
return chokidar.watch(Array.from(watchFiles), options);
|
|
4946
|
+
}
|
|
4947
|
+
async function startWatchFiles({ paths, options, type = 'reload-page' }, compileMiddlewareAPI, root) {
|
|
4948
|
+
if ('reload-page' !== type) return;
|
|
4949
|
+
let watcher = await createChokidar(paths, root, options);
|
|
4950
|
+
return watcher.on('change', ()=>{
|
|
4951
|
+
compileMiddlewareAPI.sockWrite('static-changed');
|
|
4952
|
+
}), watcher;
|
|
4953
|
+
}
|
|
4954
|
+
let cleaners = [], onBeforeRestartServer = (cleaner)=>{
|
|
4955
|
+
cleaners.push(cleaner);
|
|
4956
|
+
}, clearConsole = ()=>{
|
|
4957
|
+
isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
|
|
4958
|
+
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
4959
|
+
if (clear && clearConsole(), filePath) {
|
|
4960
|
+
let filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(filePath);
|
|
4961
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restarting ${id} as ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(filename)} changed\n`);
|
|
4962
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restarting ${id}...\n`);
|
|
4963
|
+
for (let cleaner of cleaners)await cleaner();
|
|
4964
|
+
cleaners = [];
|
|
4965
|
+
}, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
|
|
4966
|
+
await beforeRestart({
|
|
4967
|
+
filePath,
|
|
4968
|
+
clear,
|
|
4969
|
+
id: 'server'
|
|
4970
|
+
});
|
|
4971
|
+
let rsbuild = await init({
|
|
4972
|
+
isRestart: !0
|
|
4973
|
+
});
|
|
4974
|
+
return !!rsbuild && (await rsbuild.startDevServer(), !0);
|
|
4975
|
+
}, restartBuild = async ({ filePath, clear = !0 } = {})=>{
|
|
4976
|
+
await beforeRestart({
|
|
4977
|
+
filePath,
|
|
4978
|
+
clear,
|
|
4979
|
+
id: 'build'
|
|
4980
|
+
});
|
|
4981
|
+
let rsbuild = await init({
|
|
4982
|
+
isRestart: !0,
|
|
4983
|
+
isBuildWatch: !0
|
|
4984
|
+
});
|
|
4985
|
+
return !!rsbuild && (onBeforeRestartServer((await rsbuild.build({
|
|
4986
|
+
watch: !0
|
|
4987
|
+
})).close), !0);
|
|
4988
|
+
};
|
|
4989
|
+
async function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions }) {
|
|
4990
|
+
if (!files.length) return;
|
|
4991
|
+
let root = rsbuild.context.rootPath, watcher = await createChokidar(files, root, {
|
|
4992
|
+
ignoreInitial: !0,
|
|
4993
|
+
ignorePermissionErrors: !0,
|
|
4994
|
+
...watchOptions
|
|
4995
|
+
}), restarting = !1, onChange = async (filePath)=>{
|
|
4996
|
+
!restarting && (restarting = !0, (isBuildWatch ? await restartBuild({
|
|
4997
|
+
filePath
|
|
4998
|
+
}) : await restartDevServer({
|
|
4999
|
+
filePath
|
|
5000
|
+
})) ? await watcher.close() : __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(isBuildWatch ? 'Restart build failed.' : 'Restart server failed.'), restarting = !1);
|
|
5001
|
+
};
|
|
5002
|
+
watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
|
|
5003
|
+
}
|
|
5017
5004
|
let isCliShortcutsEnabled = (devConfig)=>devConfig.cliShortcuts && isTTY('stdin');
|
|
5018
5005
|
function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
|
|
5019
5006
|
let shortcuts = [
|
|
@@ -6090,9 +6077,13 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
|
|
|
6090
6077
|
cleanupCallbacks.add(callback);
|
|
6091
6078
|
}, removeCleanup = (callback)=>{
|
|
6092
6079
|
cleanupCallbacks.delete(callback);
|
|
6093
|
-
}, shutdownRefCount = 0, setupGracefulShutdown = ()=>
|
|
6094
|
-
|
|
6095
|
-
|
|
6080
|
+
}, shutdownRefCount = 0, setupGracefulShutdown = ()=>{
|
|
6081
|
+
shutdownRefCount++, process.once('SIGTERM', handleTermination);
|
|
6082
|
+
let isCI = 'true' === process.env.CI;
|
|
6083
|
+
return isCI || process.stdin.on('end', handleTermination), ()=>{
|
|
6084
|
+
!(--shutdownRefCount > 0) && (process.removeListener('SIGTERM', handleTermination), isCI || process.stdin.removeListener('end', handleTermination));
|
|
6085
|
+
};
|
|
6086
|
+
}, createHttpServer = async ({ serverConfig, middlewares })=>{
|
|
6096
6087
|
if (serverConfig.https) {
|
|
6097
6088
|
if (serverConfig.proxy) {
|
|
6098
6089
|
let { createServer } = await import("node:https");
|
|
@@ -6308,7 +6299,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
6308
6299
|
}
|
|
6309
6300
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.start('build started...');
|
|
6310
6301
|
}(compiler, context), isCompiling = !0;
|
|
6311
|
-
}), 'build' === context.
|
|
6302
|
+
}), 'build' === context.action && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
|
|
6312
6303
|
let done = (stats)=>{
|
|
6313
6304
|
let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
|
|
6314
6305
|
children: !0,
|
|
@@ -6333,7 +6324,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
6333
6324
|
};
|
|
6334
6325
|
return compiler.hooks.done.tap('rsbuild:done', (stats)=>{
|
|
6335
6326
|
done(stats);
|
|
6336
|
-
}), 'dev' === context.
|
|
6327
|
+
}), 'dev' === context.action && registerDevHook({
|
|
6337
6328
|
context,
|
|
6338
6329
|
compiler,
|
|
6339
6330
|
bundlerConfigs: rspackConfigs,
|
|
@@ -6749,6 +6740,7 @@ async function createRsbuild(options = {}) {
|
|
|
6749
6740
|
}), context = await createContext(resolvedOptions, config), getPluginAPI = function({ context, pluginManager }) {
|
|
6750
6741
|
let { hooks } = context, publicContext = function(context) {
|
|
6751
6742
|
let exposedKeys = [
|
|
6743
|
+
'action',
|
|
6752
6744
|
'version',
|
|
6753
6745
|
'rootPath',
|
|
6754
6746
|
'distPath',
|
|
@@ -6934,7 +6926,7 @@ async function createRsbuild(options = {}) {
|
|
|
6934
6926
|
helpers: provider_helpers_namespaceObject
|
|
6935
6927
|
}), rsbuild = {
|
|
6936
6928
|
build: async (...args)=>{
|
|
6937
|
-
context.
|
|
6929
|
+
context.action = 'build', getNodeEnv() || setNodeEnv('production');
|
|
6938
6930
|
let buildInstance = await providerInstance.build(...args);
|
|
6939
6931
|
return {
|
|
6940
6932
|
...buildInstance,
|
|
@@ -6944,7 +6936,7 @@ async function createRsbuild(options = {}) {
|
|
|
6944
6936
|
};
|
|
6945
6937
|
},
|
|
6946
6938
|
preview: async (options = {})=>{
|
|
6947
|
-
context.
|
|
6939
|
+
context.action = 'preview', getNodeEnv() || setNodeEnv('production');
|
|
6948
6940
|
let config = await initRsbuildConfig({
|
|
6949
6941
|
context,
|
|
6950
6942
|
pluginManager
|
|
@@ -6958,9 +6950,9 @@ async function createRsbuild(options = {}) {
|
|
|
6958
6950
|
}
|
|
6959
6951
|
return startProdServer(context, config, options);
|
|
6960
6952
|
},
|
|
6961
|
-
startDevServer: (...args)=>(context.
|
|
6962
|
-
createCompiler: (...args)=>(context.
|
|
6963
|
-
createDevServer: (...args)=>(context.
|
|
6953
|
+
startDevServer: (...args)=>(context.action = 'dev', getNodeEnv() || setNodeEnv('development'), providerInstance.startDevServer(...args)),
|
|
6954
|
+
createCompiler: (...args)=>(context.action || (context.action = 'development' === getNodeEnv() ? 'dev' : 'build'), providerInstance.createCompiler(...args)),
|
|
6955
|
+
createDevServer: (...args)=>(context.action = 'dev', getNodeEnv() || setNodeEnv('development'), providerInstance.createDevServer(...args)),
|
|
6964
6956
|
...pick(pluginManager, [
|
|
6965
6957
|
'addPlugins',
|
|
6966
6958
|
'getPlugins',
|
|
@@ -7325,22 +7317,20 @@ let cac_dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
|
7325
7317
|
};
|
|
7326
7318
|
async function runCLI() {
|
|
7327
7319
|
!function() {
|
|
7328
|
-
!
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.2.19\n`);
|
|
7339
|
-
}();
|
|
7320
|
+
if (!process.env.NODE_ENV) {
|
|
7321
|
+
let command = process.argv[2];
|
|
7322
|
+
process.env.NODE_ENV = [
|
|
7323
|
+
'build',
|
|
7324
|
+
'preview'
|
|
7325
|
+
].includes(command) ? 'production' : 'development';
|
|
7326
|
+
}
|
|
7327
|
+
}(), process.title = 'rsbuild-node';
|
|
7328
|
+
let { npm_execpath } = process.env;
|
|
7329
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.0-beta.1\n`);
|
|
7340
7330
|
try {
|
|
7341
7331
|
!function() {
|
|
7342
7332
|
let cli = cac_dist('rsbuild');
|
|
7343
|
-
cli.help(), cli.version("1.
|
|
7333
|
+
cli.help(), cli.version("1.3.0-beta.1"), applyCommonOptions(cli);
|
|
7344
7334
|
let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
7345
7335
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7346
7336
|
try {
|
|
@@ -7391,6 +7381,6 @@ async function runCLI() {
|
|
|
7391
7381
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
7392
7382
|
}
|
|
7393
7383
|
}
|
|
7394
|
-
let src_version = "1.
|
|
7384
|
+
let src_version = "1.3.0-beta.1";
|
|
7395
7385
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
7396
7386
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|