Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 33af719

Browse files
committed
fix(@schematics/angular): remove baseUrl from project tsconfigs
In a multiple project environment, the workspace tsconfig should be used for path mapping and tooling. Having a baseUrl in the project tsconfigs would lead to either tooling or builds to be broken.
1 parent bbac6d3 commit 33af719

File tree

12 files changed

+11
-22
lines changed

12 files changed

+11
-22
lines changed

packages/angular_devkit/build_webpack/test/browser/tsconfig-paths_spec_large.ts

+8-14
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,12 @@ describe('Browser Builder tsconfig paths', () => {
1515
afterEach(done => host.restore().subscribe(undefined, done.fail, done));
1616

1717
it('works', (done) => {
18-
host.writeMultipleFiles({
19-
'src/meaning-too.ts': 'export var meaning = 42;',
20-
'src/app/shared/meaning.ts': 'export var meaning = 42;',
21-
'src/app/shared/index.ts': `export * from './meaning'`,
22-
});
23-
2418
host.replaceInFile('src/app/app.module.ts', './app.component', '@root/app/app.component');
25-
host.replaceInFile('src/tsconfig.app.json', /"baseUrl": "[^"]*",/, `
19+
host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, `
2620
"baseUrl": "./",
2721
"paths": {
2822
"@root/*": [
29-
"./*"
23+
"./src/*"
3024
]
3125
},
3226
`);
@@ -42,27 +36,27 @@ describe('Browser Builder tsconfig paths', () => {
4236
'src/app/shared/meaning.ts': 'export var meaning = 42;',
4337
'src/app/shared/index.ts': `export * from './meaning'`,
4438
});
45-
host.replaceInFile('src/tsconfig.app.json', /"baseUrl": "[^"]*",/, `
39+
host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, `
4640
"baseUrl": "./",
4741
"paths": {
4842
"@shared": [
49-
"app/shared"
43+
"src/app/shared"
5044
],
5145
"@shared/*": [
52-
"app/shared/*"
46+
"src/app/shared/*"
5347
],
5448
"*": [
5549
"*",
56-
"app/shared/*"
50+
"src/app/shared/*"
5751
]
5852
},
5953
`);
6054
host.appendToFile('src/app/app.component.ts', `
61-
import { meaning } from 'app/shared/meaning';
55+
import { meaning } from 'src/app/shared/meaning';
6256
import { meaning as meaning2 } from '@shared';
6357
import { meaning as meaning3 } from '@shared/meaning';
6458
import { meaning as meaning4 } from 'meaning';
65-
import { meaning as meaning5 } from 'meaning-too';
59+
import { meaning as meaning5 } from 'src/meaning-too';
6660
6761
// need to use imports otherwise they are ignored and
6862
// no error is outputted, even if baseUrl/paths don't work

packages/schematics/angular/application/files/tsconfig.app.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "<%= appDir.split('/').map(x => '..').join('/') %>/tsconfig.json",
33
"compilerOptions": {
44
"outDir": "<%= appDir.split('/').map(x => '..').join('/') %>/out-tsc/app",
5-
"baseUrl": "./",
65
"module": "es2015",
76
"types": []
87
},

packages/schematics/angular/application/files/tsconfig.spec.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "<%= appDir.split('/').map(x => '..').join('/') %>/tsconfig.json",
33
"compilerOptions": {
44
"outDir": "<%= appDir.split('/').map(x => '..').join('/') %>/out-tsc/spec",
5-
"baseUrl": "./",
65
"module": "commonjs",
76
"types": [
87
"jasmine",

packages/schematics/angular/e2e/files/tsconfig.e2e.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "<%= appDir.split('/').map(x => '..').join('/') %>/tsconfig.json",
33
"compilerOptions": {
44
"outDir": "<%= appDir.split('/').map(x => '..').join('/') %>/out-tsc/app",
5-
"baseUrl": "./",
65
"module": "commonjs",
76
"target": "es5",
87
"types": [

packages/schematics/angular/library/files/__projectRoot__/tsconfig.spec.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "<%= projectRoot.split('/').map(x => '..').join('/') %>/tsconfig.json",
33
"compilerOptions": {
44
"outDir": "<%= projectRoot.split('/').map(x => '..').join('/') %>/out-tsc/spec",
5-
"baseUrl": "./",
65
"types": [
76
"jasmine",
87
"node"

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

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compileOnSave": false,
33
"compilerOptions": {
4+
"baseUrl": "./",
45
"outDir": "./dist/out-tsc",
56
"sourceMap": true,
67
"declaration": false,

tests/@angular_devkit/build_ng_packagr/ng-packaged/projects/lib/tsconfig.spec.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../out-tsc/spec",
5-
"baseUrl": "./",
65
"types": [
76
"jasmine",
87
"node"

tests/@angular_devkit/build_ng_packagr/ng-packaged/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compileOnSave": false,
33
"compilerOptions": {
4+
"baseUrl": "./",
45
"outDir": "./dist/out-tsc",
56
"sourceMap": true,
67
"declaration": false,

tests/@angular_devkit/build_webpack/hello-world-app/e2e/tsconfig.e2e.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/e2e",
5-
"baseUrl": "./",
65
"module": "commonjs",
76
"target": "es5",
87
"types": [

tests/@angular_devkit/build_webpack/hello-world-app/src/tsconfig.app.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
5-
"baseUrl": "./",
65
"module": "es2015",
76
"types": []
87
},

tests/@angular_devkit/build_webpack/hello-world-app/src/tsconfig.spec.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/spec",
5-
"baseUrl": "./",
65
"module": "commonjs",
76
"types": [
87
"jasmine",

tests/@angular_devkit/build_webpack/hello-world-app/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compileOnSave": false,
33
"compilerOptions": {
4+
"baseUrl": "./",
45
"outDir": "./dist/out-tsc",
56
"sourceMap": true,
67
"declaration": false,

0 commit comments

Comments
 (0)