Have you read the Contributing Guidelines on issues?
Prerequisites
Description
The code to print console error messages is quite bad:
import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
export function formatStatsErrorMessage(
statsJson: ReturnType<webpack.Stats['toJson']> | undefined,
): string | undefined {
if (statsJson?.errors?.length) {
const {errors} = formatWebpackMessages(statsJson);
return errors
.map((str) => logger.red(str))
.join(`\n\n${logger.yellow('--------------------------')}\n\n`);
}
return undefined;
}
'react-dev-utils/formatWebpackMessages' does not print all the relevant info, notably the file path that on which the error happens, and this prevents users from solving their problems.
Example #9022
Reproducible demo
No response
Steps to reproduce
- init new site
- add
src/thing.xyz
- add
import './thing.xyz' on src/index.tsx
Console error:
However, the Dev Server error overlay works better:
Expected behavior
We should print relevant information to the console. At least the file path.
This info is definitively available in the Webpack stats:
const stats = {
errors: [
{
moduleIdentifier: '/Users/sebastienlorber/Desktop/website/src/pages/thing.xyz',
moduleName: './src/pages/thing.xyz',
loc: '1:0',
message: "Module parse failed: Unexpected character '🔥' (1:0)\n" +
'You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\n' +
'> 🔥 bad file content'
}
],
errorsCount: 1,
warnings: [],
warningsCount: 0
}
Actual behavior
Error message does not contain the problematic file path
Your environment
- Docusaurus version used: v2.4.1 or v3 canary
Self-service
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clearoryarn clearcommand.rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages.Description
The code to print console error messages is quite bad:
'react-dev-utils/formatWebpackMessages'does not print all the relevant info, notably the file path that on which the error happens, and this prevents users from solving their problems.Example #9022
Reproducible demo
No response
Steps to reproduce
src/thing.xyzimport './thing.xyz'onsrc/index.tsxConsole error:
However, the Dev Server error overlay works better:
Expected behavior
We should print relevant information to the console. At least the file path.
This info is definitively available in the Webpack stats:
Actual behavior
Error message does not contain the problematic file path
Your environment
Self-service