Introduces an update schematic for the "@angular/core" package that automatically migrates pre-V8 "ViewChild" and "ContentChild" queries to the new explicit timing syntax. This is not required yet, but with Ivy, queries will be "dynamic" by default. Therefore specifying an explicit query timing ensures that developers can smoothly migrate to Ivy (once it's the default). Read more about the explicit timing API here: https://github.com/angular/angular/pull/28810 PR Close #28983
30 lines
945 B
TypeScript
30 lines
945 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics';
|
|
import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths';
|
|
import {runStaticQueryMigration} from './migration';
|
|
|
|
/** Entry point for the V8 static-query migration. */
|
|
export default function(): Rule {
|
|
return (tree: Tree) => {
|
|
const projectTsConfigPaths = getProjectTsConfigPaths(tree);
|
|
const basePath = process.cwd();
|
|
|
|
if (!projectTsConfigPaths.length) {
|
|
throw new SchematicsException(
|
|
'Could not find any tsconfig file. Cannot migrate queries ' +
|
|
'to explicit timing.');
|
|
}
|
|
|
|
for (const tsconfigPath of projectTsConfigPaths) {
|
|
runStaticQueryMigration(tree, tsconfigPath, basePath);
|
|
}
|
|
};
|
|
}
|