File tree 6 files changed +37
-9
lines changed
packages/schematics/angular
6 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,18 @@ describe('Application Schematic', () => {
110
110
expect ( _extends ) . toBe ( '../../tsconfig.json' ) ;
111
111
} ) ;
112
112
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
+
113
125
it ( 'should install npm dependencies when `skipInstall` is false' , async ( ) => {
114
126
await schematicRunner . runSchematic (
115
127
'application' ,
Original file line number Diff line number Diff line change @@ -119,10 +119,6 @@ function updateConfigFileApplicationBuilder(options: ServerOptions): Rule {
119
119
function updateTsConfigFile ( tsConfigPath : string ) : Rule {
120
120
return ( host : Tree ) => {
121
121
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 ] ) ;
126
122
127
123
const typePath = [ 'compilerOptions' , 'types' ] ;
128
124
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', () => {
167
167
const filePath = '/projects/bar/tsconfig.app.json' ;
168
168
const contents = parseJson ( tree . readContent ( filePath ) . toString ( ) ) ;
169
169
expect ( contents . compilerOptions . types ) . toEqual ( [ 'node' ] ) ;
170
- expect ( contents . files ) . toEqual ( [ 'src/main.ts' , 'src/main.server.ts' ] ) ;
171
170
} ) ;
172
171
173
172
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 {
154
154
}
155
155
156
156
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
+
157
164
const filesPath = [ 'files' ] ;
158
165
const files = new Set ( ( json . get ( filesPath ) as string [ ] | undefined ) ?? [ ] ) ;
159
166
files . add ( 'src/server.ts' ) ;
Original file line number Diff line number Diff line change @@ -70,13 +70,28 @@ describe('SSR Schematic', () => {
70
70
expect ( ( schematicRunner . tasks [ 0 ] . options as { command : string } ) . command ) . toBe ( 'install' ) ;
71
71
} ) ;
72
72
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 ( ) => {
74
74
const tree = await schematicRunner . runSchematic ( 'ssr' , defaultOptions , appTree ) ;
75
75
const { files } = tree . readJson ( '/projects/test-app/tsconfig.app.json' ) as {
76
76
files : string [ ] ;
77
77
} ;
78
78
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' ) ;
80
95
} ) ;
81
96
} ) ;
82
97
Original file line number Diff line number Diff line change 2
2
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
3
{
4
4
"compileOnSave": false,
5
- "compilerOptions": {
6
- "outDir": "./dist/out-tsc",<% if (strict) { %>
5
+ "compilerOptions": {<% if (strict) { %>
7
6
"strict": true,
8
7
"noImplicitOverride": true,
9
8
"noPropertyAccessFromIndexSignature": true,
You can’t perform that action at this time.
0 commit comments