MCPcopy Index your code
hub / github.com/react/react / handleRollupError

Function handleRollupError

scripts/rollup/build.js:793–821  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

791}
792
793function handleRollupError(error) {
794 loggedErrors.add(error);
795 if (!error.code) {
796 console.error(error);
797 return;
798 }
799 console.error(
800 `\x1b[31m-- ${error.code}${error.plugin ? ` (${error.plugin})` : ''} --`
801 );
802 console.error(error.stack);
803 if (error.loc && error.loc.file) {
804 const {file, line, column} = error.loc;
805 // This looks like an error from Rollup, e.g. missing export.
806 // We'll use the accurate line numbers provided by Rollup but
807 // use Babel code frame because it looks nicer.
808 const rawLines = fs.readFileSync(file, 'utf-8');
809 // column + 1 is required due to rollup counting column start position from 0
810 // whereas babel-code-frame counts from 1
811 const frame = codeFrame(rawLines, line, column + 1, {
812 highlightCode: true,
813 });
814 console.error(frame);
815 } else if (error.codeFrame) {
816 // This looks like an error from a plugin (e.g. Babel).
817 // In this case we'll resort to displaying the provided code frame
818 // because we can't be sure the reported location is accurate.
819 console.error(error.codeFrame);
820 }
821}
822
823function runShellCommand(command) {
824 console.log(chalk.dim('Running: ') + chalk.cyan(command));

Callers 1

createBundleFunction · 0.85

Calls 2

addMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected