Skip to content

Commit 645c5a1

Browse files
committed
fix(@schematics/angular): remove setting files tsconfig field with SSR/Server generation
The `files` field within the `tsconfig.app.json` file is no longer used with the "solution" style tsconfig generated with applications. The SSR and server schematics no longer need to modify this field since all TS files within `src` are included by default.
1 parent 16244c0 commit 645c5a1

File tree

4 files changed

+1
-41
lines changed

4 files changed

+1
-41
lines changed

packages/schematics/angular/server/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ function updateConfigFileApplicationBuilder(options: ServerOptions): Rule {
119119
function 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) ?? []);

packages/schematics/angular/server/index_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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 () => {

packages/schematics/angular/ssr/index.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -138,29 +138,6 @@ function addScriptsRule({ project }: SSROptions, isUsingApplicationBuilder: bool
138138
};
139139
}
140140

141-
function updateApplicationBuilderTsConfigRule(options: SSROptions): Rule {
142-
return async (host) => {
143-
const workspace = await readWorkspace(host);
144-
const project = workspace.projects.get(options.project);
145-
const buildTarget = project?.targets.get('build');
146-
if (!buildTarget || !buildTarget.options) {
147-
return;
148-
}
149-
150-
const tsConfigPath = buildTarget.options.tsConfig;
151-
if (!tsConfigPath || typeof tsConfigPath !== 'string') {
152-
// No tsconfig path
153-
return;
154-
}
155-
156-
const json = new JSONFile(host, tsConfigPath);
157-
const filesPath = ['files'];
158-
const files = new Set((json.get(filesPath) as string[] | undefined) ?? []);
159-
files.add('src/server.ts');
160-
json.modify(filesPath, [...files]);
161-
};
162-
}
163-
164141
function updateApplicationBuilderWorkspaceConfigRule(
165142
projectSourceRoot: string,
166143
options: SSROptions,
@@ -372,10 +349,7 @@ export default function (options: SSROptions): Rule {
372349
skipInstall: true,
373350
}),
374351
...(usingApplicationBuilder
375-
? [
376-
updateApplicationBuilderWorkspaceConfigRule(sourceRoot, options, context),
377-
updateApplicationBuilderTsConfigRule(options),
378-
]
352+
? [updateApplicationBuilderWorkspaceConfigRule(sourceRoot, options, context)]
379353
: [
380354
updateWebpackBuilderServerTsConfigRule(options),
381355
updateWebpackBuilderWorkspaceConfigRule(sourceRoot, options),

packages/schematics/angular/ssr/index_spec.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,6 @@ describe('SSR Schematic', () => {
6969
expect(schematicRunner.tasks[0].name).toBe('node-package');
7070
expect((schematicRunner.tasks[0].options as { command: string }).command).toBe('install');
7171
});
72-
73-
it(`should update 'tsconfig.app.json' files with Express main file`, async () => {
74-
const tree = await schematicRunner.runSchematic('ssr', defaultOptions, appTree);
75-
const { files } = tree.readJson('/projects/test-app/tsconfig.app.json') as {
76-
files: string[];
77-
};
78-
79-
expect(files).toEqual(['src/main.ts', 'src/main.server.ts', 'src/server.ts']);
80-
});
8172
});
8273

8374
describe('standalone application', () => {

0 commit comments

Comments
 (0)