angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.36k stars 6.74k forks source link

ng update @angular/material@15 forget about updating angular.json prebuilt-themes path to legacy #27037

Open sdedieu opened 1 year ago

sdedieu commented 1 year ago

Command

update

Is this a regression?

The previous version in which this bug was not present was

No response

Description

The ng update @angular/material@15 command update every @angular/material import path in order to use the legacy classes. This behaviour prevents breaking the project using that command during a migration from v14 to v15. Sadly the script forget about updating the prebuilt-themes path under the angular.json file in the styles section.

Minimal Reproduction

Every material classes import paths are automatically updated to use the legacy version example: import { MatDialogRef } from '@angular/material/dialog'; is now import { MatLegacyDialogRef as MatDialogRef } from '@angular/material/legacy-dialog';

But style is broken since prebuilt-themes import wasn't updated.

Expected behaviour

// angular.json
...
"styles": [
  "./node_modules/@angular/material/legacy-prebuilt-themes/legacy-deeppurple-amber.css",
  "src/styles.css"
],
...

Exception or Error

No response

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 15.2.8
Node: 16.14.0
Package Manager: npm 8.3.1
OS: darwin arm64

Angular: 15.2.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1502.8
@angular-devkit/build-angular   15.2.8
@angular-devkit/core            15.2.8
@angular-devkit/schematics      15.2.8
@angular/cdk                    14.2.7
@angular/cli                    15.2.8
@angular/material               14.2.7
@schematics/angular             15.2.8
rxjs                            7.5.7
typescript                      4.9.5

Anything else relevant?

No response

jacksonhart commented 4 months ago

this just saved me after an hour of figuring out why my styles were broken after an ng material 14 -> 15 upgrade, despite using legacy components. this should at least be put as a known issue / step in the upgrade guide!