-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathtsconfig-paths_spec_large.ts
78 lines (69 loc) · 2.31 KB
/
tsconfig-paths_spec_large.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Architect } from '@angular-devkit/architect/src/index2';
import { runTargetSpec } from '@angular-devkit/architect/testing';
import { tap } from 'rxjs/operators';
import { browserBuild, browserTargetSpec, createArchitect, host } from '../utils';
describe('Browser Builder tsconfig paths', () => {
const target = { project: 'app', target: 'build' };
let architect: Architect;
beforeEach(async () => {
await host.initialize().toPromise();
architect = (await createArchitect(host.root())).architect;
});
afterEach(async () => host.restore().toPromise());
it('works', async () => {
host.replaceInFile('src/app/app.module.ts', './app.component', '@root/app/app.component');
host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, `
"baseUrl": "./",
"paths": {
"@root/*": [
"./src/*"
]
},
`);
await browserBuild(architect, host, target);
});
it('works', async () => {
host.writeMultipleFiles({
'src/meaning-too.ts': 'export var meaning = 42;',
'src/app/shared/meaning.ts': 'export var meaning = 42;',
'src/app/shared/index.ts': `export * from './meaning'`,
});
host.replaceInFile('tsconfig.json', /"baseUrl": ".\/",/, `
"baseUrl": "./",
"paths": {
"@shared": [
"src/app/shared"
],
"@shared/*": [
"src/app/shared/*"
],
"*": [
"*",
"src/app/shared/*"
]
},
`);
host.appendToFile('src/app/app.component.ts', `
import { meaning } from 'src/app/shared/meaning';
import { meaning as meaning2 } from '@shared';
import { meaning as meaning3 } from '@shared/meaning';
import { meaning as meaning4 } from 'meaning';
import { meaning as meaning5 } from 'src/meaning-too';
// need to use imports otherwise they are ignored and
// no error is outputted, even if baseUrl/paths don't work
console.log(meaning)
console.log(meaning2)
console.log(meaning3)
console.log(meaning4)
console.log(meaning5)
`);
await browserBuild(architect, host, target);
});
});