Skip to content

fix(@schematics/angular): apply viewEncapsulation to generated application components - #34389

Open
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/view-encapsulation
Open

MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/view-encapsulation

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

The viewEncapsulation option of the application schematic had no effect. The root component template did not set encapsulation, the value was not added to the component schematic defaults, so components generated later used the default encapsulation, and the defaultEncapsulation option added to bootstrapModule in main.ts for NgModule applications is only used by the JIT compiler.

Set encapsulation on the root component, add viewEncapsulation to the component schematic defaults in angular.json, and remove the ineffective defaultEncapsulation option from main.ts.

Fixes #34388

…ication components

The `viewEncapsulation` option of the application schematic had no effect. The root
component template did not set `encapsulation`, the value was not added to the
component schematic defaults, so components generated later used the default
encapsulation, and the `defaultEncapsulation` option added to `bootstrapModule` in
`main.ts` for NgModule applications is only used by the JIT compiler.

Set `encapsulation` on the root component, add `viewEncapsulation` to the component
schematic defaults in `angular.json`, and remove the ineffective `defaultEncapsulation`
option from `main.ts`.

Fixes angular#34388

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Angular application schematic to configure viewEncapsulation directly on the root component (via the @component decorator) instead of setting defaultEncapsulation globally in main.ts during bootstrapping. It also ensures that viewEncapsulation is added to the component schematic defaults in the workspace configuration when provided, and includes comprehensive unit tests to verify these changes. There are no review comments, so I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng new --view-encapsulation has no effect on generated components

1 participant