Skip to content

Commit 00cd0d1

Browse files
committed
fix(@angular/build): prevent nested CSS in components
The Angular encapsulation currently does not support CSS nesting syntax, which can lead to run-time errors or unexpected behavior when such styles are used in component stylesheets. This change ensures that nested CSS rules flattened to maintain compatibility with the compiler. For more context, see: angular/angular#58996 (cherry picked from commit 3d997fe)
1 parent 8ab033e commit 00cd0d1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: packages/angular/build/src/tools/esbuild/angular/component-stylesheets.ts

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export class ComponentStylesheetBundler {
7474
buildOptions.entryPoints = [entry];
7575
}
7676

77+
// Angular encapsulation does not support nesting
78+
// See: https://github.com/angular/angular/issues/58996
79+
buildOptions.supported ??= {};
80+
buildOptions.supported['nesting'] = false;
81+
7782
return buildOptions;
7883
});
7984
});
@@ -124,6 +129,11 @@ export class ComponentStylesheetBundler {
124129
buildOptions.entryPoints = [`${namespace};${entry}`];
125130
}
126131

132+
// Angular encapsulation does not support nesting
133+
// See: https://github.com/angular/angular/issues/58996
134+
buildOptions.supported ??= {};
135+
buildOptions.supported['nesting'] = false;
136+
127137
buildOptions.plugins.push({
128138
name: 'angular-component-styles',
129139
setup(build) {

0 commit comments

Comments
 (0)