mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(migrations): flip the default standalone flag in route-lazy-loading migration (#58474)
Before v19, the default value of the standalone flag was false, this code change flips the logic in the migration to make it true by default. PR Close #58474
This commit is contained in:
parent
86d8f6bda8
commit
c5e676bb87
2 changed files with 18 additions and 2 deletions
|
|
@ -23,7 +23,11 @@ export function isStandaloneComponent(node: ts.ClassDeclaration): boolean {
|
|||
const arg = decorator.expression.arguments[0];
|
||||
if (ts.isObjectLiteralExpression(arg)) {
|
||||
const property = findLiteralProperty(arg, 'standalone') as ts.PropertyAssignment;
|
||||
return property ? property.initializer.getText() === 'true' : false;
|
||||
if (property) {
|
||||
return property.initializer.getText() === 'true';
|
||||
} else {
|
||||
return true; // standalone is true by default in v19
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -335,11 +335,13 @@ describe('route lazy loading migration', () => {
|
|||
import {NgModule} from '@angular/core';
|
||||
import {provideRoutes} from '@angular/router';
|
||||
import {TestComponent} from './test';
|
||||
import {StandaloneByDefaultComponent} from './standalone-by-default';
|
||||
import {NotStandaloneComponent} from './not-standalone';
|
||||
|
||||
const routes = [
|
||||
{path: 'test', component: TestComponent},
|
||||
{path: 'test1', component: NotStandaloneComponent},
|
||||
{path: 'test2', component: StandaloneByDefaultComponent},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
@ -358,11 +360,20 @@ describe('route lazy loading migration', () => {
|
|||
`,
|
||||
);
|
||||
|
||||
writeFile(
|
||||
'standalone-by-default.ts',
|
||||
`
|
||||
import {Component} from '@angular/core';
|
||||
@Component({template: 'hello'})
|
||||
export class StandaloneByDefaultComponent {}
|
||||
`,
|
||||
);
|
||||
|
||||
writeFile(
|
||||
'not-standalone.ts',
|
||||
`
|
||||
import {Component, NgModule} from '@angular/core';
|
||||
@Component({template: 'hello'})
|
||||
@Component({template: 'hello', standalone: false})
|
||||
export class NotStandaloneComponent {}
|
||||
|
||||
@NgModule({declarations: [NotStandaloneComponent], exports: [NotStandaloneComponent]})
|
||||
|
|
@ -381,6 +392,7 @@ describe('route lazy loading migration', () => {
|
|||
const routes = [
|
||||
{path: 'test', loadComponent: () => import('./test').then(m => m.TestComponent)},
|
||||
{path: 'test1', component: NotStandaloneComponent},
|
||||
{path: 'test2', loadComponent: () => import('./standalone-by-default').then(m => m.StandaloneByDefaultComponent)},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
|
|||
Loading…
Reference in a new issue