Skip to content

Feature/bug - standalone migration should provide progress output for long-running operations #62788

@tomer953

Description

@tomer953

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

When running the standalone migration on a large codebase (6000+ components), the CLI outputs nothing to the console until the migration is complete. This can take over an hour, which creates confusion and leads developers to think the process is stuck or broken.

Proposed solution

Add console.log() or context.logger.info() calls throughout the migration steps — especially before and after analyzing components and after migrating each batch.

function toStandalone(sourceFiles, program, printer, fileImportRemapper, declarationImportRemapper) {    
    logWithTimestamp('Starting standalone migration process');
    const templateTypeChecker = program.compiler.getTemplateTypeChecker();
    const typeChecker = program.getTsProgram().getTypeChecker();
    const modulesToMigrate = new Set();
    const testObjectsToMigrate = new Set();
    const declarations = new Set();
    const tracker = new compiler_host.ChangeTracker(printer, fileImportRemapper);
    
    logWithTimestamp(`Processing ${sourceFiles.length} source files`);
    let fileCounter = 0;
    
    for (const sourceFile of sourceFiles) {
        fileCounter++;
        logWithTimestamp(`[${fileCounter}/${sourceFiles.length}] Processing sourceFile:`, sourceFile.fileName);
        
        const modules = findNgModuleClassesToMigrate(sourceFile, typeChecker);
        logWithTimestamp(`Found ${modules.length} NgModule classes to migrate in ${sourceFile.fileName}`);
        
        const testObjects = findTestObjectsToMigrate(sourceFile, typeChecker);
        logWithTimestamp(`Found ${testObjects.size || 0} test objects to migrate in ${sourceFile.fileName}`);
        
        for (const module of modules) {
            logWithTimestamp(`Processing module: ${module.name?.escapedText || 'unnamed module'}`);
            
            const allModuleDeclarations = extractDeclarationsFromModule(module, templateTypeChecker);
            logWithTimestamp(`Extracted ${allModuleDeclarations.length} declarations from module ${module.name?.escapedText || 'unnamed'}`);
            
            const unbootstrappedDeclarations = filterNonBootstrappedDeclarations(allModuleDeclarations, module, templateTypeChecker, typeChecker);
            logWithTimestamp(`Found ${unbootstrappedDeclarations.length} unbootstrapped declarations in ${module.name?.escapedText || 'unnamed'}`);
            
            if (unbootstrappedDeclarations.length > 0) {
                modulesToMigrate.add(module);
                logWithTimestamp(`Added module to migrate: ${module.name?.escapedText || 'unnamed'}`);
                
                unbootstrappedDeclarations.forEach((decl) => {
                    declarations.add(decl);
                    logWithTimestamp(`Added declaration to migrate: ${decl.name?.escapedText || 'unnamed declaration'}`);
                });
            }
        }
        
        if (testObjects.size > 0) {
            logWithTimestamp(`Adding ${testObjects.size} test objects to migrate`);
            testObjects.forEach((obj) => testObjectsToMigrate.add(obj));
        }
    }
    
    logWithTimestamp(`Starting conversion of ${declarations.size} declarations to standalone`);
    let declarationCounter = 0;
    
    for (const declaration of declarations) {
        declarationCounter++;
        logWithTimestamp(`[${declarationCounter}/${declarations.size}] Converting declaration to standalone: ${declaration.name?.escapedText || 'unnamed declaration'}`);
        convertNgModuleDeclarationToStandalone(declaration, declarations, tracker, templateTypeChecker, declarationImportRemapper);
    }
    
    logWithTimestamp(`Starting migration of ${modulesToMigrate.size} NgModule classes`);
    let moduleCounter = 0;
    
    for (const node of modulesToMigrate) {
        moduleCounter++;
        logWithTimestamp(`[${moduleCounter}/${modulesToMigrate.size}] Migrating NgModule class: ${node.name?.escapedText || 'unnamed module'}`);
        migrateNgModuleClass(node, declarations, tracker, typeChecker, templateTypeChecker);
    }
    
    logWithTimestamp(`Starting migration of ${testObjectsToMigrate.size} test declarations`);
    migrateTestDeclarations(testObjectsToMigrate, declarations, tracker, templateTypeChecker, typeChecker);
    
    logWithTimestamp('Standalone migration process completed');
    return tracker.recordChanges();
}

Alternatives considered

.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: migrationsIssues related to `ng update`/`ng generate` migrations

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy