-
Notifications
You must be signed in to change notification settings - Fork 11.9k
fix(@angular/build): workaround Vite CSS ShadowDOM hot replacement #28780
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
fix(@angular/build): workaround Vite CSS ShadowDOM hot replacement #28780
Conversation
When using the development server with the application builder (default for new projects), Angular components using ShadowDOM view encapsulation will now cause a full page reload. This ensures that these components styles are correctly updated during watch mode. Vite's CSS hot replacement client code currently does not support searching and replacing `<link>` elements inside shadow roots. When support is available within Vite, an HMR based update for ShadowDOM components can be supported as other view encapsulation modes are now.
const trackingId = componentId || shadow; | ||
if (usedIds === undefined) { | ||
usedComponentStyles.set(pathname, new Set([componentId])); | ||
usedComponentStyles.set(pathname, new Set([trackingId])); |
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.
It might be clearer if we structure the data differently rather than using true/false/string, as a object to make it easier to follow:
{
encapsulation?: string;
componentId?: string;
}
I can foresee that, in the future, this can be a bit confusing whlist debugging that as component ids we store booleans
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.
I'm hoping we can revert this workaround sooner rather than later. Post v19 i may also look into patching the Vite client code to add support for shadow DOM with a potential followup Vite PR.
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.
LGTM. one NIT.
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. |
When using the development server with the application builder (default for new projects), Angular components using ShadowDOM view encapsulation will now cause a full page reload. This ensures that these components styles are correctly updated during watch mode. Vite's CSS hot replacement client code currently does not support searching and replacing
<link>
elements inside shadow roots. When support is available within Vite, an HMR based update for ShadowDOM components can be supported as other view encapsulation modes are now.