feat(compiler-cli): support transforming component style resources#41307
feat(compiler-cli): support transforming component style resources#41307clydin wants to merge 4 commits intoangular:masterfrom
Conversation
dc43f5b to
303d10a
Compare
This change introduces a new hook on the `ResourceHost` interface named `transformResource`. Resource transformation allows both external and inline resources to be transformed prior to compilation by the AOT compiler. This provides support for tooling integrations to enable features such as preprocessor support for inline styles. Only style resources are currently supported. However, the infrastructure is in place to add template support in the future.
303d10a to
96015e3
Compare
petebacondarwin
left a comment
There was a problem hiding this comment.
One concern I have, which may be unfounded, with this feature is that resource pre-processing can only be done async. This means that compiling the application synchronously would produce a different result to compiling it asynchronously. I am not sure how common this would be a problem... does the CLI "always" run the pre-analyze async run? I think that unit testing via the TestBed would normally be sync?
|
The CLI and in turn the Angular Webpack plugin always execute asynchronously. Integration with the Webpack pipeline requires asynchronous compiler analysis. The current set of potential transformations are all asynchronous as well so at this point there would be no consumer for a synchronous variant. However, if such a requirement is later introduced, synchronous support could be added without any breaking API changes. |
JoostK
left a comment
There was a problem hiding this comment.
I have some concerns about the preprocessing not being considered when loadNgStructureAsync is not used.
Additionally, I'd like to see integration-level tests using NgtscTestEnvironment, to actually run this through the whole pipeline.
JoostK
left a comment
There was a problem hiding this comment.
The changes LGTM to land for v12. Would be good to expand our test coverage of (async) resource loading/processing in a followup PR.
…ngular#41307) This change introduces a new hook on the `ResourceHost` interface named `transformResource`. Resource transformation allows both external and inline resources to be transformed prior to compilation by the AOT compiler. This provides support for tooling integrations to enable features such as preprocessor support for inline styles. Only style resources are currently supported. However, the infrastructure is in place to add template support in the future. PR Close angular#41307
|
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 change introduces a new hook on the
ResourceHostinterface namedtransformResource.Resource transformation allows both external and inline resources to be transformed prior to
compilation by the AOT compiler. This provides support for tooling integrations to enable
features such as preprocessor support for inline styles.
This change also allows all resource transformation to be centralized in the new
transformResourcehook. Previously, thereadResourcehook was leveraged to both read and transform external styles.Only style resources are currently supported. However, the infrastructure is in place to add
template support in the future.