File tree Expand file tree Collapse file tree 6 files changed +37
-9
lines changed
packages/schematics/angular Expand file tree Collapse file tree 6 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,18 @@ describe('Application Schematic', () => {
110110 expect ( _extends ) . toBe ( '../../tsconfig.json' ) ;
111111 } ) ;
112112
113+ it ( 'should add project references in the root tsconfig.json' , async ( ) => {
114+ const tree = await schematicRunner . runSchematic ( 'application' , defaultOptions , workspaceTree ) ;
115+
116+ const { references } = readJsonFile ( tree , '/tsconfig.json' ) ;
117+ expect ( references ) . toContain (
118+ jasmine . objectContaining ( { path : 'projects/foo/tsconfig.app.json' } ) ,
119+ ) ;
120+ expect ( references ) . toContain (
121+ jasmine . objectContaining ( { path : 'projects/foo/tsconfig.spec.json' } ) ,
122+ ) ;
123+ } ) ;
124+
113125 it ( 'should install npm dependencies when `skipInstall` is false' , async ( ) => {
114126 await schematicRunner . runSchematic (
115127 'application' ,
Original file line number Diff line number Diff line change @@ -119,10 +119,6 @@ function updateConfigFileApplicationBuilder(options: ServerOptions): Rule {
119119function updateTsConfigFile ( tsConfigPath : string ) : Rule {
120120 return ( host : Tree ) => {
121121 const json = new JSONFile ( host , tsConfigPath ) ;
122- const filesPath = [ 'files' ] ;
123- const files = new Set ( ( json . get ( filesPath ) as string [ ] | undefined ) ?? [ ] ) ;
124- files . add ( 'src/' + serverMainEntryName ) ;
125- json . modify ( filesPath , [ ...files ] ) ;
126122
127123 const typePath = [ 'compilerOptions' , 'types' ] ;
128124 const types = new Set ( ( json . get ( typePath ) as string [ ] | undefined ) ?? [ ] ) ;
Original file line number Diff line number Diff line change @@ -167,7 +167,6 @@ describe('Server Schematic', () => {
167167 const filePath = '/projects/bar/tsconfig.app.json' ;
168168 const contents = parseJson ( tree . readContent ( filePath ) . toString ( ) ) ;
169169 expect ( contents . compilerOptions . types ) . toEqual ( [ 'node' ] ) ;
170- expect ( contents . files ) . toEqual ( [ 'src/main.ts' , 'src/main.server.ts' ] ) ;
171170 } ) ;
172171
173172 it ( `should add 'provideClientHydration' to the providers list` , async ( ) => {
Original file line number Diff line number Diff line change @@ -154,6 +154,13 @@ function updateApplicationBuilderTsConfigRule(options: SSROptions): Rule {
154154 }
155155
156156 const json = new JSONFile ( host , tsConfigPath ) ;
157+
158+ // Skip adding the files entry if the server entry would already be included
159+ const include = json . get ( [ 'include' ] ) ;
160+ if ( Array . isArray ( include ) && include . includes ( 'src/**/*.ts' ) ) {
161+ return ;
162+ }
163+
157164 const filesPath = [ 'files' ] ;
158165 const files = new Set ( ( json . get ( filesPath ) as string [ ] | undefined ) ?? [ ] ) ;
159166 files . add ( 'src/server.ts' ) ;
Original file line number Diff line number Diff line change @@ -70,13 +70,28 @@ describe('SSR Schematic', () => {
7070 expect ( ( schematicRunner . tasks [ 0 ] . options as { command : string } ) . command ) . toBe ( 'install' ) ;
7171 } ) ;
7272
73- it ( `should update 'tsconfig.app.json' files with Express main file` , async ( ) => {
73+ it ( `should not update 'tsconfig.app.json' files with Express main file already included ` , async ( ) => {
7474 const tree = await schematicRunner . runSchematic ( 'ssr' , defaultOptions , appTree ) ;
7575 const { files } = tree . readJson ( '/projects/test-app/tsconfig.app.json' ) as {
7676 files : string [ ] ;
7777 } ;
7878
79- expect ( files ) . toEqual ( [ 'src/main.ts' , 'src/main.server.ts' , 'src/server.ts' ] ) ;
79+ expect ( files ) . toBeUndefined ( ) ;
80+ } ) ;
81+
82+ it ( `should update 'tsconfig.app.json' files with Express main file if not included` , async ( ) => {
83+ const appTsConfigContent = appTree . readJson ( '/projects/test-app/tsconfig.app.json' ) as {
84+ include ?: string [ ] ;
85+ } ;
86+ appTsConfigContent . include = [ ] ;
87+ appTree . overwrite ( '/projects/test-app/tsconfig.app.json' , JSON . stringify ( appTsConfigContent ) ) ;
88+
89+ const tree = await schematicRunner . runSchematic ( 'ssr' , defaultOptions , appTree ) ;
90+ const { files } = tree . readJson ( '/projects/test-app/tsconfig.app.json' ) as {
91+ files : string [ ] ;
92+ } ;
93+
94+ expect ( files ) . toContain ( 'src/server.ts' ) ;
8095 } ) ;
8196 } ) ;
8297
Original file line number Diff line number Diff line change 22/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
33{
44 "compileOnSave": false,
5- "compilerOptions": {
6- "outDir": "./dist/out-tsc",<% if (strict) { %>
5+ "compilerOptions": {<% if (strict) { %>
76 "strict": true,
87 "noImplicitOverride": true,
98 "noPropertyAccessFromIndexSignature": true,
You can’t perform that action at this time.
0 commit comments