@@ -27,9 +27,9 @@ import {
27
27
} from '../utility/ast-utils' ;
28
28
import { applyToUpdateRecorder } from '../utility/change' ;
29
29
import { getAppModulePath , isStandaloneApp } from '../utility/ng-ast-utils' ;
30
+ import { isUsingApplicationBuilder , targetBuildNotFoundError } from '../utility/project-targets' ;
30
31
import { findBootstrapApplicationCall , getMainFilePath } from '../utility/standalone/util' ;
31
- import { getWorkspace , updateWorkspace } from '../utility/workspace' ;
32
- import { Builders } from '../utility/workspace-models' ;
32
+ import { getWorkspace } from '../utility/workspace' ;
33
33
import { Schema as AppShellOptions } from './schema' ;
34
34
35
35
const APP_SHELL_ROUTE = 'shell' ;
@@ -156,29 +156,6 @@ function getMetadataProperty(metadata: ts.Node, propertyName: string): ts.Proper
156
156
return property ;
157
157
}
158
158
159
- function addAppShellConfigToWorkspace ( options : AppShellOptions ) : Rule {
160
- return updateWorkspace ( ( workspace ) => {
161
- const project = workspace . projects . get ( options . project ) ;
162
- if ( ! project ) {
163
- return ;
164
- }
165
- const buildTarget = project . targets . get ( 'build' ) ;
166
- if (
167
- buildTarget ?. builder === Builders . Application ||
168
- buildTarget ?. builder === Builders . BuildApplication
169
- ) {
170
- // Application builder configuration.
171
- const prodConfig = buildTarget . configurations ?. production ;
172
- if ( ! prodConfig ) {
173
- throw new SchematicsException (
174
- `A "production" configuration is not defined for the "build" builder.` ,
175
- ) ;
176
- }
177
- prodConfig . appShell = true ;
178
- }
179
- } ) ;
180
- }
181
-
182
159
function addServerRoutes ( options : AppShellOptions ) : Rule {
183
160
return async ( host : Tree ) => {
184
161
// The workspace gets updated so this needs to be reloaded
@@ -359,17 +336,21 @@ export default function (options: AppShellOptions): Rule {
359
336
const browserEntryPoint = await getMainFilePath ( tree , options . project ) ;
360
337
const isStandalone = isStandaloneApp ( tree , browserEntryPoint ) ;
361
338
339
+ const workspace = await getWorkspace ( tree ) ;
340
+ const project = workspace . projects . get ( options . project ) ;
341
+ if ( ! project ) {
342
+ throw targetBuildNotFoundError ( ) ;
343
+ }
344
+
362
345
return chain ( [
363
346
validateProject ( browserEntryPoint ) ,
364
347
schematic ( 'server' , options ) ,
365
- ...( options . serverRouting
348
+ ...( isUsingApplicationBuilder ( project )
366
349
? [ noop ( ) ]
367
350
: isStandalone
368
351
? [ addStandaloneServerRoute ( options ) ]
369
352
: [ addServerRoutes ( options ) ] ) ,
370
- options . serverRouting
371
- ? addServerRoutingConfig ( options , isStandalone )
372
- : addAppShellConfigToWorkspace ( options ) ,
353
+ addServerRoutingConfig ( options , isStandalone ) ,
373
354
schematic ( 'component' , {
374
355
name : 'app-shell' ,
375
356
module : 'app.module.server.ts' ,
0 commit comments