@rsbuild/core 1.1.12 → 1.1.13
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/chokidar/index.d.ts +24 -6
- package/compiled/chokidar/index.js +16 -13
- package/compiled/chokidar/package.json +1 -1
- package/compiled/jiti/index.js +56 -31
- package/compiled/jiti/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/rspack-manifest-plugin/index.d.ts +1 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/rspack-manifest-plugin/package.json +1 -1
- package/dist/client/hmr.js +8 -69
- package/dist/client/overlay.js +7 -12
- package/dist/index.cjs +161 -70
- package/dist/index.js +158 -67
- package/dist-types/helpers/index.d.ts +2 -0
- package/dist-types/server/ansiHTML.d.ts +12 -0
- package/dist-types/server/helper.d.ts +6 -0
- package/package.json +5 -5
- /package/dist-types/{client → helpers}/format.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -10,8 +10,8 @@ import * as __WEBPACK_EXTERNAL_MODULE_os__ from "os";
|
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE__rspack_core__ from "@rspack/core";
|
|
12
12
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
|
|
13
|
-
import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__ from "../compiled/picocolors/index.js";
|
|
14
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_url__ from "node:url";
|
|
14
|
+
import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__ from "../compiled/picocolors/index.js";
|
|
15
15
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__ from "../compiled/rslog/index.js";
|
|
16
16
|
import * as __WEBPACK_EXTERNAL_MODULE_node_util_types__ from "node:util/types";
|
|
17
17
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js__ from "../compiled/rspack-chain/index.js";
|
|
@@ -1512,47 +1512,11 @@ let getCompiledPath = (packageName)=>(0, external_node_path_.join)(COMPILED_PATH
|
|
|
1512
1512
|
} catch (err) {
|
|
1513
1513
|
return publicPath;
|
|
1514
1514
|
}
|
|
1515
|
-
}
|
|
1516
|
-
function formatMessage(stats, verbose) {
|
|
1517
|
-
let message, lines = [];
|
|
1518
|
-
if ('object' == typeof stats) {
|
|
1519
|
-
let fileName = function(stats) {
|
|
1520
|
-
if (stats.moduleIdentifier) {
|
|
1521
|
-
let matched = stats.moduleIdentifier.match(/(?:\!|^)([^!]+)$/);
|
|
1522
|
-
if (matched) {
|
|
1523
|
-
let fileName = matched.pop();
|
|
1524
|
-
if (fileName) return `File: ${fileName}:1:1\n`;
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
let file = stats.file || stats.moduleName;
|
|
1528
|
-
return file ? `File: ${file}\n` : '';
|
|
1529
|
-
}(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
|
|
1530
|
-
let traceStr = '';
|
|
1531
|
-
if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
|
|
1532
|
-
return traceStr;
|
|
1533
|
-
}(stats);
|
|
1534
|
-
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
1535
|
-
} else message = stats;
|
|
1536
|
-
message = (lines = (lines = (message = function(message) {
|
|
1537
|
-
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
1538
|
-
return -1 === message.indexOf(hint) ? message : /File: .+\.s(c|a)ss/.test(message) ? message.replace(hint, 'To enable support for Sass, use "@rsbuild/plugin-sass".') : /File: .+\.less/.test(message) ? message.replace(hint, 'To enable support for Less, use "@rsbuild/plugin-less".') : /File: .+\.styl(us)?/.test(message) ? message.replace(hint, 'To enable support for Stylus, use "@rsbuild/plugin-stylus".') : message;
|
|
1539
|
-
}(message)).split('\n')).filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n');
|
|
1540
|
-
let innerError = '-- inner error --';
|
|
1541
|
-
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), message.trim();
|
|
1542
|
-
}
|
|
1543
|
-
function formatStatsMessages(stats, verbose) {
|
|
1544
|
-
var _stats_errors, _stats_warnings;
|
|
1545
|
-
let formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
1546
|
-
return {
|
|
1547
|
-
errors: formattedErrors,
|
|
1548
|
-
warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
|
|
1549
|
-
};
|
|
1550
|
-
}
|
|
1551
|
-
let hintNodePolyfill = (message)=>{
|
|
1515
|
+
}, hintNodePolyfill = (message)=>{
|
|
1552
1516
|
let getTips = (moduleName)=>{
|
|
1553
1517
|
let tips = [
|
|
1554
1518
|
`Tip: "${moduleName}" is a built-in Node.js module. It cannot be imported in client-side code.`,
|
|
1555
|
-
`Check if you need to import Node.js module. If needed, you can use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan('@rsbuild/plugin-node-polyfill')}.`
|
|
1519
|
+
`Check if you need to import Node.js module. If needed, you can use "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan('@rsbuild/plugin-node-polyfill')}" to polyfill it.`
|
|
1556
1520
|
];
|
|
1557
1521
|
return `${message}\n\n${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(tips.join('\n'))}`;
|
|
1558
1522
|
};
|
|
@@ -1601,7 +1565,42 @@ let hintNodePolyfill = (message)=>{
|
|
|
1601
1565
|
'vm',
|
|
1602
1566
|
'zlib'
|
|
1603
1567
|
].includes(moduleName) ? getTips(moduleName) : message;
|
|
1604
|
-
}
|
|
1568
|
+
};
|
|
1569
|
+
function formatMessage(stats, verbose) {
|
|
1570
|
+
let message, lines = [];
|
|
1571
|
+
if ('object' == typeof stats) {
|
|
1572
|
+
let fileName = function(stats) {
|
|
1573
|
+
if (stats.moduleIdentifier) {
|
|
1574
|
+
let matched = stats.moduleIdentifier.match(/(?:\!|^)([^!]+)$/);
|
|
1575
|
+
if (matched) {
|
|
1576
|
+
let fileName = matched.pop();
|
|
1577
|
+
if (fileName) return `File: ${fileName}:1:1\n`;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
let file = stats.file || stats.moduleName;
|
|
1581
|
+
return file ? `File: ${file}\n` : '';
|
|
1582
|
+
}(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
|
|
1583
|
+
let traceStr = '';
|
|
1584
|
+
if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
|
|
1585
|
+
return traceStr;
|
|
1586
|
+
}(stats);
|
|
1587
|
+
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
1588
|
+
} else message = stats;
|
|
1589
|
+
let innerError = '-- inner error --';
|
|
1590
|
+
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), (message = (lines = (lines = (message = hintNodePolyfill(message = function(message) {
|
|
1591
|
+
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
1592
|
+
return -1 === message.indexOf(hint) ? message : /File: .+\.s(c|a)ss/.test(message) ? message.replace(hint, `To enable support for Sass, use "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow('@rsbuild/plugin-sass')}".`) : /File: .+\.less/.test(message) ? message.replace(hint, `To enable support for Less, use "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow('@rsbuild/plugin-less')}".`) : /File: .+\.styl(us)?/.test(message) ? message.replace(hint, `To enable support for Stylus, use "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow('@rsbuild/plugin-stylus')}".`) : message;
|
|
1593
|
+
}(message))).split('\n')).filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n')).trim();
|
|
1594
|
+
}
|
|
1595
|
+
function formatStatsMessages(stats, verbose) {
|
|
1596
|
+
var _stats_errors, _stats_warnings;
|
|
1597
|
+
let formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
1598
|
+
return {
|
|
1599
|
+
errors: formattedErrors,
|
|
1600
|
+
warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
let getAllStatsErrors = (statsData)=>{
|
|
1605
1604
|
var _statsData_errors, _statsData_children;
|
|
1606
1605
|
return statsData.errorsCount && (null === (_statsData_errors = statsData.errors) || void 0 === _statsData_errors ? void 0 : _statsData_errors.length) === 0 ? null === (_statsData_children = statsData.children) || void 0 === _statsData_children ? void 0 : _statsData_children.reduce((errors, curr)=>errors.concat(curr.errors || []), []) : statsData.errors;
|
|
1607
1606
|
}, getAllStatsWarnings = (statsData)=>{
|
|
@@ -1626,9 +1625,9 @@ function formatStats(statsData, hasErrors) {
|
|
|
1626
1625
|
}, verbose);
|
|
1627
1626
|
return {
|
|
1628
1627
|
message: function(errors) {
|
|
1629
|
-
let
|
|
1628
|
+
let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.red('Compile error: '));
|
|
1630
1629
|
if (!errors.length) return `${title}\n${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow("For more details, please setting 'stats.errors: true' ")}`;
|
|
1631
|
-
let tip = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow('Failed to compile, check the errors for troubleshooting.')
|
|
1630
|
+
let tip = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow('Failed to compile, check the errors for troubleshooting.'), text = `${errors.join('\n\n')}\n`;
|
|
1632
1631
|
return `${title}\n${tip}\n${text}`;
|
|
1633
1632
|
}(errors),
|
|
1634
1633
|
level: 'error'
|
|
@@ -1676,10 +1675,16 @@ let rspackMinVersion = '1.0.0', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEn
|
|
|
1676
1675
|
return `${urlProtocol}://${external_node_path_.posix.join(baseUrl, path)}`;
|
|
1677
1676
|
}, canParse = (url)=>{
|
|
1678
1677
|
try {
|
|
1679
|
-
return new URL(url), !0;
|
|
1678
|
+
return new __WEBPACK_EXTERNAL_MODULE_node_url__.URL(url), !0;
|
|
1680
1679
|
} catch {
|
|
1681
1680
|
return !1;
|
|
1682
1681
|
}
|
|
1682
|
+
}, parseUrl = (url)=>{
|
|
1683
|
+
try {
|
|
1684
|
+
return new __WEBPACK_EXTERNAL_MODULE_node_url__.URL(url);
|
|
1685
|
+
} catch {
|
|
1686
|
+
return null;
|
|
1687
|
+
}
|
|
1683
1688
|
}, ensureAssetPrefix = (url, assetPrefix = DEFAULT_ASSET_PREFIX)=>url.startsWith('//') || canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : external_node_path_.posix.join(assetPrefix, url);
|
|
1684
1689
|
function getFilename(config, type, isProd, isServer) {
|
|
1685
1690
|
let { filename, filenameHash } = config.output, hash = 'string' == typeof filenameHash ? filenameHash ? `.[${filenameHash}]` : '' : filenameHash ? '.[contenthash:8]' : '';
|
|
@@ -2647,7 +2652,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2647
2652
|
async function createContext(options, userConfig, bundlerType) {
|
|
2648
2653
|
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');
|
|
2649
2654
|
return {
|
|
2650
|
-
version: "1.1.
|
|
2655
|
+
version: "1.1.13",
|
|
2651
2656
|
rootPath,
|
|
2652
2657
|
distPath: '',
|
|
2653
2658
|
cachePath,
|
|
@@ -5248,8 +5253,8 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
|
5248
5253
|
environment
|
|
5249
5254
|
})));
|
|
5250
5255
|
if (isDebug()) {
|
|
5251
|
-
let inspect = ()=>{
|
|
5252
|
-
inspectConfig({
|
|
5256
|
+
let inspect = async ()=>{
|
|
5257
|
+
await inspectConfig({
|
|
5253
5258
|
context,
|
|
5254
5259
|
pluginManager,
|
|
5255
5260
|
inspectOptions: {
|
|
@@ -5260,8 +5265,8 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
|
5260
5265
|
bundlerConfigs: rspackConfigs
|
|
5261
5266
|
});
|
|
5262
5267
|
};
|
|
5263
|
-
context.hooks.onBeforeBuild.tap(({ isFirstCompile })=>{
|
|
5264
|
-
isFirstCompile && inspect();
|
|
5268
|
+
context.hooks.onBeforeBuild.tap(async ({ isFirstCompile })=>{
|
|
5269
|
+
isFirstCompile && await inspect();
|
|
5265
5270
|
}), context.hooks.onAfterStartDevServer.tap(inspect);
|
|
5266
5271
|
}
|
|
5267
5272
|
return {
|
|
@@ -5359,6 +5364,61 @@ let isClientCompiler = (compiler)=>{
|
|
|
5359
5364
|
}), setupServerHooks(compiler, callbacks);
|
|
5360
5365
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
5361
5366
|
};
|
|
5367
|
+
}, colors = {
|
|
5368
|
+
black: '#000',
|
|
5369
|
+
red: '#fb6a6a',
|
|
5370
|
+
green: '#6ef790',
|
|
5371
|
+
yellow: '#eff986',
|
|
5372
|
+
cyan: '#6eecf7',
|
|
5373
|
+
blue: '#6eb2f7',
|
|
5374
|
+
magenta: '#f76ebe',
|
|
5375
|
+
lightgrey: '#f0f0f0',
|
|
5376
|
+
darkgrey: '#888'
|
|
5377
|
+
}, styles = {
|
|
5378
|
+
30: 'black',
|
|
5379
|
+
31: 'red',
|
|
5380
|
+
32: 'green',
|
|
5381
|
+
33: 'yellow',
|
|
5382
|
+
34: 'blue',
|
|
5383
|
+
35: 'magenta',
|
|
5384
|
+
36: 'cyan',
|
|
5385
|
+
37: 'lightgrey'
|
|
5386
|
+
}, openTags = {
|
|
5387
|
+
1: 'font-weight:bold',
|
|
5388
|
+
2: 'opacity:0.5',
|
|
5389
|
+
3: '<i>',
|
|
5390
|
+
4: '<u>',
|
|
5391
|
+
8: 'display:none',
|
|
5392
|
+
9: '<del>'
|
|
5393
|
+
}, closeTags = {
|
|
5394
|
+
23: '</i>',
|
|
5395
|
+
24: '</u>',
|
|
5396
|
+
29: '</del>'
|
|
5397
|
+
};
|
|
5398
|
+
for (let n of [
|
|
5399
|
+
0,
|
|
5400
|
+
21,
|
|
5401
|
+
22,
|
|
5402
|
+
27,
|
|
5403
|
+
28,
|
|
5404
|
+
39,
|
|
5405
|
+
49
|
|
5406
|
+
])closeTags[n.toString()] = '</span>';
|
|
5407
|
+
!function() {
|
|
5408
|
+
for(let code in openTags['90'] = `color:${colors.darkgrey}`, styles){
|
|
5409
|
+
let oriColor = colors[styles[code]] || colors.black;
|
|
5410
|
+
openTags[code] = `color:${oriColor}`;
|
|
5411
|
+
}
|
|
5412
|
+
}();
|
|
5413
|
+
let server_ansiHTML = function(text) {
|
|
5414
|
+
if (!RegExp(`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`, 'g').test(text)) return text;
|
|
5415
|
+
let ansiCodes = [], ret = text.replace(/\x1B\[(\d+)m/g, (_match, seq)=>{
|
|
5416
|
+
let ot = openTags[seq];
|
|
5417
|
+
if (ot) return -1 !== ansiCodes.indexOf(seq) ? (ansiCodes.pop(), '</span>') : (ansiCodes.push(seq), '<' === ot[0] ? ot : `<span style="${ot}">`);
|
|
5418
|
+
let ct = closeTags[seq];
|
|
5419
|
+
return ct ? (ansiCodes.pop(), ct) : '';
|
|
5420
|
+
}), l = ansiCodes.length;
|
|
5421
|
+
return l > 0 && (ret += Array(l + 1).join('</span>')), ret;
|
|
5362
5422
|
};
|
|
5363
5423
|
function socketServer_define_property(obj, key, value) {
|
|
5364
5424
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
@@ -5461,25 +5521,49 @@ class SocketServer {
|
|
|
5461
5521
|
for (let v of a.values())if (!b.has(v)) return !1;
|
|
5462
5522
|
return !0;
|
|
5463
5523
|
}(initialChunks, newInitialChunks);
|
|
5464
|
-
|
|
5524
|
+
if (this.initialChunks[compilationId] = newInitialChunks, shouldReload) return this.sockWrite({
|
|
5465
5525
|
type: 'content-changed',
|
|
5466
5526
|
compilationId
|
|
5467
|
-
})
|
|
5527
|
+
});
|
|
5528
|
+
if (!force && stats && !stats.errorsCount && stats.assets && stats.assets.every((asset)=>!asset.emitted)) return this.sockWrite({
|
|
5468
5529
|
type: 'still-ok',
|
|
5469
5530
|
compilationId
|
|
5470
|
-
})
|
|
5531
|
+
});
|
|
5532
|
+
if (this.sockWrite({
|
|
5471
5533
|
type: 'hash',
|
|
5472
5534
|
compilationId,
|
|
5473
5535
|
data: stats.hash
|
|
5474
|
-
}), stats.errorsCount)
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5536
|
+
}), stats.errorsCount) {
|
|
5537
|
+
let { errors: formattedErrors } = formatStatsMessages({
|
|
5538
|
+
errors: getAllStatsErrors(stats),
|
|
5539
|
+
warnings: []
|
|
5540
|
+
});
|
|
5541
|
+
return this.sockWrite({
|
|
5542
|
+
type: 'errors',
|
|
5543
|
+
compilationId,
|
|
5544
|
+
data: {
|
|
5545
|
+
text: formattedErrors,
|
|
5546
|
+
html: formattedErrors.map((item)=>{
|
|
5547
|
+
var text;
|
|
5548
|
+
return server_ansiHTML((text = item) ? text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') : '');
|
|
5549
|
+
})
|
|
5550
|
+
}
|
|
5551
|
+
});
|
|
5552
|
+
}
|
|
5553
|
+
if (stats.warningsCount) {
|
|
5554
|
+
let { warnings: formattedWarnings } = formatStatsMessages({
|
|
5555
|
+
warnings: getAllStatsWarnings(stats),
|
|
5556
|
+
errors: []
|
|
5557
|
+
});
|
|
5558
|
+
return this.sockWrite({
|
|
5559
|
+
type: 'warnings',
|
|
5560
|
+
compilationId,
|
|
5561
|
+
data: {
|
|
5562
|
+
text: formattedWarnings
|
|
5563
|
+
}
|
|
5564
|
+
});
|
|
5565
|
+
}
|
|
5566
|
+
return this.sockWrite({
|
|
5483
5567
|
type: 'ok',
|
|
5484
5568
|
compilationId
|
|
5485
5569
|
});
|
|
@@ -5499,13 +5583,19 @@ function compilerDevMiddleware_define_property(obj, key, value) {
|
|
|
5499
5583
|
writable: !0
|
|
5500
5584
|
}) : obj[key] = value, obj;
|
|
5501
5585
|
}
|
|
5502
|
-
let compilerDevMiddleware_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), formatDevConfig = (config, environments)=>
|
|
5586
|
+
let compilerDevMiddleware_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), formatDevConfig = (config, environments)=>{
|
|
5587
|
+
let writeToDiskValues = Object.values(environments).map((env)=>env.config.dev.writeToDisk);
|
|
5588
|
+
return 1 === new Set(writeToDiskValues).size ? {
|
|
5589
|
+
...config,
|
|
5590
|
+
writeToDisk: writeToDiskValues[0]
|
|
5591
|
+
} : {
|
|
5503
5592
|
...config,
|
|
5504
5593
|
writeToDisk (filePath, compilationName) {
|
|
5505
5594
|
let { writeToDisk } = config;
|
|
5506
5595
|
return compilationName && environments[compilationName] && (writeToDisk = environments[compilationName].config.dev.writeToDisk ?? writeToDisk), 'function' == typeof writeToDisk ? writeToDisk(filePath) : writeToDisk;
|
|
5507
5596
|
}
|
|
5508
5597
|
};
|
|
5598
|
+
};
|
|
5509
5599
|
class CompilerDevMiddleware {
|
|
5510
5600
|
async init() {
|
|
5511
5601
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
@@ -6013,8 +6103,9 @@ let run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>new Bas
|
|
|
6013
6103
|
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments })=>{
|
|
6014
6104
|
let upgradeEvents = [];
|
|
6015
6105
|
if (server.compress && middlewares.push(gzipMiddleware()), middlewares.push((req, res, next)=>{
|
|
6106
|
+
var _parseUrl;
|
|
6016
6107
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
6017
|
-
let path = req.url ?
|
|
6108
|
+
let path = req.url ? null === (_parseUrl = parseUrl(req.url)) || void 0 === _parseUrl ? void 0 : _parseUrl.pathname : '';
|
|
6018
6109
|
(null == path ? void 0 : path.includes('hot-update')) && res.setHeader('Access-Control-Allow-Credentials', 'false');
|
|
6019
6110
|
let confHeaders = server.headers;
|
|
6020
6111
|
if (confHeaders) for (let [key, value] of Object.entries(confHeaders))res.setHeader(key, value);
|
|
@@ -6893,6 +6984,7 @@ async function createRsbuild(options = {}) {
|
|
|
6893
6984
|
build,
|
|
6894
6985
|
preview,
|
|
6895
6986
|
startDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
|
|
6987
|
+
createCompiler: (...args)=>(!context.command && (context.command = 'development' === getNodeEnv() ? 'dev' : 'build'), providerInstance.createCompiler(...args)),
|
|
6896
6988
|
createDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
|
|
6897
6989
|
...pick(pluginManager, [
|
|
6898
6990
|
'addPlugins',
|
|
@@ -6919,8 +7011,7 @@ async function createRsbuild(options = {}) {
|
|
|
6919
7011
|
]),
|
|
6920
7012
|
...pick(providerInstance, [
|
|
6921
7013
|
'initConfigs',
|
|
6922
|
-
'inspectConfig'
|
|
6923
|
-
'createCompiler'
|
|
7014
|
+
'inspectConfig'
|
|
6924
7015
|
])
|
|
6925
7016
|
}, getFlattenedPlugins = async (pluginOptions)=>{
|
|
6926
7017
|
let plugins = pluginOptions;
|
|
@@ -6959,11 +7050,11 @@ async function runCLI() {
|
|
|
6959
7050
|
}
|
|
6960
7051
|
}(), process.title = 'rsbuild-node';
|
|
6961
7052
|
let { npm_execpath } = process.env;
|
|
6962
|
-
(!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.
|
|
7053
|
+
(!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.13\n`);
|
|
6963
7054
|
}();
|
|
6964
7055
|
try {
|
|
6965
7056
|
!function() {
|
|
6966
|
-
program.name('rsbuild').usage('<command> [options]').version("1.1.
|
|
7057
|
+
program.name('rsbuild').usage('<command> [options]').version("1.1.13");
|
|
6967
7058
|
let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
|
|
6968
7059
|
[
|
|
6969
7060
|
devCommand,
|
|
@@ -7022,6 +7113,6 @@ async function runCLI() {
|
|
|
7022
7113
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
7023
7114
|
}
|
|
7024
7115
|
}
|
|
7025
|
-
let src_version = "1.1.
|
|
7116
|
+
let src_version = "1.1.13";
|
|
7026
7117
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack;
|
|
7027
7118
|
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 };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { URL } from 'node:url';
|
|
1
2
|
import type { Compiler as WebpackCompiler, MultiCompiler as WebpackMultiCompiler } from 'webpack';
|
|
2
3
|
import color from '../../compiled/picocolors/index.js';
|
|
3
4
|
import type RspackChain from '../../compiled/rspack-chain/index.js';
|
|
@@ -24,6 +25,7 @@ export declare const getPublicPathFromChain: (chain: RspackChain, withSlash?: bo
|
|
|
24
25
|
export declare const getPublicPathFromCompiler: (compiler: Rspack.Compiler | Rspack.Compilation) => string;
|
|
25
26
|
export declare const urlJoin: (base: string, path: string) => string;
|
|
26
27
|
export declare const canParse: (url: string) => boolean;
|
|
28
|
+
export declare const parseUrl: (url: string) => URL | null;
|
|
27
29
|
export declare const ensureAssetPrefix: (url: string, assetPrefix?: Rspack.PublicPath) => string;
|
|
28
30
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'js', isProd: boolean, isServer?: boolean): NonNullable<FilenameConfig['js']>;
|
|
29
31
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'css', isProd: boolean): NonNullable<FilenameConfig['css']>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module is modified based on `ansi-html-community`
|
|
3
|
+
* https://github.com/mahdyar/ansi-html-community
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* https://github.com/mahdyar/ansi-html-community/blob/master/LICENSE
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Converts text with ANSI color codes to HTML markup.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ansiHTML(text: string): string;
|
|
12
|
+
export default ansiHTML;
|
|
@@ -62,4 +62,10 @@ export declare const getAddressUrls: ({ protocol, port, host, }: {
|
|
|
62
62
|
}) => AddressUrl[];
|
|
63
63
|
export declare const getCompilationId: (compiler: Rspack.Compiler | Rspack.Compilation) => string;
|
|
64
64
|
export declare function getServerTerminator(server: Server | Http2SecureServer): () => Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Escape HTML characters
|
|
67
|
+
* @example
|
|
68
|
+
* escapeHtml('<div>Hello</div>') // '<div>Hello</div>'
|
|
69
|
+
*/
|
|
70
|
+
export declare function escapeHtml(text: string | null | undefined): string;
|
|
65
71
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"core-js": "~3.39.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@rslib/core": "0.
|
|
55
|
+
"@rslib/core": "0.2.0",
|
|
56
56
|
"@types/connect": "3.4.38",
|
|
57
57
|
"@types/node": "^22.10.2",
|
|
58
58
|
"@types/on-finished": "2.3.4",
|
|
59
59
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
60
60
|
"@types/ws": "^8.5.13",
|
|
61
61
|
"browserslist-load-config": "1.0.0",
|
|
62
|
-
"chokidar": "^4.0.
|
|
62
|
+
"chokidar": "^4.0.3",
|
|
63
63
|
"commander": "^12.1.0",
|
|
64
64
|
"connect": "3.7.0",
|
|
65
65
|
"connect-history-api-fallback": "^2.0.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"dotenv-expand": "11.0.7",
|
|
71
71
|
"html-rspack-plugin": "6.0.2",
|
|
72
72
|
"http-proxy-middleware": "^2.0.6",
|
|
73
|
-
"jiti": "^1.21.
|
|
73
|
+
"jiti": "^1.21.7",
|
|
74
74
|
"launch-editor-middleware": "^2.9.1",
|
|
75
75
|
"mrmime": "^2.0.0",
|
|
76
76
|
"on-finished": "2.4.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"rsbuild-dev-middleware": "0.1.2",
|
|
85
85
|
"rslog": "^1.2.3",
|
|
86
86
|
"rspack-chain": "^1.1.0",
|
|
87
|
-
"rspack-manifest-plugin": "5.0.
|
|
87
|
+
"rspack-manifest-plugin": "5.0.3",
|
|
88
88
|
"sirv": "^3.0.0",
|
|
89
89
|
"style-loader": "3.3.4",
|
|
90
90
|
"tinyglobby": "^0.2.10",
|
|
File without changes
|