runMinimizeCommand() — react Function Reference
Architecture documentation for the runMinimizeCommand() function in runner.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD d5caee94_b787_985a_c66f_301a6cb1eaba["runMinimizeCommand()"] 1fd49604_fb16_2568_4971_9eca12fd6a73["runner.ts"] d5caee94_b787_985a_c66f_301a6cb1eaba -->|defined in| 1fd49604_fb16_2568_4971_9eca12fd6a73 5a048c02_8e86_6fb8_e501_a05c0f563dce["parseLanguage()"] d5caee94_b787_985a_c66f_301a6cb1eaba -->|calls| 5a048c02_8e86_6fb8_e501_a05c0f563dce 4553e8b5_c1d7_17bf_ec31_bf39f1f5df21["parseSourceType()"] d5caee94_b787_985a_c66f_301a6cb1eaba -->|calls| 4553e8b5_c1d7_17bf_ec31_bf39f1f5df21 4cc2ea3f_517f_a920_44fb_ae7d745078a5["minimize()"] d5caee94_b787_985a_c66f_301a6cb1eaba -->|calls| 4cc2ea3f_517f_a920_44fb_ae7d745078a5 style d5caee94_b787_985a_c66f_301a6cb1eaba fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/snap/src/runner.ts lines 158–209
async function runMinimizeCommand(opts: MinimizeOptions): Promise<void> {
// Resolve the input path
const inputPath = path.isAbsolute(opts.path)
? opts.path
: path.resolve(PROJECT_ROOT, opts.path);
// Check if file exists
if (!fs.existsSync(inputPath)) {
console.error(`Error: File not found: ${inputPath}`);
process.exit(1);
}
// Read the input file
const input = fs.readFileSync(inputPath, 'utf-8');
const filename = path.basename(inputPath);
const firstLine = input.substring(0, input.indexOf('\n'));
const language = parseLanguage(firstLine);
const sourceType = parseSourceType(firstLine);
console.log(`Minimizing: ${inputPath}`);
const originalLines = input.split('\n').length;
// Run the minimization
const result = minimize(input, filename, language, sourceType);
if (result.kind === 'success') {
console.log('Could not minimize: the input compiles successfully.');
process.exit(0);
}
if (result.kind === 'minimal') {
console.log(
'Could not minimize: the input fails but is already minimal and cannot be reduced further.',
);
process.exit(0);
}
// Output the minimized code
console.log('--- Minimized Code ---');
console.log(result.source);
const minimizedLines = result.source.split('\n').length;
console.log(
`\nReduced from ${originalLines} lines to ${minimizedLines} lines`,
);
if (opts.update) {
fs.writeFileSync(inputPath, result.source, 'utf-8');
console.log(`\nUpdated ${inputPath} with minimized code.`);
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does runMinimizeCommand() do?
runMinimizeCommand() is a function in the react codebase, defined in compiler/packages/snap/src/runner.ts.
Where is runMinimizeCommand() defined?
runMinimizeCommand() is defined in compiler/packages/snap/src/runner.ts at line 158.
What does runMinimizeCommand() call?
runMinimizeCommand() calls 3 function(s): minimize, parseLanguage, parseSourceType.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free