fix(core): migrations not always migrating all files (#30269)
In an Angular CLI project scenario where projects only reference top-level source-files through the `tsconfig` `files` option, we currently do not migrate referenced source-files. This can be fixed checking all referenced source-files which aren't coming from an external library. This is similar to how `tslint` determines project source-files. PR Close #30269
This commit is contained in:
parent
6357d4a0d3
commit
349935a434
|
@ -53,10 +53,11 @@ function runInjectablePipeMigration(tree: Tree, tsconfigPath: string, basePath:
|
|||
const program = ts.createProgram(parsed.fileNames, parsed.options, host);
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const visitor = new InjectablePipeVisitor(typeChecker);
|
||||
const rootSourceFiles = program.getRootFileNames().map(f => program.getSourceFile(f) !);
|
||||
const sourceFiles = program.getSourceFiles().filter(
|
||||
f => !f.isDeclarationFile && !program.isSourceFileFromExternalLibrary(f));
|
||||
const printer = ts.createPrinter();
|
||||
|
||||
rootSourceFiles.forEach(sourceFile => visitor.visitNode(sourceFile));
|
||||
sourceFiles.forEach(sourceFile => visitor.visitNode(sourceFile));
|
||||
|
||||
visitor.missingInjectablePipes.forEach(data => {
|
||||
const {classDeclaration, importDeclarationMissingImport} = data;
|
||||
|
|
|
@ -54,10 +54,11 @@ function runMoveDocumentMigration(tree: Tree, tsconfigPath: string, basePath: st
|
|||
const program = ts.createProgram(parsed.fileNames, parsed.options, host);
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const visitor = new DocumentImportVisitor(typeChecker);
|
||||
const rootSourceFiles = program.getRootFileNames().map(f => program.getSourceFile(f) !);
|
||||
const sourceFiles = program.getSourceFiles().filter(
|
||||
f => !f.isDeclarationFile && !program.isSourceFileFromExternalLibrary(f));
|
||||
|
||||
// Analyze source files by finding imports.
|
||||
rootSourceFiles.forEach(sourceFile => visitor.visitNode(sourceFile));
|
||||
sourceFiles.forEach(sourceFile => visitor.visitNode(sourceFile));
|
||||
|
||||
const {importsMap} = visitor;
|
||||
|
||||
|
|
|
@ -117,7 +117,8 @@ function analyzeProject(tree: Tree, tsconfigPath: string, basePath: string):
|
|||
|
||||
const program = ts.createProgram(parsed.fileNames, parsed.options, host);
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const sourceFiles = program.getRootFileNames().map(f => program.getSourceFile(f) !);
|
||||
const sourceFiles = program.getSourceFiles().filter(
|
||||
f => !f.isDeclarationFile && !program.isSourceFileFromExternalLibrary(f));
|
||||
const queryVisitor = new NgQueryResolveVisitor(typeChecker);
|
||||
|
||||
// Analyze all project source-files and collect all queries that
|
||||
|
|
|
@ -60,10 +60,11 @@ function runTemplateVariableAssignmentCheck(
|
|||
const program = ts.createProgram(parsed.fileNames, parsed.options, host);
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const templateVisitor = new NgComponentTemplateVisitor(typeChecker);
|
||||
const rootSourceFiles = program.getRootFileNames().map(f => program.getSourceFile(f) !);
|
||||
const sourceFiles = program.getSourceFiles().filter(
|
||||
f => !f.isDeclarationFile && !program.isSourceFileFromExternalLibrary(f));
|
||||
|
||||
// Analyze source files by detecting HTML templates.
|
||||
rootSourceFiles.forEach(sourceFile => templateVisitor.visitNode(sourceFile));
|
||||
sourceFiles.forEach(sourceFile => templateVisitor.visitNode(sourceFile));
|
||||
|
||||
const {resolvedTemplates} = templateVisitor;
|
||||
const collectedFailures: string[] = [];
|
||||
|
|
Loading…
Reference in New Issue