Skip to content

Commit 8582ddc

Browse files
alan-agius4filipesilva
authored andcommitted
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.
1 parent 34aef32 commit 8582ddc

File tree

4 files changed

+1
-51
lines changed

4 files changed

+1
-51
lines changed

packages/schematics/angular/component/index.ts

+1-24
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import {
2222
url,
2323
} from '@angular-devkit/schematics';
2424
import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript';
25-
import {
26-
addDeclarationToModule,
27-
addEntryComponentToModule,
28-
addExportToModule,
29-
} from '../utility/ast-utils';
25+
import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils';
3026
import { InsertChange } from '../utility/change';
3127
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
3228
import { applyLintFix } from '../utility/lint-fix';
@@ -93,25 +89,6 @@ function addDeclarationToNgModule(options: ComponentOptions): Rule {
9389
host.commitUpdate(exportRecorder);
9490
}
9591

96-
if (options.entryComponent) {
97-
// Need to refresh the AST because we overwrote the file in the host.
98-
const source = readIntoSourceFile(host, modulePath);
99-
100-
const entryComponentRecorder = host.beginUpdate(modulePath);
101-
const entryComponentChanges = addEntryComponentToModule(
102-
source, modulePath,
103-
strings.classify(options.name) + strings.classify(options.type),
104-
relativePath);
105-
106-
for (const change of entryComponentChanges) {
107-
if (change instanceof InsertChange) {
108-
entryComponentRecorder.insertLeft(change.pos, change.toAdd);
109-
}
110-
}
111-
host.commitUpdate(entryComponentRecorder);
112-
}
113-
114-
11592
return host;
11693
};
11794
}

packages/schematics/angular/component/index_spec.ts

-8
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,6 @@ describe('Component Schematic', () => {
148148
expect(appModuleContent).toMatch(/exports: \[\n(\s*) FooComponent\n\1\]/);
149149
});
150150

151-
it('should set the entry component', async () => {
152-
const options = { ...defaultOptions, entryComponent: true };
153-
154-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
155-
const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
156-
expect(appModuleContent).toMatch(/entryComponents: \[\n(\s*) FooComponent\n\1\]/);
157-
});
158-
159151
it('should import into a specified module', async () => {
160152
const options = { ...defaultOptions, module: 'app.module.ts' };
161153

packages/schematics/angular/component/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,6 @@
132132
"description": "The declaring NgModule exports this component.",
133133
"x-user-analytics": 19
134134
},
135-
"entryComponent": {
136-
"type": "boolean",
137-
"default": false,
138-
"description": "The new component is the entry component of the declaring NgModule.",
139-
"x-deprecated": "Since version 9.0.0 with Ivy, entryComponents is no longer necessary."
140-
},
141135
"lintFix": {
142136
"type": "boolean",
143137
"description": "Apply lint fixes after generating the component.",

packages/schematics/angular/utility/ast-utils.ts

-13
Original file line numberDiff line numberDiff line change
@@ -488,19 +488,6 @@ export function addBootstrapToModule(source: ts.SourceFile,
488488
return addSymbolToNgModuleMetadata(source, modulePath, 'bootstrap', classifiedName, importPath);
489489
}
490490

491-
/**
492-
* Custom function to insert an entryComponent into NgModule. It also imports it.
493-
* @deprecated - Since version 9.0.0 with Ivy, entryComponents is no longer necessary.
494-
*/
495-
export function addEntryComponentToModule(source: ts.SourceFile,
496-
modulePath: string, classifiedName: string,
497-
importPath: string): Change[] {
498-
return addSymbolToNgModuleMetadata(
499-
source, modulePath,
500-
'entryComponents', classifiedName, importPath,
501-
);
502-
}
503-
504491
/**
505492
* Determine if an import already exists.
506493
*/

0 commit comments

Comments
 (0)