Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions packages/core/src/helpers/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ const formatFileName = (fileName: string) => {
};

function resolveFileName(stats: StatsError) {
// `moduleName` is the readable relative path of the source file
// e.g. "./src/App.jsx"
if (stats.moduleName) {
return formatFileName(stats.moduleName);
const file =
// `file` is a custom file path related to the stats error. For example,
// ts-checker-rspack-plugin sets the module path of type errors to this field.
// It should be output first as it provides the most specific error location.
stats.file ||
// `moduleName` is the readable relative path of the source file
// e.g. "./src/App.jsx"
stats.moduleName;

if (file) {
return formatFileName(file);
}

// `moduleIdentifier` is the absolute path with inline loaders
Expand All @@ -28,9 +35,7 @@ function resolveFileName(stats: StatsError) {
}
}

// fallback to `file` if `moduleName` and `moduleIdentifier` do not exist
const file = stats.file;
return file ? formatFileName(file) : '';
return '';
}

function resolveModuleTrace(stats: StatsError) {
Expand Down
Loading