Skip to content

Commit 345e737

Browse files
crisbetothePunderWoman
authored andcommitted
feat(core): add ng generate schematic to convert to standalone bootstrapping APIs (#48848)
Adds a new mode to the `@angular/core:standalone` schematic that allows users to switch from `bootstrapModule` to `bootstrapApplication`, as well as `provideRouter`, `provideAnimations` and `provideNoopAnimations`. PR Close #48848
1 parent 04e0ac3 commit 345e737

File tree

4 files changed

+1271
-1
lines changed

4 files changed

+1271
-1
lines changed

packages/core/schematics/ng-generate/standalone-migration/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths';
1616
import {canMigrateFile, createProgramOptions} from '../../utils/typescript/compiler_host';
1717

1818
import {pruneNgModules} from './prune-modules';
19+
import {toStandaloneBootstrap} from './standalone-bootstrap';
1920
import {toStandalone} from './to-standalone';
2021
import {ChangesByFile} from './util';
2122

2223
enum MigrationMode {
2324
toStandalone = 'convert-to-standalone',
2425
pruneModules = 'prune-ng-modules',
26+
standaloneBootstrap = 'standalone-bootstrap',
2527
}
2628

2729
interface Options {
@@ -89,6 +91,9 @@ function standaloneMigration(tree: Tree, tsconfigPath: string, basePath: string,
8991
const result = pruneNgModules(program, host, basePath, rootNames, sourceFiles, printer);
9092
pendingChanges = result.pendingChanges;
9193
filesToRemove = result.filesToRemove;
94+
} else if (options.mode === MigrationMode.standaloneBootstrap) {
95+
pendingChanges =
96+
toStandaloneBootstrap(program, host, basePath, rootNames, sourceFiles, printer);
9297
} else {
9398
/** MigrationMode.toStandalone */
9499
pendingChanges = toStandalone(sourceFiles, program, printer);

packages/core/schematics/ng-generate/standalone-migration/schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"mode": {
88
"description": "Operation that should be performed by the migrator",
99
"type": "string",
10-
"enum": ["convert-to-standalone", "prune-ng-modules"],
10+
"enum": ["convert-to-standalone", "prune-ng-modules", "standalone-bootstrap"],
1111
"default": "convert-to-standalone",
1212
"x-prompt": {
1313
"message": "Choose the type of migration:",
@@ -20,6 +20,10 @@
2020
{
2121
"value": "prune-ng-modules",
2222
"label": "Remove unnecessary NgModule classes"
23+
},
24+
{
25+
"value": "standalone-bootstrap",
26+
"label": "Bootstrap the application using standalone APIs"
2327
}
2428
]
2529
}

0 commit comments

Comments
 (0)