fix(@angular-devkit/build-angular): bring back style tags in browser builder#28873
Conversation
2fba337 to
26715d2
Compare
|
Thanks for looking into this! Seems like a tricky issue. I feel like this comment is particularly telling: https://github.com/angular/angular/blob/92f30a749d676a290f5e173760ca29f0ff85ba8c/packages/compiler-cli/src/ngtsc/annotations/component/src/resources.ts#L435-L436 "If the preload worked" seems to mean "If it returned a I'm not sure I'm seeing the "preload didn't work" cause in If this is sufficient to get the test to pass, I'm probably ok to merge it with |
|
If nothing else, I believe this kind of " |
|
The changes were merged into the following branches: main, 19.0.x |
|
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. |
Adds tests for extracting component styles from
<style>tags inside of the template. The application builder didn't have this regression but I still added a test there as well to ensure we don't accidentally regress on that side in the future.So... what happened here? Basically,
readResourcereturning a string and not a Promise was triggering what I suspect was unintended behavior:AdapterResourceLoader.preload, a string result fromreadResourceleads to the function returningundefinedinstead ofPromise<undefined>.preloadAndParseTemplate, anundefinedreturn value ofpreloadresults in an immediatereturn Promise.resolve(null)while aPromise.resolve(undefined)actually populates the template cache and returns thetemplatevalue.templatevalue, theComponentDecoratorHandler.preanalyzemethod will always returntemplateStyles: []- completely ignoring what might have actually been in the template. Which is kind of fair - it never got to see the value oftemplate.Somewhere along the lines, something disagrees about the meaning of
undefinedand/or if there is a semantic difference betweenundefinedandPromise<undefined>. I'm pretty sure what we want here is the behavior ofPromise<undefined>where it actually takes the template metadata.