Skip to content

Commit 52ee813

Browse files
authored
docs: improve documentation for stats properties (#11792)
* docs: improve documentation for stats properties * fix
1 parent e169788 commit 52ee813

File tree

7 files changed

+61
-16
lines changed

7 files changed

+61
-16
lines changed

packages/rspack/etc/core.api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,6 @@ type DevToolPosition = "inline-" | "hidden-" | "eval-" | "";
18151815

18161816
// @public (undocumented)
18171817
interface Diagnostic {
1818-
// (undocumented)
18191818
file?: string;
18201819
// (undocumented)
18211820
help?: string;

packages/rspack/src/config/adapterRuleUse.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ export interface Diagnostic {
112112
sourceCode?: string;
113113
/**
114114
* Location to the source code.
115-
*
116115
* If `sourceCode` is not provided, location will be omitted.
117116
*/
118117
location?: DiagnosticLocation;
118+
/**
119+
* Optional filename to show.
120+
* If provided, it becomes the `StatsError.file` value in stats.
121+
*/
119122
file?: string;
120123
severity: "error" | "warning";
121124
}

packages/rspack/src/stats/statsFactoryUtils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,25 @@ export type KnownStatsError = {
185185
chunkName?: string;
186186
chunkEntry?: boolean;
187187
chunkInitial?: boolean;
188+
/**
189+
* A custom filename associated with this error/warning.
190+
*/
188191
file?: string;
192+
/**
193+
* The identifier of the module related to this error/warning.
194+
* Usually an absolute path, may include inline loader requests.
195+
* @example
196+
* - `/path/to/project/src/index.js`
197+
* - `!builtin:react-refresh-loader!/path/to/project/src/index.css`
198+
*/
189199
moduleIdentifier?: string;
200+
/**
201+
* The readable name of the module related to this error/warning.
202+
* Usually a relative path, no inline loader requests.
203+
* @example
204+
* - `"./src/index.js"`
205+
* - `"./src/index.css"`
206+
*/
190207
moduleName?: string;
191208
loc?: string;
192209
chunkId?: string | number;

website/docs/en/api/javascript-api/stats-json.mdx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,27 @@ Each error or warning object represents an error/warning thrown during the build
315315
type StatsError = {
316316
// Visual message of the error/warning
317317
message: string;
318-
// Related source file
318+
// A custom filename associated with this error/warning.
319319
file?: string;
320320
// Detail info of the error/warning
321321
details?: string;
322322
// Stack info of the error/warning
323323
stack?: string;
324-
325-
// Unique identifier of the module where the error/warning occurs
324+
/**
325+
* The identifier of the module related to this error/warning.
326+
* Usually an absolute path, may include inline loader requests.
327+
* @example
328+
* - `/path/to/project/src/index.js`
329+
* - `!builtin:react-refresh-loader!/path/to/project/src/index.css`
330+
*/
326331
moduleIdentifier?: string;
327-
// Relative path of the module where the error/warning occurs
332+
/**
333+
* The readable name of the module related to this error/warning.
334+
* Usually a relative path, no inline loader requests.
335+
* @example
336+
* - `"./src/index.js"`
337+
* - `"./src/index.css"`
338+
*/
328339
moduleName?: string;
329340
// ID of the module where the error/warning occurs
330341
moduleId?: string;

website/docs/en/api/loader-api/context.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,13 @@ interface Diagnostic {
221221
sourceCode?: string;
222222
/**
223223
* Location to the source code.
224-
*
225224
* If `sourceCode` is not provided, location will be omitted.
226225
*/
227226
location?: DiagnosticLocation;
227+
/**
228+
* Optional filename to show.
229+
* If provided, it becomes the `StatsError.file` value in stats.
230+
*/
228231
file?: string;
229232
severity: 'error' | 'warning';
230233
}

website/docs/zh/api/javascript-api/stats-json.mdx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,27 @@ type StatsChunkGroup = {
317317
type StatsError = {
318318
// 错误/警告的可视化提示信息
319319
message: string;
320-
// 相关资源文件
320+
// 与此错误/警告关联的自定义文件名
321321
file?: string;
322322
// 错误/警告的明细信息
323323
details?: string;
324324
// 错误/警告的栈信息
325325
stack?: string;
326-
327-
// 发生错误/警告的模块唯一标识
326+
/**
327+
* 与此错误/警告相关的模块标识符
328+
* 通常是绝对路径,可能包含内联的 loader request
329+
* @example
330+
* - `/path/to/project/src/index.js`
331+
* - `!builtin:react-refresh-loader!/path/to/project/src/index.css`
332+
*/
328333
moduleIdentifier?: string;
329-
// 发生错误/警告的模块相对路径
330-
moduleName?: string;
331-
// 发生错误/警告的模块 ID
334+
/**
335+
* 与此错误/警告相关的模块可读名称
336+
* 通常是相对路径,不包含内联的 loader request
337+
* @example
338+
* - `"./src/index.js"`
339+
* - `"./src/index.css"`
340+
*/
332341
moduleId?: string;
333342
// 错误/警告的模块引用路径
334343
moduleTrace: Array<JsStatsModuleTrace>;

website/docs/zh/api/loader-api/context.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,14 @@ interface Diagnostic {
211211
help?: string;
212212
sourceCode?: string;
213213
/**
214-
* Location to the source code.
215-
*
216-
* If `sourceCode` is not provided, location will be omitted.
214+
* 源代码的位置信息
215+
* 如果未提供 `sourceCode`,则位置信息将被省略
217216
*/
218217
location?: DiagnosticLocation;
218+
/**
219+
* 可选展示的文件名
220+
* 如果设置,它将成为 stats 中的 `StatsError.file` 值
221+
*/
219222
file?: string;
220223
severity: 'error' | 'warning';
221224
}

0 commit comments

Comments
 (0)