Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,23 @@ export function createAngularAssetsMiddleware(
// Inject component ID for view encapsulation if requested
const componentId = new URL(req.url, 'http://localhost').searchParams.get('ngcomp');
if (componentId !== null) {
const etag = `W/"${outputFile.contents.byteLength}-${outputFile.hash}-${componentId}"`;
if (req.headers['if-none-match'] === etag) {
res.statusCode = 304;
res.end();

return;
}
// Record the component style usage for HMR updates
const usedIds = usedComponentStyles.get(pathname);
if (usedIds === undefined) {
usedComponentStyles.set(pathname, new Set([componentId]));
} else {
usedIds.add(componentId);
}

// Report if there are no changes to avoid reprocessing
const etag = `W/"${outputFile.contents.byteLength}-${outputFile.hash}-${componentId}"`;
if (req.headers['if-none-match'] === etag) {
res.statusCode = 304;
res.end();

return;
}

// Shim the stylesheet if a component ID is provided
if (componentId.length > 0) {
// Validate component ID
Expand Down