New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ivy): support templateUrl for ngtsc #24704
Conversation
You can preview 9d100de at https://pr24704-9d100de.ngbuilds.io/. |
Will this support TypeScript path resolution? |
This commit adds support for templateUrl in component templates within ngtsc. The compilation pipeline is split into sync and async versions, where asynchronous compilation invokes a special preanalyze() phase of analysis. The preanalyze() phase can optionally return a Promise which will delay compilation until it resolves. A ResourceLoader interface is used to resolve templateUrls to template strings and can return results either synchronously or asynchronously. During sync compilation it is an error if the ResourceLoader returns a Promise. Two ResourceLoader implementations are provided. One uses 'fs' to read resources directly from disk and is chosen if the CompilerHost doesn't provide a readResource method. The other wraps the readResource method from CompilerHost if it's provided.
9d100de
to
af7f6f9
Compare
You can preview af7f6f9 at https://pr24704-af7f6f9.ngbuilds.io/. |
@@ -147,6 +147,27 @@ describe('ngtsc behavioral tests', () => { | |||
expect(dtsContents).toContain('static ngComponentDef: i0.ComponentDef<TestCmp, \'test-cmp\'>'); | |||
}); | |||
|
|||
it('should compile Components without errors', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have tests for the cases which throw errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we will. Right now the errors the compiler throws are temporary - basically assertions that throw new Error(...)
on encountering something unexpected.
In the future, these will be migrated to become actual user-facing errors which will be reported via TypeScript's diagnostic system, including line/col pointers to the location of the error in the source. These are the errors we should write tests for.
fe9da2c
to
c5afae1
Compare
@alfaproject no, module resolution is not supported in |
You can preview c5afae1 at https://pr24704-c5afae1.ngbuilds.io/. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit adds support for templateUrl in component templates within
ngtsc. The compilation pipeline is split into sync and async versions,
where asynchronous compilation invokes a special preanalyze() phase of
analysis. The preanalyze() phase can optionally return a Promise which
will delay compilation until it resolves.
A ResourceLoader interface is used to resolve templateUrls to template
strings and can return results either synchronously or asynchronously.
During sync compilation it is an error if the ResourceLoader returns a
Promise.
Two ResourceLoader implementations are provided. One uses 'fs' to read
resources directly from disk and is chosen if the CompilerHost doesn't
provide a readResource method. The other wraps the readResource method
from CompilerHost if it's provided.