feat(compiler): use typescript for resolving resource paths
This can also be customized via the new method `resourceNameToFileName` in the `CompilerHost`.
This commit is contained in:
@ -100,4 +100,27 @@ describe('NgCompilerHost', () => {
|
||||
.toBe('/tmp/src/a/child.d.ts');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('resourceNameToFileName', () => {
|
||||
it('should resolve a relative import', () => {
|
||||
const ngHost = createHost({files: {'tmp': {'src': {'a': {'child.html': '<div>'}}}}});
|
||||
expect(ngHost.resourceNameToFileName('./a/child.html', '/tmp/src/index.ts'))
|
||||
.toBe('/tmp/src/a/child.html');
|
||||
|
||||
expect(ngHost.resourceNameToFileName('./a/non-existing.html', '/tmp/src/index.ts'))
|
||||
.toBe(null);
|
||||
});
|
||||
|
||||
it('should resolve package paths as relative paths', () => {
|
||||
const ngHost = createHost({files: {'tmp': {'src': {'a': {'child.html': '<div>'}}}}});
|
||||
expect(ngHost.resourceNameToFileName('a/child.html', '/tmp/src/index.ts'))
|
||||
.toBe('/tmp/src/a/child.html');
|
||||
});
|
||||
|
||||
it('should resolve absolute paths', () => {
|
||||
const ngHost = createHost({files: {'tmp': {'src': {'a': {'child.html': '<div>'}}}}});
|
||||
expect(ngHost.resourceNameToFileName('/tmp/src/a/child.html', '/tmp/src/index.ts'))
|
||||
.toBe('/tmp/src/a/child.html');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user