mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 10:33:43 +08:00
feat(@schematics/angular): remove entryComponent
from component
schematic
BREAKING CHANGE: `entryComponent` option has been removed from the `component` schematic as this was intended to be used with the the now no longer supported ViewEngine rendering engine.
This commit is contained in:
parent
34aef32f77
commit
8582ddc35e
@ -22,11 +22,7 @@ import {
|
||||
url,
|
||||
} from '@angular-devkit/schematics';
|
||||
import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript';
|
||||
import {
|
||||
addDeclarationToModule,
|
||||
addEntryComponentToModule,
|
||||
addExportToModule,
|
||||
} from '../utility/ast-utils';
|
||||
import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils';
|
||||
import { InsertChange } from '../utility/change';
|
||||
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
|
||||
import { applyLintFix } from '../utility/lint-fix';
|
||||
@ -93,25 +89,6 @@ function addDeclarationToNgModule(options: ComponentOptions): Rule {
|
||||
host.commitUpdate(exportRecorder);
|
||||
}
|
||||
|
||||
if (options.entryComponent) {
|
||||
// Need to refresh the AST because we overwrote the file in the host.
|
||||
const source = readIntoSourceFile(host, modulePath);
|
||||
|
||||
const entryComponentRecorder = host.beginUpdate(modulePath);
|
||||
const entryComponentChanges = addEntryComponentToModule(
|
||||
source, modulePath,
|
||||
strings.classify(options.name) + strings.classify(options.type),
|
||||
relativePath);
|
||||
|
||||
for (const change of entryComponentChanges) {
|
||||
if (change instanceof InsertChange) {
|
||||
entryComponentRecorder.insertLeft(change.pos, change.toAdd);
|
||||
}
|
||||
}
|
||||
host.commitUpdate(entryComponentRecorder);
|
||||
}
|
||||
|
||||
|
||||
return host;
|
||||
};
|
||||
}
|
||||
|
@ -148,14 +148,6 @@ describe('Component Schematic', () => {
|
||||
expect(appModuleContent).toMatch(/exports: \[\n(\s*) FooComponent\n\1\]/);
|
||||
});
|
||||
|
||||
it('should set the entry component', async () => {
|
||||
const options = { ...defaultOptions, entryComponent: true };
|
||||
|
||||
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
||||
const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
|
||||
expect(appModuleContent).toMatch(/entryComponents: \[\n(\s*) FooComponent\n\1\]/);
|
||||
});
|
||||
|
||||
it('should import into a specified module', async () => {
|
||||
const options = { ...defaultOptions, module: 'app.module.ts' };
|
||||
|
||||
|
@ -132,12 +132,6 @@
|
||||
"description": "The declaring NgModule exports this component.",
|
||||
"x-user-analytics": 19
|
||||
},
|
||||
"entryComponent": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "The new component is the entry component of the declaring NgModule.",
|
||||
"x-deprecated": "Since version 9.0.0 with Ivy, entryComponents is no longer necessary."
|
||||
},
|
||||
"lintFix": {
|
||||
"type": "boolean",
|
||||
"description": "Apply lint fixes after generating the component.",
|
||||
|
@ -488,19 +488,6 @@ export function addBootstrapToModule(source: ts.SourceFile,
|
||||
return addSymbolToNgModuleMetadata(source, modulePath, 'bootstrap', classifiedName, importPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom function to insert an entryComponent into NgModule. It also imports it.
|
||||
* @deprecated - Since version 9.0.0 with Ivy, entryComponents is no longer necessary.
|
||||
*/
|
||||
export function addEntryComponentToModule(source: ts.SourceFile,
|
||||
modulePath: string, classifiedName: string,
|
||||
importPath: string): Change[] {
|
||||
return addSymbolToNgModuleMetadata(
|
||||
source, modulePath,
|
||||
'entryComponents', classifiedName, importPath,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an import already exists.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user