Description
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
17.3.10
Description
When attempting to run the ng update @angular/material@18
script to make the step from Angular Material 17 to 18, the script breaks consistently, providing the following output:
$ ng update @angular/material@18.0
Using package manager: npm
Collecting installed dependencies...
Found 80 dependencies.
Fetching dependency metadata from registry...
Updating package.json with dependency @angular/cdk @ "18.0.6" (was "17.3.10")...
Updating package.json with dependency @angular/material @ "18.0.6" (was "17.3.10")...
Updating package.json with dependency @angular/material-moment-adapter @ "18.0.6" (was "17.3.10")...
UPDATE package.json (3953 bytes)
✔ Cleaning node modules directory
✔ Installing packages
** Executing migrations of package '@angular/cdk' **
❯ Updates the Angular CDK to v18.
Skipping migration for project ems-ui-e2e. Unable to determine 'tsconfig.json' file in workspace config.
✓ Updated Angular CDK to version 18
Migration completed (No changes made).
** Executing migrations of package '@angular/material' **
❯ Updates Angular Material to v18.
✖ Migration failed: Invalid regular expression: /*\.define-light-theme\(/: Nothing to repeat
See "C:\Users\NATHAN~1\AppData\Local\Temp\ng-qBQlVT\angular-errors.log" for further details.
The angular-errors.log provides slightly more details:
[error] SyntaxError: Invalid regular expression: /*\.define-light-theme\(/: Nothing to repeat
at new RegExp (<anonymous>)
at migrateFunction (C:\git\emsuite\UI\node_modules\@angular\material\schematics\ng-update\index_bundled.js:750:34)
at migrateM2ThemingApiUsages (C:\git\emsuite\UI\node_modules\@angular\material\schematics\ng-update\index_bundled.js:723:21)
at M2ThemingMigration2.postAnalysis (C:\git\emsuite\UI\node_modules\@angular\material\schematics\ng-update\index_bundled.js:844:70)
at C:\git\emsuite\UI\node_modules\@angular\cdk\schematics\update-tool\index.js:137:35
at Array.forEach (<anonymous>)
at UpdateProject.migrate (C:\git\emsuite\UI\node_modules\@angular\cdk\schematics\update-tool\index.js:137:20)
at runMigrations (C:\git\emsuite\UI\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:119:42)
at C:\git\emsuite\UI\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:82:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
This has been tested by multiple people on our team with the same results. According to the code here ( https://github.com/angular/components/blob/18.0.x/src/material/schematics/ng-update/migrations/m2-theming-v18/migration.ts ) it is checking for commented out function names, but it is not escaping the comment characters, which is causing the migrateFunction
function to fail on line 154, since the /*
characters are not being escaped.
Reproduction
StackBlitz link: (As this is a migration script run via ng update, a stackblitz does not make sense
Steps to reproduce:
- Create a new Angular Material project @ 17.3.10.
- In the application's project directory, run ng update @angular/core@18 @angular/cli@18 to update your application to Angular v18.
- Run ng update @angular/material@18.
Expected Behavior
I would expect the script to proceed, and finish migrating things from 17 to 18.
Actual Behavior
It crashes out, with the errors above.
Environment
- Angular: 17.3.10 => 18
- CDK/Material: 17.3.10 => 18
- Browser(s): Attempted in both a git bash window and a basic command prompt
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11.