Skip to content

Commit 9c2a52d

Browse files
committed
fix(@schematics/angular): fix universal tsconfig paths
Fix angular/angular-cli#10343
1 parent 465414a commit 9c2a52d

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

packages/schematics/angular/universal/files/__tsconfigFileName__.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "./<%= tsConfigExtends %>",
33
"compilerOptions": {
44
"outDir": "<%= outDir %>-server",
5-
"baseUrl": "./",
6-
"module": "commonjs",
7-
"types": []
5+
"module": "commonjs"
86
},
9-
"exclude": [
10-
"test.ts",
11-
"**/*.spec.ts"
12-
],
137
"angularCompilerOptions": {
148
"entryModule": "<%= appDir %>/<%= stripTsExtension(rootModuleFileName) %>#<%= rootModuleClassName %>"
159
}

packages/schematics/angular/universal/index.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonObject, experimental, normalize, parseJson, strings } from '@angular-devkit/core';
8+
import {
9+
JsonObject,
10+
basename,
11+
experimental,
12+
normalize,
13+
parseJson,
14+
strings,
15+
} from '@angular-devkit/core';
916
import {
1017
Rule,
1118
SchematicContext,
@@ -197,12 +204,14 @@ export default function (options: UniversalOptions): Rule {
197204
const clientProject = getClientProject(host, options);
198205
const clientArchitect = getClientArchitect(host, options);
199206
const outDir = getTsConfigOutDir(host, clientArchitect);
207+
const tsConfigExtends = basename(clientArchitect.build.options.tsConfig);
200208
const templateSource = apply(url('./files'), [
201209
template({
202210
...strings,
203211
...options as object,
204212
stripTsExtension: (s: string) => { return s.replace(/\.ts$/, ''); },
205213
outDir,
214+
tsConfigExtends,
206215
}),
207216
move(clientProject.root),
208217
]);

packages/schematics/angular/universal/index_spec.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,16 @@ describe('Universal Schematic', () => {
6262
const filePath = '/projects/bar/tsconfig.server.json';
6363
expect(tree.exists(filePath)).toEqual(true);
6464
const contents = tree.readContent(filePath);
65-
expect(contents).toMatch('../../out-tsc/app-server');
65+
expect(JSON.parse(contents)).toEqual({
66+
extends: './tsconfig.app.json',
67+
compilerOptions: {
68+
outDir: '../../out-tsc/app-server',
69+
module: 'commonjs',
70+
},
71+
angularCompilerOptions: {
72+
entryModule: 'src/app/app.server.module#AppServerModule',
73+
},
74+
});
6675
});
6776

6877
it('should add dependency: @angular/platform-server', () => {

packages/schematics/angular/universal/schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"type": "string",
4141
"format": "path",
4242
"description": "The name of the application directory.",
43-
"default": "app"
43+
"default": "src/app"
4444
},
4545
"rootModuleFileName": {
4646
"type": "string",

0 commit comments

Comments
 (0)