Skip to content

Commit

Permalink
refactor(@schematics/angular): remove redundant standalone: true fr…
Browse files Browse the repository at this point in the history
…om templates

This is no longer needed.
  • Loading branch information
alan-agius4 committed Oct 24, 2024
1 parent 0a1f171 commit 113de21
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { RouterOutlet } from '@angular/router';<% } %>

@Component({
selector: '<%= selector %>',
standalone: true,
imports: [<% if(routing) { %>RouterOutlet<% } %>],<% if(inlineTemplate) { %>
template: `
<h1>Welcome to {{title}}!</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core';

@Component({<% if(!skipSelector) {%>
selector: '<%= selector %>',<%}%><% if(standalone) {%>
standalone: true,
imports: [],<%} else { %>
selector: '<%= selector %>',<%}%><% if(!standalone) {%>
standalone: false,
<% }%><% if(inlineTemplate) { %>
template: `
Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/component/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ describe('Component Schematic', () => {
const componentContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
expect(componentContent).toContain('class FooComponent');
expect(moduleContent).not.toContain('FooComponent');
expect(componentContent).toContain('standalone: true');
expect(componentContent).not.toContain('standalone');
});

it('should declare standalone components in the `imports` of a test', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[<%= selector %>]'<% if(standalone) {%>,
standalone: true<%} else {%>,
selector: '[<%= selector %>]'<% if(!standalone) {%>,
standalone: false<%}%>
})
export class <%= classify(name) %>Directive {
Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/directive/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('Directive Schematic', () => {
const options = { ...defaultOptions, standalone: true };
const tree = await schematicRunner.runSchematic('directive', options, appTree);
const directiveContent = tree.readContent('/projects/bar/src/app/foo.directive.ts');
expect(directiveContent).toContain('standalone: true');
expect(directiveContent).not.toContain('standalone');
expect(directiveContent).toContain('class FooDirective');
});

Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Library Schematic', () => {
it('should create a standalone component', async () => {
const tree = await schematicRunner.runSchematic('library', defaultOptions, workspaceTree);
const componentContent = tree.readContent('/projects/foo/src/lib/foo.component.ts');
expect(componentContent).toContain('standalone: true');
expect(componentContent).not.toContain('standalone');
});

describe('custom projectRoot', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: '<%= camelize(name) %>'<% if(standalone) {%>,
standalone: true<%} else {%>,
name: '<%= camelize(name) %>'<% if(!standalone) {%>,
standalone: false<%}%>
})
export class <%= classify(name) %>Pipe implements PipeTransform {
Expand Down

0 comments on commit 113de21

Please sign in to comment.