Skip to content

Commit 419b5c1

Browse files
committed
fix(@schematics/angular): remove baseUrl from tsconfig.json
The `baseUrl` is no longer needed since NGCC has been removed. This also enables better auto-import suggestions. Closes #18834
1 parent dc6b6ea commit 419b5c1

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

packages/schematics/angular/library/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export default function (options: LibraryOptions): Rule {
164164
mergeWith(templateSource),
165165
addLibToWorkspaceFile(options, libDir, packageName),
166166
options.skipPackageJson ? noop() : addDependenciesToPackageJson(),
167-
options.skipTsConfig ? noop() : updateTsConfig(packageName, distRoot),
167+
options.skipTsConfig ? noop() : updateTsConfig(packageName, './' + distRoot),
168168
options.standalone
169169
? noop()
170170
: schematic('module', {

packages/schematics/angular/library/index_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ describe('Library Schematic', () => {
266266
const tree = await schematicRunner.runSchematic('library', defaultOptions, workspaceTree);
267267

268268
const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json');
269-
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['dist/foo']);
269+
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['./dist/foo']);
270270
});
271271

272272
it(`should append to existing paths mappings`, async () => {
@@ -284,7 +284,7 @@ describe('Library Schematic', () => {
284284
const tree = await schematicRunner.runSchematic('library', defaultOptions, workspaceTree);
285285

286286
const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json');
287-
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['libs/*', 'dist/foo']);
287+
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['libs/*', './dist/foo']);
288288
});
289289

290290
it(`should not modify the file when --skipTsConfig`, async () => {
@@ -333,7 +333,7 @@ describe('Library Schematic', () => {
333333
expect(cfg.projects['@myscope/mylib']).toBeDefined();
334334

335335
const rootTsCfg = getJsonFileContent(tree, '/tsconfig.json');
336-
expect(rootTsCfg.compilerOptions.paths['@myscope/mylib']).toEqual(['dist/myscope/mylib']);
336+
expect(rootTsCfg.compilerOptions.paths['@myscope/mylib']).toEqual(['./dist/myscope/mylib']);
337337
});
338338

339339
it(`should dasherize scoped libraries`, async () => {

packages/schematics/angular/workspace/files/tsconfig.json.template

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{
33
"compileOnSave": false,
44
"compilerOptions": {
5-
"baseUrl": "./",
65
"outDir": "./dist/out-tsc",<% if (strict) { %>
76
"forceConsistentCasingInFileNames": true,
87
"strict": true,

tests/legacy-cli/e2e/tests/build/library-with-demo-app.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function () {
1717

1818
// Scenario #1 where we use wildcard path mappings for secondary entry-points.
1919
await updateJsonFile('tsconfig.json', (json) => {
20-
json.compilerOptions.paths = { 'mylib': ['dist/mylib'], 'mylib/*': ['dist/mylib/*'] };
20+
json.compilerOptions.paths = { 'mylib': ['./dist/mylib'], 'mylib/*': ['./dist/mylib/*'] };
2121
});
2222

2323
await appendToFile(
@@ -39,9 +39,9 @@ export default async function () {
3939
// Scenario #2 where we don't use wildcard path mappings.
4040
await updateJsonFile('tsconfig.json', (json) => {
4141
json.compilerOptions.paths = {
42-
'mylib': ['dist/mylib'],
43-
'mylib/secondary': ['dist/mylib/secondary'],
44-
'mylib/another': ['dist/mylib/another'],
42+
'mylib': ['./dist/mylib'],
43+
'mylib/secondary': ['./dist/mylib/secondary'],
44+
'mylib/another': ['./dist/mylib/another'],
4545
};
4646
});
4747

0 commit comments

Comments
 (0)