`ng new --view-encapsulation` has no effect on generated components
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #34389 di @MeAkib — integrata
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- angular, typescript
- Ambito
- build-system, cli
Direzione di ricerca
The issue identifies the ng new and ng generate application paths, the generated root App component, angular.json component schematic defaults, and main.ts bootstrap options. Trace how --view-encapsulation flows through those generation paths and compare the generated files with the reproduction steps. Done means the selected mode affects the initial component and later generated components under AOT.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Command
new
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
The --view-encapsulation option of ng new / ng generate application is documented as "Sets the view
encapsulation mode for components in the initial project", but it currently has no effect:
- The root
Appcomponent is generated withoutencapsulation, so its styles stay scoped (Emulated). - The value is not saved to the project's
@schematics/angular:componentdefaults inangular.json, so components
generated later withng g calso use Emulated. - For
--no-standaloneapps,main.tsgetsbootstrapModule(AppModule, { defaultEncapsulation: ViewEncapsulation.X }).
defaultEncapsulationis only read by the JIT compiler, so it has no effect with AOT, which is the default for
ng buildandng serve.
This looks like #13689 again: it was fixed in 89797900db by setting the encapsulation on the root component and in
bootstrapModule, but the root component part was removed in 58bc5b8f2a (for #13742, invalid generated code), leaving
only the JIT-only option.
Minimal Reproduction
ng new ve-repro --defaults --view-encapsulation=None(same result with--no-standalone)- Add
h1 { color: red; }tosrc/app/app.css ng build --configuration development- The output contains
h1[_ngcontent-%COMP%], i.e. the styles are still encapsulated. angular.jsonhas noviewEncapsulationunderprojects.ve-repro.schematics, song g c fooalso generates an
Emulated component.
Exception or Error
Your Environment
Latest
Anything else relevant?
Possible fix: set encapsulation on the generated root component, save viewEncapsulation in the component schematic
defaults, and drop defaultEncapsulation from main.ts. Happy to send a PR.
- Lingua principale
- TypeScript
- Stelle
- 27k
- Fork
- 11.8k
- Merge medio
- 1g 6h
- PR unite (30g)
- 234
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di angular/angular-cli
-
area: @angular/build gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
angular/angular-cli#33955 ·
I maintainer di solito rispondono entro 1 giorno
-
area: @angular/cli gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
angular/angular-cli#33055 · 1 commento · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
@angular/build@21 depends on [email protected] which is vulnerable to multiple CVEsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 30/100
angular/angular-cli#34518 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Server build bundles two copies of Domino, so DOM globals from `init` and the `DominoAdapter` are different classesForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea: @angular/build
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
angular/angular-cli#34514 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
ssr: string redirectTo drops trailing slash in query and fragmentForse già presa @alan-agius4 l’ha presa 2 giorni fa. Apertaarea: @angular/ssr
Difficoltà 3/5 1-2 giorni Idoneità per principianti 57/100
angular/angular-cli#34511 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di angular/angular-cli
Issue simili
-
type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
0️⃣ phase/new
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
microsoft/playwright#43640 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100