@@ -21,15 +21,12 @@ import {
2121 url ,
2222} from '@angular-devkit/schematics' ;
2323import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks' ;
24- import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript' ;
25- import { findNode , getDecoratorMetadata } from '../utility/ast-utils' ;
2624import {
2725 NodeDependencyType ,
2826 addPackageJsonDependency ,
2927 getPackageJsonDependency ,
3028} from '../utility/dependencies' ;
3129import { latestVersions } from '../utility/latest-versions' ;
32- import { findBootstrapModulePath } from '../utility/ng-ast-utils' ;
3330import { relativePathToWorkspaceRoot } from '../utility/paths' ;
3431import { targetBuildNotFoundError } from '../utility/project-targets' ;
3532import { getWorkspace , updateWorkspace } from '../utility/workspace' ;
@@ -95,54 +92,6 @@ function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): R
9592 } ) ;
9693}
9794
98- function findBrowserModuleImport ( host : Tree , modulePath : string ) : ts . Node {
99- const moduleFileText = host . readText ( modulePath ) ;
100- const source = ts . createSourceFile ( modulePath , moduleFileText , ts . ScriptTarget . Latest , true ) ;
101-
102- const decoratorMetadata = getDecoratorMetadata ( source , 'NgModule' , '@angular/core' ) [ 0 ] ;
103- const browserModuleNode = findNode ( decoratorMetadata , ts . SyntaxKind . Identifier , 'BrowserModule' ) ;
104-
105- if ( browserModuleNode === null ) {
106- throw new SchematicsException ( `Cannot find BrowserModule import in ${ modulePath } ` ) ;
107- }
108-
109- return browserModuleNode ;
110- }
111-
112- function addServerTransition (
113- options : UniversalOptions ,
114- mainFile : string ,
115- clientProjectRoot : string ,
116- ) : Rule {
117- return ( host : Tree ) => {
118- const mainPath = normalize ( '/' + mainFile ) ;
119-
120- const bootstrapModuleRelativePath = findBootstrapModulePath ( host , mainPath ) ;
121- const bootstrapModulePath = normalize (
122- `/${ clientProjectRoot } /src/${ bootstrapModuleRelativePath } .ts` ,
123- ) ;
124-
125- const browserModuleImport = findBrowserModuleImport ( host , bootstrapModulePath ) ;
126- const transitionCallRecorder = host . beginUpdate ( bootstrapModulePath ) ;
127- const position = browserModuleImport . pos + browserModuleImport . getFullWidth ( ) ;
128- const browserModuleFullImport = browserModuleImport . parent ;
129-
130- if ( browserModuleFullImport . getText ( ) === 'BrowserModule.withServerTransition' ) {
131- // Remove any existing withServerTransition as otherwise we might have incorrect configuration.
132- transitionCallRecorder . remove (
133- position ,
134- browserModuleFullImport . parent . getFullWidth ( ) - browserModuleImport . getFullWidth ( ) ,
135- ) ;
136- }
137-
138- transitionCallRecorder . insertLeft (
139- position ,
140- `.withServerTransition({ appId: '${ options . appId } ' })` ,
141- ) ;
142- host . commitUpdate ( transitionCallRecorder ) ;
143- } ;
144- }
145-
14695function addDependencies ( ) : Rule {
14796 return ( host : Tree ) => {
14897 const coreDep = getPackageJsonDependency ( host , '@angular/core' ) ;
@@ -214,7 +163,6 @@ export default function (options: UniversalOptions): Rule {
214163 mergeWith ( rootSource ) ,
215164 addDependencies ( ) ,
216165 updateConfigFile ( options , tsConfigDirectory ) ,
217- addServerTransition ( options , clientBuildOptions . main , clientProject . root ) ,
218166 ] ) ;
219167 } ;
220168}
0 commit comments