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:

committed by
Matias Niemelä

parent
103a5b42ec
commit
1cba5d42d1
@ -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';
|
||||
|
Reference in New Issue
Block a user