@@ -21,15 +21,12 @@ import {
21
21
url ,
22
22
} from '@angular-devkit/schematics' ;
23
23
import { 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' ;
26
24
import {
27
25
NodeDependencyType ,
28
26
addPackageJsonDependency ,
29
27
getPackageJsonDependency ,
30
28
} from '../utility/dependencies' ;
31
29
import { latestVersions } from '../utility/latest-versions' ;
32
- import { findBootstrapModulePath } from '../utility/ng-ast-utils' ;
33
30
import { relativePathToWorkspaceRoot } from '../utility/paths' ;
34
31
import { targetBuildNotFoundError } from '../utility/project-targets' ;
35
32
import { getWorkspace , updateWorkspace } from '../utility/workspace' ;
@@ -95,54 +92,6 @@ function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): R
95
92
} ) ;
96
93
}
97
94
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
-
146
95
function addDependencies ( ) : Rule {
147
96
return ( host : Tree ) => {
148
97
const coreDep = getPackageJsonDependency ( host , '@angular/core' ) ;
@@ -214,7 +163,6 @@ export default function (options: UniversalOptions): Rule {
214
163
mergeWith ( rootSource ) ,
215
164
addDependencies ( ) ,
216
165
updateConfigFile ( options , tsConfigDirectory ) ,
217
- addServerTransition ( options , clientBuildOptions . main , clientProject . root ) ,
218
166
] ) ;
219
167
} ;
220
168
}
0 commit comments