Skip to content

Commit

Permalink
feat(@schematics/angular): remove entryComponent from component s…
Browse files Browse the repository at this point in the history
…chematic

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.
  • Loading branch information
alan-agius4 authored and filipesilva committed Mar 31, 2021
1 parent 34aef32 commit 8582ddc
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 51 deletions.
25 changes: 1 addition & 24 deletions packages/schematics/angular/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
};
}
Expand Down
8 changes: 0 additions & 8 deletions packages/schematics/angular/component/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' };

Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
13 changes: 0 additions & 13 deletions packages/schematics/angular/utility/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 8582ddc

Please sign in to comment.