Skip to content

Commit e90a808

Browse files
alan-agius4clydin
authored andcommitted
fix(@schematics/angular): include main.server.ts in tsconfig.files when present
Add logic to automatically include `main.server.ts` in the `files` array of the tsconfig when present during schematic execution. This ensures backwards compatibility for applications generated prior to version 19. Closes #30526 (cherry picked from commit c437111)
1 parent 0371f9a commit e90a808

File tree

1 file changed

+8
-0
lines changed
  • packages/schematics/angular/server

1 file changed

+8
-0
lines changed

packages/schematics/angular/server/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ function updateConfigFileApplicationBuilder(options: ServerOptions): Rule {
119119
function updateTsConfigFile(tsConfigPath: string): Rule {
120120
return (host: Tree) => {
121121
const json = new JSONFile(host, tsConfigPath);
122+
// Skip adding the files entry if the server entry would already be included.
123+
const include = json.get(['include']);
124+
if (!Array.isArray(include) || !include.includes('src/**/*.ts')) {
125+
const filesPath = ['files'];
126+
const files = new Set((json.get(filesPath) as string[] | undefined) ?? []);
127+
files.add('src/' + serverMainEntryName);
128+
json.modify(filesPath, [...files]);
129+
}
122130

123131
const typePath = ['compilerOptions', 'types'];
124132
const types = new Set((json.get(typePath) as string[] | undefined) ?? []);

0 commit comments

Comments
 (0)