@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"jiti","version":"1.21.
|
|
1
|
+
{"name":"jiti","version":"1.21.7","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -368,12 +368,12 @@
|
|
|
368
368
|
};
|
|
369
369
|
};
|
|
370
370
|
},
|
|
371
|
-
|
|
371
|
+
124: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
372
372
|
const { resolve } = __nccwpck_require__(411);
|
|
373
373
|
const config = __nccwpck_require__(245);
|
|
374
|
-
const loadOptions = __nccwpck_require__(
|
|
375
|
-
const loadPlugins = __nccwpck_require__(
|
|
376
|
-
const req = __nccwpck_require__(
|
|
374
|
+
const loadOptions = __nccwpck_require__(256);
|
|
375
|
+
const loadPlugins = __nccwpck_require__(356);
|
|
376
|
+
const req = __nccwpck_require__(146);
|
|
377
377
|
const interopRequireDefault = (obj) =>
|
|
378
378
|
obj && obj.__esModule ? obj : { default: obj };
|
|
379
379
|
async function processResult(ctx, result) {
|
|
@@ -487,8 +487,8 @@
|
|
|
487
487
|
* @requires ./plugins
|
|
488
488
|
*/ module.exports = rc;
|
|
489
489
|
},
|
|
490
|
-
|
|
491
|
-
const req = __nccwpck_require__(
|
|
490
|
+
256: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
491
|
+
const req = __nccwpck_require__(146);
|
|
492
492
|
async function options(config, file) {
|
|
493
493
|
if (config.parser && typeof config.parser === "string") {
|
|
494
494
|
try {
|
|
@@ -521,8 +521,8 @@
|
|
|
521
521
|
}
|
|
522
522
|
module.exports = options;
|
|
523
523
|
},
|
|
524
|
-
|
|
525
|
-
const req = __nccwpck_require__(
|
|
524
|
+
356: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
525
|
+
const req = __nccwpck_require__(146);
|
|
526
526
|
async function load(plugin, options, file) {
|
|
527
527
|
try {
|
|
528
528
|
if (
|
|
@@ -577,7 +577,7 @@
|
|
|
577
577
|
}
|
|
578
578
|
module.exports = plugins;
|
|
579
579
|
},
|
|
580
|
-
|
|
580
|
+
146: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
581
581
|
const { createRequire } = __nccwpck_require__(33);
|
|
582
582
|
const { pathToFileURL } = __nccwpck_require__(41);
|
|
583
583
|
const TS_EXT_RE = /\.[mc]?ts$/;
|
|
@@ -734,6 +734,6 @@
|
|
|
734
734
|
})();
|
|
735
735
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
736
736
|
__nccwpck_require__.ab = __dirname + "/";
|
|
737
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
737
|
+
var __webpack_exports__ = __nccwpck_require__(124);
|
|
738
738
|
module.exports = __webpack_exports__;
|
|
739
739
|
})();
|
|
@@ -41,4 +41,4 @@ declare class WebpackManifestPlugin implements RspackPluginInstance {
|
|
|
41
41
|
|
|
42
42
|
declare const RspackManifestPlugin: typeof WebpackManifestPlugin;
|
|
43
43
|
|
|
44
|
-
export { type EmitCountMap, type InternalOptions, type Manifest, type ManifestPluginOptions, RspackManifestPlugin, WebpackManifestPlugin, getCompilerHooks };
|
|
44
|
+
export { type EmitCountMap, type FileDescriptor, type InternalOptions, type Manifest, type ManifestPluginOptions, RspackManifestPlugin, WebpackManifestPlugin, getCompilerHooks };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
4
|
+
699: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.transformFiles =
|
|
7
7
|
exports.reduceChunk =
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
.map(standardizeFilePaths);
|
|
121
121
|
exports.transformFiles = transformFiles;
|
|
122
122
|
},
|
|
123
|
-
|
|
123
|
+
586: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
124
124
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
125
125
|
exports.normalModuleLoaderHook =
|
|
126
126
|
exports.getCompilerHooks =
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
const fs_1 = __nccwpck_require__(147);
|
|
131
131
|
const path_1 = __nccwpck_require__(17);
|
|
132
132
|
const lite_tapable_1 = __nccwpck_require__(348);
|
|
133
|
-
const helpers_1 = __nccwpck_require__(
|
|
133
|
+
const helpers_1 = __nccwpck_require__(699);
|
|
134
134
|
const compilerHookMap = new WeakMap();
|
|
135
135
|
const getCompilerHooks = (compiler) => {
|
|
136
136
|
let hooks = compilerHookMap.get(compiler);
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
exports.getCompilerHooks =
|
|
313
313
|
void 0;
|
|
314
314
|
const path_1 = __nccwpck_require__(17);
|
|
315
|
-
const hooks_1 = __nccwpck_require__(
|
|
315
|
+
const hooks_1 = __nccwpck_require__(586);
|
|
316
316
|
Object.defineProperty(exports, "getCompilerHooks", {
|
|
317
317
|
enumerable: true,
|
|
318
318
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"rspack-manifest-plugin","author":"Dane Thurber <dane.thurber@gmail.com>","version":"5.0.
|
|
1
|
+
{"name":"rspack-manifest-plugin","author":"Dane Thurber <dane.thurber@gmail.com>","version":"5.0.3","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/client/hmr.js
CHANGED
|
@@ -1,58 +1,3 @@
|
|
|
1
|
-
function resolveFileName(stats) {
|
|
2
|
-
if (stats.moduleIdentifier) {
|
|
3
|
-
const regex = /(?:\!|^)([^!]+)$/;
|
|
4
|
-
const matched = stats.moduleIdentifier.match(regex);
|
|
5
|
-
if (matched) {
|
|
6
|
-
const fileName = matched.pop();
|
|
7
|
-
if (fileName) return `File: ${fileName}:1:1\n`;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
const file = stats.file || stats.moduleName;
|
|
11
|
-
return file ? `File: ${file}\n` : '';
|
|
12
|
-
}
|
|
13
|
-
function resolveModuleTrace(stats) {
|
|
14
|
-
let traceStr = '';
|
|
15
|
-
if (stats.moduleTrace) {
|
|
16
|
-
for (const trace of stats.moduleTrace)if (trace.originName) traceStr += `\n @ ${trace.originName}`;
|
|
17
|
-
}
|
|
18
|
-
return traceStr;
|
|
19
|
-
}
|
|
20
|
-
function hintUnknownFiles(message) {
|
|
21
|
-
const hint = 'You may need an appropriate loader to handle this file type.';
|
|
22
|
-
if (-1 === message.indexOf(hint)) return message;
|
|
23
|
-
if (/File: .+\.s(c|a)ss/.test(message)) return message.replace(hint, 'To enable support for Sass, use "@rsbuild/plugin-sass".');
|
|
24
|
-
if (/File: .+\.less/.test(message)) return message.replace(hint, 'To enable support for Less, use "@rsbuild/plugin-less".');
|
|
25
|
-
if (/File: .+\.styl(us)?/.test(message)) return message.replace(hint, 'To enable support for Stylus, use "@rsbuild/plugin-stylus".');
|
|
26
|
-
return message;
|
|
27
|
-
}
|
|
28
|
-
function formatMessage(stats, verbose) {
|
|
29
|
-
let lines = [];
|
|
30
|
-
let message;
|
|
31
|
-
if ('object' == typeof stats) {
|
|
32
|
-
const fileName = resolveFileName(stats);
|
|
33
|
-
const mainMessage = stats.message;
|
|
34
|
-
const details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '';
|
|
35
|
-
const stack = verbose && stats.stack ? `\n${stats.stack}` : '';
|
|
36
|
-
const moduleTrace = resolveModuleTrace(stats);
|
|
37
|
-
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
38
|
-
} else message = stats;
|
|
39
|
-
message = hintUnknownFiles(message);
|
|
40
|
-
lines = message.split('\n');
|
|
41
|
-
lines = lines.filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim());
|
|
42
|
-
message = lines.join('\n');
|
|
43
|
-
const innerError = '-- inner error --';
|
|
44
|
-
if (!verbose && message.includes(innerError)) message = message.split(innerError)[0];
|
|
45
|
-
return message.trim();
|
|
46
|
-
}
|
|
47
|
-
function formatStatsMessages(stats, verbose) {
|
|
48
|
-
var _stats_errors, _stats_warnings;
|
|
49
|
-
const formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
50
|
-
const formattedWarnings = (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || [];
|
|
51
|
-
return {
|
|
52
|
-
errors: formattedErrors,
|
|
53
|
-
warnings: formattedWarnings
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
1
|
const compilationId = RSBUILD_COMPILATION_NAME;
|
|
57
2
|
const config = RSBUILD_CLIENT_CONFIG;
|
|
58
3
|
function formatURL(param) {
|
|
@@ -88,34 +33,28 @@ function handleSuccess() {
|
|
|
88
33
|
hasCompileErrors = false;
|
|
89
34
|
if (isHotUpdate) tryApplyUpdates();
|
|
90
35
|
}
|
|
91
|
-
function handleWarnings(
|
|
36
|
+
function handleWarnings(param) {
|
|
37
|
+
let { text } = param;
|
|
92
38
|
clearOutdatedErrors();
|
|
93
39
|
const isHotUpdate = !isFirstCompilation;
|
|
94
40
|
isFirstCompilation = false;
|
|
95
41
|
hasCompileErrors = false;
|
|
96
|
-
|
|
97
|
-
warnings,
|
|
98
|
-
errors: []
|
|
99
|
-
});
|
|
100
|
-
for(let i = 0; i < formatted.warnings.length; i++){
|
|
42
|
+
for(let i = 0; i < text.length; i++){
|
|
101
43
|
if (5 === i) {
|
|
102
44
|
console.warn('There were more warnings in other files, you can find a complete log in the terminal.');
|
|
103
45
|
break;
|
|
104
46
|
}
|
|
105
|
-
console.warn(
|
|
47
|
+
console.warn(text[i]);
|
|
106
48
|
}
|
|
107
49
|
if (isHotUpdate) tryApplyUpdates();
|
|
108
50
|
}
|
|
109
|
-
function handleErrors(
|
|
51
|
+
function handleErrors(param) {
|
|
52
|
+
let { text, html } = param;
|
|
110
53
|
clearOutdatedErrors();
|
|
111
54
|
isFirstCompilation = false;
|
|
112
55
|
hasCompileErrors = true;
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
warnings: []
|
|
116
|
-
});
|
|
117
|
-
for (const error of formatted.errors)console.error(error);
|
|
118
|
-
if (createOverlay) createOverlay(formatted.errors);
|
|
56
|
+
for (const error of text)console.error(error);
|
|
57
|
+
if (createOverlay) createOverlay(html);
|
|
119
58
|
}
|
|
120
59
|
const isUpdateAvailable = ()=>lastCompilationHash !== __webpack_hash__;
|
|
121
60
|
function tryApplyUpdates() {
|
package/dist/client/overlay.js
CHANGED
|
@@ -9,11 +9,6 @@ function _define_property(obj, key, value) {
|
|
|
9
9
|
else obj[key] = value;
|
|
10
10
|
return obj;
|
|
11
11
|
}
|
|
12
|
-
function stripAnsi(content) {
|
|
13
|
-
const pattern = "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))";
|
|
14
|
-
const regex = new RegExp(pattern, 'g');
|
|
15
|
-
return content.replace(regex, '');
|
|
16
|
-
}
|
|
17
12
|
function linkedText(root, selector, text) {
|
|
18
13
|
const el = root.querySelector(selector);
|
|
19
14
|
const fileRegex = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
|
|
@@ -23,7 +18,7 @@ function linkedText(root, selector, text) {
|
|
|
23
18
|
const { 0: file, index } = match;
|
|
24
19
|
if (null != index) {
|
|
25
20
|
const frag = text.slice(curIndex, index);
|
|
26
|
-
el.
|
|
21
|
+
el.insertAdjacentHTML('beforeend', frag);
|
|
27
22
|
const link = document.createElement('a');
|
|
28
23
|
link.textContent = file;
|
|
29
24
|
link.className = 'file-link';
|
|
@@ -36,7 +31,7 @@ function linkedText(root, selector, text) {
|
|
|
36
31
|
match = fileRegex.exec(text);
|
|
37
32
|
}
|
|
38
33
|
const frag = text.slice(curIndex);
|
|
39
|
-
el.
|
|
34
|
+
el.insertAdjacentHTML('beforeend', frag);
|
|
40
35
|
}
|
|
41
36
|
const overlayTemplate = `
|
|
42
37
|
<style>
|
|
@@ -75,7 +70,7 @@ const overlayTemplate = `
|
|
|
75
70
|
padding-bottom: 12px;
|
|
76
71
|
font-size: 17px;
|
|
77
72
|
font-weight: 600;
|
|
78
|
-
color: #
|
|
73
|
+
color: #fb6a6a;
|
|
79
74
|
border-bottom: 2px solid rgba(252,94,94,.66);
|
|
80
75
|
}
|
|
81
76
|
.content {
|
|
@@ -84,15 +79,15 @@ const overlayTemplate = `
|
|
|
84
79
|
font-family: inherit;
|
|
85
80
|
overflow-x: scroll;
|
|
86
81
|
scrollbar-width: none;
|
|
87
|
-
color: #b8b8b8;
|
|
88
82
|
}
|
|
89
83
|
.content::-webkit-scrollbar {
|
|
90
84
|
display: none;
|
|
91
85
|
}
|
|
92
86
|
.file-link {
|
|
93
87
|
cursor: pointer;
|
|
94
|
-
color: #
|
|
88
|
+
color: #6eecf7;
|
|
95
89
|
text-decoration: underline;
|
|
90
|
+
text-underline-offset: 3px;
|
|
96
91
|
&:hover {
|
|
97
92
|
opacity: 0.8;
|
|
98
93
|
}
|
|
@@ -149,7 +144,7 @@ const overlayTemplate = `
|
|
|
149
144
|
<div class="root">
|
|
150
145
|
<div class="container">
|
|
151
146
|
<div class="close"></div>
|
|
152
|
-
<p class="title">
|
|
147
|
+
<p class="title">Build failed</p>
|
|
153
148
|
<pre class="content"></pre>
|
|
154
149
|
<footer class="footer">
|
|
155
150
|
<p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
|
|
@@ -189,7 +184,7 @@ class ErrorOverlay extends HTMLElement {
|
|
|
189
184
|
mode: 'open'
|
|
190
185
|
});
|
|
191
186
|
root.innerHTML = overlayTemplate;
|
|
192
|
-
linkedText(root, '.content',
|
|
187
|
+
linkedText(root, '.content', message.join('\n\n').trim());
|
|
193
188
|
null === (_root_querySelector = root.querySelector('.close')) || void 0 === _root_querySelector || _root_querySelector.addEventListener('click', this.close);
|
|
194
189
|
this.addEventListener('click', this.close);
|
|
195
190
|
root.querySelector('.container').addEventListener('click', (e)=>{
|
package/dist/index.cjs
CHANGED
|
@@ -1483,11 +1483,11 @@ var __webpack_exports__ = {};
|
|
|
1483
1483
|
}, getHTMLPlugin = ()=>(!pluginHelper_htmlPlugin && (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
|
|
1484
1484
|
cssExtractPlugin = plugin;
|
|
1485
1485
|
}, getCssExtractPlugin = ()=>cssExtractPlugin ? cssExtractPlugin : core_default().CssExtractRspackPlugin;
|
|
1486
|
-
var external_node_fs_ = __webpack_require__("node:fs"), external_node_fs_default = __webpack_require__.n(external_node_fs_), external_node_path_ = __webpack_require__("node:path"), external_node_path_default = __webpack_require__.n(external_node_path_), main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.7/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")
|
|
1486
|
+
var external_node_fs_ = __webpack_require__("node:fs"), external_node_fs_default = __webpack_require__.n(external_node_fs_), external_node_path_ = __webpack_require__("node:path"), external_node_path_default = __webpack_require__.n(external_node_path_), main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.7/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");
|
|
1487
|
+
let external_node_url_namespaceObject = require("node:url");
|
|
1488
|
+
var cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
|
|
1487
1489
|
let index_js_namespaceObject = require("../compiled/picocolors/index.js");
|
|
1488
1490
|
var index_js_default = __webpack_require__.n(index_js_namespaceObject);
|
|
1489
|
-
let external_node_url_namespaceObject = require("node:url");
|
|
1490
|
-
var external_node_url_default = __webpack_require__.n(external_node_url_namespaceObject);
|
|
1491
1491
|
let constants_filename = (0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__), constants_dirname = (0, external_node_path_.dirname)(constants_filename), 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 = [
|
|
1492
1492
|
'chrome >= 87',
|
|
1493
1493
|
'edge >= 88',
|
|
@@ -1602,47 +1602,11 @@ var __webpack_exports__ = {};
|
|
|
1602
1602
|
} catch (err) {
|
|
1603
1603
|
return publicPath;
|
|
1604
1604
|
}
|
|
1605
|
-
}
|
|
1606
|
-
function formatMessage(stats, verbose) {
|
|
1607
|
-
let message, lines = [];
|
|
1608
|
-
if ('object' == typeof stats) {
|
|
1609
|
-
let fileName = function(stats) {
|
|
1610
|
-
if (stats.moduleIdentifier) {
|
|
1611
|
-
let matched = stats.moduleIdentifier.match(/(?:\!|^)([^!]+)$/);
|
|
1612
|
-
if (matched) {
|
|
1613
|
-
let fileName = matched.pop();
|
|
1614
|
-
if (fileName) return `File: ${fileName}:1:1\n`;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
let file = stats.file || stats.moduleName;
|
|
1618
|
-
return file ? `File: ${file}\n` : '';
|
|
1619
|
-
}(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
|
|
1620
|
-
let traceStr = '';
|
|
1621
|
-
if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
|
|
1622
|
-
return traceStr;
|
|
1623
|
-
}(stats);
|
|
1624
|
-
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
1625
|
-
} else message = stats;
|
|
1626
|
-
message = (lines = (lines = (message = function(message) {
|
|
1627
|
-
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
1628
|
-
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;
|
|
1629
|
-
}(message)).split('\n')).filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n');
|
|
1630
|
-
let innerError = '-- inner error --';
|
|
1631
|
-
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), message.trim();
|
|
1632
|
-
}
|
|
1633
|
-
function formatStatsMessages(stats, verbose) {
|
|
1634
|
-
var _stats_errors, _stats_warnings;
|
|
1635
|
-
let formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
1636
|
-
return {
|
|
1637
|
-
errors: formattedErrors,
|
|
1638
|
-
warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
|
|
1639
|
-
};
|
|
1640
|
-
}
|
|
1641
|
-
let hintNodePolyfill = (message)=>{
|
|
1605
|
+
}, hintNodePolyfill = (message)=>{
|
|
1642
1606
|
let getTips = (moduleName)=>{
|
|
1643
1607
|
let tips = [
|
|
1644
1608
|
`Tip: "${moduleName}" is a built-in Node.js module. It cannot be imported in client-side code.`,
|
|
1645
|
-
`Check if you need to import Node.js module. If needed, you can use ${index_js_default().cyan('@rsbuild/plugin-node-polyfill')}.`
|
|
1609
|
+
`Check if you need to import Node.js module. If needed, you can use "${index_js_default().cyan('@rsbuild/plugin-node-polyfill')}" to polyfill it.`
|
|
1646
1610
|
];
|
|
1647
1611
|
return `${message}\n\n${index_js_default().yellow(tips.join('\n'))}`;
|
|
1648
1612
|
};
|
|
@@ -1691,7 +1655,42 @@ var __webpack_exports__ = {};
|
|
|
1691
1655
|
'vm',
|
|
1692
1656
|
'zlib'
|
|
1693
1657
|
].includes(moduleName) ? getTips(moduleName) : message;
|
|
1694
|
-
}
|
|
1658
|
+
};
|
|
1659
|
+
function formatMessage(stats, verbose) {
|
|
1660
|
+
let message, lines = [];
|
|
1661
|
+
if ('object' == typeof stats) {
|
|
1662
|
+
let fileName = function(stats) {
|
|
1663
|
+
if (stats.moduleIdentifier) {
|
|
1664
|
+
let matched = stats.moduleIdentifier.match(/(?:\!|^)([^!]+)$/);
|
|
1665
|
+
if (matched) {
|
|
1666
|
+
let fileName = matched.pop();
|
|
1667
|
+
if (fileName) return `File: ${fileName}:1:1\n`;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
let file = stats.file || stats.moduleName;
|
|
1671
|
+
return file ? `File: ${file}\n` : '';
|
|
1672
|
+
}(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
|
|
1673
|
+
let traceStr = '';
|
|
1674
|
+
if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
|
|
1675
|
+
return traceStr;
|
|
1676
|
+
}(stats);
|
|
1677
|
+
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
1678
|
+
} else message = stats;
|
|
1679
|
+
let innerError = '-- inner error --';
|
|
1680
|
+
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), (message = (lines = (lines = (message = hintNodePolyfill(message = function(message) {
|
|
1681
|
+
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
1682
|
+
return -1 === message.indexOf(hint) ? message : /File: .+\.s(c|a)ss/.test(message) ? message.replace(hint, `To enable support for Sass, use "${index_js_default().yellow('@rsbuild/plugin-sass')}".`) : /File: .+\.less/.test(message) ? message.replace(hint, `To enable support for Less, use "${index_js_default().yellow('@rsbuild/plugin-less')}".`) : /File: .+\.styl(us)?/.test(message) ? message.replace(hint, `To enable support for Stylus, use "${index_js_default().yellow('@rsbuild/plugin-stylus')}".`) : message;
|
|
1683
|
+
}(message))).split('\n')).filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n')).trim();
|
|
1684
|
+
}
|
|
1685
|
+
function formatStatsMessages(stats, verbose) {
|
|
1686
|
+
var _stats_errors, _stats_warnings;
|
|
1687
|
+
let formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
1688
|
+
return {
|
|
1689
|
+
errors: formattedErrors,
|
|
1690
|
+
warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
let getAllStatsErrors = (statsData)=>{
|
|
1695
1694
|
var _statsData_errors, _statsData_children;
|
|
1696
1695
|
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;
|
|
1697
1696
|
}, getAllStatsWarnings = (statsData)=>{
|
|
@@ -1716,9 +1715,9 @@ var __webpack_exports__ = {};
|
|
|
1716
1715
|
}, verbose);
|
|
1717
1716
|
return {
|
|
1718
1717
|
message: function(errors) {
|
|
1719
|
-
let
|
|
1718
|
+
let title = index_js_default().bold(index_js_default().red('Compile error: '));
|
|
1720
1719
|
if (!errors.length) return `${title}\n${index_js_default().yellow("For more details, please setting 'stats.errors: true' ")}`;
|
|
1721
|
-
let tip = index_js_default().yellow('Failed to compile, check the errors for troubleshooting.')
|
|
1720
|
+
let tip = index_js_default().yellow('Failed to compile, check the errors for troubleshooting.'), text = `${errors.join('\n\n')}\n`;
|
|
1722
1721
|
return `${title}\n${tip}\n${text}`;
|
|
1723
1722
|
}(errors),
|
|
1724
1723
|
level: 'error'
|
|
@@ -1766,10 +1765,16 @@ var __webpack_exports__ = {};
|
|
|
1766
1765
|
return `${urlProtocol}://${external_node_path_.posix.join(baseUrl, path)}`;
|
|
1767
1766
|
}, canParse = (url)=>{
|
|
1768
1767
|
try {
|
|
1769
|
-
return new URL(url), !0;
|
|
1768
|
+
return new external_node_url_namespaceObject.URL(url), !0;
|
|
1770
1769
|
} catch {
|
|
1771
1770
|
return !1;
|
|
1772
1771
|
}
|
|
1772
|
+
}, parseUrl = (url)=>{
|
|
1773
|
+
try {
|
|
1774
|
+
return new external_node_url_namespaceObject.URL(url);
|
|
1775
|
+
} catch {
|
|
1776
|
+
return null;
|
|
1777
|
+
}
|
|
1773
1778
|
}, 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);
|
|
1774
1779
|
function getFilename(config, type, isProd, isServer) {
|
|
1775
1780
|
let { filename, filenameHash } = config.output, hash = 'string' == typeof filenameHash ? filenameHash ? `.[${filenameHash}]` : '' : filenameHash ? '.[contenthash:8]' : '';
|
|
@@ -2741,7 +2746,7 @@ var __webpack_exports__ = {};
|
|
|
2741
2746
|
async function createContext(options, userConfig, bundlerType) {
|
|
2742
2747
|
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');
|
|
2743
2748
|
return {
|
|
2744
|
-
version: "1.1.
|
|
2749
|
+
version: "1.1.13",
|
|
2745
2750
|
rootPath,
|
|
2746
2751
|
distPath: '',
|
|
2747
2752
|
cachePath,
|
|
@@ -5354,8 +5359,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5354
5359
|
environment
|
|
5355
5360
|
})));
|
|
5356
5361
|
if (isDebug()) {
|
|
5357
|
-
let inspect = ()=>{
|
|
5358
|
-
inspectConfig({
|
|
5362
|
+
let inspect = async ()=>{
|
|
5363
|
+
await inspectConfig({
|
|
5359
5364
|
context,
|
|
5360
5365
|
pluginManager,
|
|
5361
5366
|
inspectOptions: {
|
|
@@ -5366,8 +5371,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5366
5371
|
bundlerConfigs: rspackConfigs
|
|
5367
5372
|
});
|
|
5368
5373
|
};
|
|
5369
|
-
context.hooks.onBeforeBuild.tap(({ isFirstCompile })=>{
|
|
5370
|
-
isFirstCompile && inspect();
|
|
5374
|
+
context.hooks.onBeforeBuild.tap(async ({ isFirstCompile })=>{
|
|
5375
|
+
isFirstCompile && await inspect();
|
|
5371
5376
|
}), context.hooks.onAfterStartDevServer.tap(inspect);
|
|
5372
5377
|
}
|
|
5373
5378
|
return {
|
|
@@ -5467,7 +5472,62 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5467
5472
|
}), setupServerHooks(compiler, callbacks);
|
|
5468
5473
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
5469
5474
|
};
|
|
5470
|
-
}, external_node_querystring_namespaceObject = require("node:querystring")
|
|
5475
|
+
}, external_node_querystring_namespaceObject = require("node:querystring"), colors = {
|
|
5476
|
+
black: '#000',
|
|
5477
|
+
red: '#fb6a6a',
|
|
5478
|
+
green: '#6ef790',
|
|
5479
|
+
yellow: '#eff986',
|
|
5480
|
+
cyan: '#6eecf7',
|
|
5481
|
+
blue: '#6eb2f7',
|
|
5482
|
+
magenta: '#f76ebe',
|
|
5483
|
+
lightgrey: '#f0f0f0',
|
|
5484
|
+
darkgrey: '#888'
|
|
5485
|
+
}, styles = {
|
|
5486
|
+
30: 'black',
|
|
5487
|
+
31: 'red',
|
|
5488
|
+
32: 'green',
|
|
5489
|
+
33: 'yellow',
|
|
5490
|
+
34: 'blue',
|
|
5491
|
+
35: 'magenta',
|
|
5492
|
+
36: 'cyan',
|
|
5493
|
+
37: 'lightgrey'
|
|
5494
|
+
}, openTags = {
|
|
5495
|
+
1: 'font-weight:bold',
|
|
5496
|
+
2: 'opacity:0.5',
|
|
5497
|
+
3: '<i>',
|
|
5498
|
+
4: '<u>',
|
|
5499
|
+
8: 'display:none',
|
|
5500
|
+
9: '<del>'
|
|
5501
|
+
}, closeTags = {
|
|
5502
|
+
23: '</i>',
|
|
5503
|
+
24: '</u>',
|
|
5504
|
+
29: '</del>'
|
|
5505
|
+
};
|
|
5506
|
+
for (let n of [
|
|
5507
|
+
0,
|
|
5508
|
+
21,
|
|
5509
|
+
22,
|
|
5510
|
+
27,
|
|
5511
|
+
28,
|
|
5512
|
+
39,
|
|
5513
|
+
49
|
|
5514
|
+
])closeTags[n.toString()] = '</span>';
|
|
5515
|
+
!function() {
|
|
5516
|
+
for(let code in openTags['90'] = `color:${colors.darkgrey}`, styles){
|
|
5517
|
+
let oriColor = colors[styles[code]] || colors.black;
|
|
5518
|
+
openTags[code] = `color:${oriColor}`;
|
|
5519
|
+
}
|
|
5520
|
+
}();
|
|
5521
|
+
let server_ansiHTML = function(text) {
|
|
5522
|
+
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;
|
|
5523
|
+
let ansiCodes = [], ret = text.replace(/\x1B\[(\d+)m/g, (_match, seq)=>{
|
|
5524
|
+
let ot = openTags[seq];
|
|
5525
|
+
if (ot) return -1 !== ansiCodes.indexOf(seq) ? (ansiCodes.pop(), '</span>') : (ansiCodes.push(seq), '<' === ot[0] ? ot : `<span style="${ot}">`);
|
|
5526
|
+
let ct = closeTags[seq];
|
|
5527
|
+
return ct ? (ansiCodes.pop(), ct) : '';
|
|
5528
|
+
}), l = ansiCodes.length;
|
|
5529
|
+
return l > 0 && (ret += Array(l + 1).join('</span>')), ret;
|
|
5530
|
+
};
|
|
5471
5531
|
function socketServer_define_property(obj, key, value) {
|
|
5472
5532
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
5473
5533
|
value: value,
|
|
@@ -5569,25 +5629,49 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5569
5629
|
for (let v of a.values())if (!b.has(v)) return !1;
|
|
5570
5630
|
return !0;
|
|
5571
5631
|
}(initialChunks, newInitialChunks);
|
|
5572
|
-
|
|
5632
|
+
if (this.initialChunks[compilationId] = newInitialChunks, shouldReload) return this.sockWrite({
|
|
5573
5633
|
type: 'content-changed',
|
|
5574
5634
|
compilationId
|
|
5575
|
-
})
|
|
5635
|
+
});
|
|
5636
|
+
if (!force && stats && !stats.errorsCount && stats.assets && stats.assets.every((asset)=>!asset.emitted)) return this.sockWrite({
|
|
5576
5637
|
type: 'still-ok',
|
|
5577
5638
|
compilationId
|
|
5578
|
-
})
|
|
5639
|
+
});
|
|
5640
|
+
if (this.sockWrite({
|
|
5579
5641
|
type: 'hash',
|
|
5580
5642
|
compilationId,
|
|
5581
5643
|
data: stats.hash
|
|
5582
|
-
}), stats.errorsCount)
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5644
|
+
}), stats.errorsCount) {
|
|
5645
|
+
let { errors: formattedErrors } = formatStatsMessages({
|
|
5646
|
+
errors: getAllStatsErrors(stats),
|
|
5647
|
+
warnings: []
|
|
5648
|
+
});
|
|
5649
|
+
return this.sockWrite({
|
|
5650
|
+
type: 'errors',
|
|
5651
|
+
compilationId,
|
|
5652
|
+
data: {
|
|
5653
|
+
text: formattedErrors,
|
|
5654
|
+
html: formattedErrors.map((item)=>{
|
|
5655
|
+
var text;
|
|
5656
|
+
return server_ansiHTML((text = item) ? text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') : '');
|
|
5657
|
+
})
|
|
5658
|
+
}
|
|
5659
|
+
});
|
|
5660
|
+
}
|
|
5661
|
+
if (stats.warningsCount) {
|
|
5662
|
+
let { warnings: formattedWarnings } = formatStatsMessages({
|
|
5663
|
+
warnings: getAllStatsWarnings(stats),
|
|
5664
|
+
errors: []
|
|
5665
|
+
});
|
|
5666
|
+
return this.sockWrite({
|
|
5667
|
+
type: 'warnings',
|
|
5668
|
+
compilationId,
|
|
5669
|
+
data: {
|
|
5670
|
+
text: formattedWarnings
|
|
5671
|
+
}
|
|
5672
|
+
});
|
|
5673
|
+
}
|
|
5674
|
+
return this.sockWrite({
|
|
5591
5675
|
type: 'ok',
|
|
5592
5676
|
compilationId
|
|
5593
5677
|
});
|
|
@@ -5607,13 +5691,19 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5607
5691
|
writable: !0
|
|
5608
5692
|
}) : obj[key] = value, obj;
|
|
5609
5693
|
}
|
|
5610
|
-
let compilerDevMiddleware_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), formatDevConfig = (config, environments)=>
|
|
5694
|
+
let compilerDevMiddleware_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), formatDevConfig = (config, environments)=>{
|
|
5695
|
+
let writeToDiskValues = Object.values(environments).map((env)=>env.config.dev.writeToDisk);
|
|
5696
|
+
return 1 === new Set(writeToDiskValues).size ? {
|
|
5697
|
+
...config,
|
|
5698
|
+
writeToDisk: writeToDiskValues[0]
|
|
5699
|
+
} : {
|
|
5611
5700
|
...config,
|
|
5612
5701
|
writeToDisk (filePath, compilationName) {
|
|
5613
5702
|
let { writeToDisk } = config;
|
|
5614
5703
|
return compilationName && environments[compilationName] && (writeToDisk = environments[compilationName].config.dev.writeToDisk ?? writeToDisk), 'function' == typeof writeToDisk ? writeToDisk(filePath) : writeToDisk;
|
|
5615
5704
|
}
|
|
5616
5705
|
};
|
|
5706
|
+
};
|
|
5617
5707
|
class CompilerDevMiddleware {
|
|
5618
5708
|
async init() {
|
|
5619
5709
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
@@ -6126,8 +6216,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6126
6216
|
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments })=>{
|
|
6127
6217
|
let upgradeEvents = [];
|
|
6128
6218
|
if (server.compress && middlewares.push(gzipMiddleware()), middlewares.push((req, res, next)=>{
|
|
6219
|
+
var _parseUrl;
|
|
6129
6220
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
6130
|
-
let path = req.url ?
|
|
6221
|
+
let path = req.url ? null === (_parseUrl = parseUrl(req.url)) || void 0 === _parseUrl ? void 0 : _parseUrl.pathname : '';
|
|
6131
6222
|
(null == path ? void 0 : path.includes('hot-update')) && res.setHeader('Access-Control-Allow-Credentials', 'false');
|
|
6132
6223
|
let confHeaders = server.headers;
|
|
6133
6224
|
if (confHeaders) for (let [key, value] of Object.entries(confHeaders))res.setHeader(key, value);
|
|
@@ -7006,6 +7097,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7006
7097
|
build,
|
|
7007
7098
|
preview,
|
|
7008
7099
|
startDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
|
|
7100
|
+
createCompiler: (...args)=>(!context.command && (context.command = 'development' === getNodeEnv() ? 'dev' : 'build'), providerInstance.createCompiler(...args)),
|
|
7009
7101
|
createDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
|
|
7010
7102
|
...pick(pluginManager, [
|
|
7011
7103
|
'addPlugins',
|
|
@@ -7032,8 +7124,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7032
7124
|
]),
|
|
7033
7125
|
...pick(providerInstance, [
|
|
7034
7126
|
'initConfigs',
|
|
7035
|
-
'inspectConfig'
|
|
7036
|
-
'createCompiler'
|
|
7127
|
+
'inspectConfig'
|
|
7037
7128
|
])
|
|
7038
7129
|
}, getFlattenedPlugins = async (pluginOptions)=>{
|
|
7039
7130
|
let plugins = pluginOptions;
|
|
@@ -7072,11 +7163,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7072
7163
|
}
|
|
7073
7164
|
}(), process.title = 'rsbuild-node';
|
|
7074
7165
|
let { npm_execpath } = process.env;
|
|
7075
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.
|
|
7166
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.13\n`);
|
|
7076
7167
|
}();
|
|
7077
7168
|
try {
|
|
7078
7169
|
!function() {
|
|
7079
|
-
program.name('rsbuild').usage('<command> [options]').version("1.1.
|
|
7170
|
+
program.name('rsbuild').usage('<command> [options]').version("1.1.13");
|
|
7080
7171
|
let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
|
|
7081
7172
|
[
|
|
7082
7173
|
devCommand,
|
|
@@ -7135,7 +7226,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7135
7226
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
7136
7227
|
}
|
|
7137
7228
|
}
|
|
7138
|
-
let src_rslib_entry_version = "1.1.
|
|
7229
|
+
let src_rslib_entry_version = "1.1.13";
|
|
7139
7230
|
})();
|
|
7140
7231
|
var __webpack_export_target__ = exports;
|
|
7141
7232
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|