Skip to content

Commit f5b5b79

Browse files
crisbetoangular-robot[bot]
authored andcommitted
refactor(material/schematics): simplify standalone app detection
Updates the `ng add` schematic to simplify the way we detect standalone apps.
1 parent 15040fb commit f5b5b79

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/material/schematics/ng-add/setup-project.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {
1414
getProjectMainFile,
1515
getProjectStyleFile,
1616
hasNgModuleImport,
17+
isStandaloneApp,
1718
} from '@angular/cdk/schematics';
1819
import {
1920
importsProvidersFrom,
20-
findBootstrapApplicationCall,
2121
addFunctionalProvidersToStandaloneBootstrap,
2222
callsProvidersFunction,
2323
} from '@schematics/angular/private/components';
@@ -26,7 +26,6 @@ import {ProjectType} from '@schematics/angular/utility/workspace-models';
2626
import {addFontsToIndex} from './fonts/material-fonts';
2727
import {Schema} from './schema';
2828
import {addThemeToAppStyles, addTypographyClass} from './theming/theming';
29-
import * as ts from 'typescript';
3029

3130
/**
3231
* Scaffolds the basics of a Angular Material application, this includes:
@@ -68,13 +67,8 @@ function addAnimationsModule(options: Schema) {
6867
const workspace = await getWorkspace(host);
6968
const project = getProjectFromWorkspace(workspace, options.project);
7069
const mainFilePath = getProjectMainFile(project);
71-
const mainSourceFile = ts.createSourceFile(
72-
mainFilePath,
73-
host.readText(mainFilePath),
74-
ts.ScriptTarget.Latest,
75-
);
7670

77-
if (findBootstrapApplicationCall(mainSourceFile)) {
71+
if (isStandaloneApp(host, mainFilePath)) {
7872
addAnimationsToStandaloneApp(host, mainFilePath, context, options);
7973
} else {
8074
addAnimationsToNonStandaloneApp(host, project, mainFilePath, context, options);

0 commit comments

Comments
 (0)