fix(ivy): handle rooted resource paths correctly (#31511)

Previously, resource paths beginning with '/' (aka "rooted" paths, which
are not actually absolute filesystem paths, but are relative to the
TypeScript project root directory) were not handled correctly. The leading
'/' was stripped and the path was resolved as if it was relative, but with
no containing file for context. This led to resources in different rootDirs
not being found.

Instead, such rooted paths are now resolved without TypeScript's help, by
checking each root directory. A test is added to this effect.

PR Close #31511
This commit is contained in:
Alex Rickabaugh
2019-07-11 13:55:11 +02:00
committed by Matias Niemelä
parent 103a5b42ec
commit 1cba5d42d1
2 changed files with 47 additions and 13 deletions

View File

@ -385,6 +385,25 @@ runInEachFileSystem(os => {
expect(jsContents).toContain('Hello World');
});
it('should compile Components with an absolute templateUrl in a different rootDir', () => {
env.tsconfig({}, ['./extraRootDir']);
env.write('extraRootDir/test.html', '<p>Hello World</p>');
env.write('test.ts', `
import {Component} from '@angular/core';
@Component({
selector: 'test-cmp',
templateUrl: '/test.html',
})
export class TestCmp {}
`);
env.driveMain();
const jsContents = env.getContents('test.js');
expect(jsContents).toContain('Hello World');
});
it('should compile components with styleUrls', () => {
env.write('test.ts', `
import {Component} from '@angular/core';