Skip to content

ng serve --hmr should apply changes in component styles without reinitialization of the whole app #19867

Closed
@th0r

Description

@th0r

🚀 Feature request

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Description

Currently during ng serve --hmr any change in component styles triggers reinitialization of the whole app. This behavior is far from ideal as route components in most of the apps need to load data asynchronously and their reinitialization triggers this process again, so applying a change in component's styles can't be reviewed immediately (as it should and as it's done in other frameworks like Vue or React).

I've created a reproduction repo:

  1. Clone it, run npm ci && npm start and open localhost:4200
  2. You'll see Initializing page... and then Page ready. TestPageComponent simulates data loading in it's ngOnInit method.
  3. Change this line to something like background-color: blue.
  4. TestPageComponent will be reinitialized and you'll be able to review the change only after 3 seconds.

Describe the solution you'd like

I expect changes in component styles to be applied immediately without reinitialization of the host component.

By the way, changes in global styles are applied immediately, as they should.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions