Skip to content

Migration to Angular Material 18 fails due to invalid regular expression in define-light-theme migration #30921

@nicoesiea

Description

@nicoesiea

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

Yes, the previous migration from Angular Material 16 → 17 worked correctly. Angular Material 17.3.10

Description

When running the migration command to update @angular/material from version 17 to 18 using the Angular CLI, the process fails with the following error:

× Migration failed: Invalid regular expression: /*.define-light-theme(/: Nothing to repeat

It seems the migration script contains an invalid regular expression targeting define-light-theme() usage in SCSS files, possibly due to an unescaped / or *.

Reproduction

  1. Install Angular CLI and Angular Material 17 in a project.
  2. Ensure some use of define-light-theme() is present in SCSS (even if unused, the migration fails).
  3. Run: ng update @angular/material@18

Expected Behavior

The migration should correctly scan SCSS files and apply changes (if necessary) without failing due to a malformed regular expression.

Actual Behavior

The update process is interrupted due to a JavaScript exception caused by an invalid regular expression:
Invalid regular expression: /*.define-light-theme(/: Nothing to repeat

As a result, no migration is applied and developers must manually adjust their styles.

Environment

Angular CLI: 18.x
Node: 18.19.0
OS: Windows 10
Package manager: npm
Project Angular version: 18.2.14
@angular/material: 17.3.10 → 18.2.14
@angular/cdk: 17.3.10 → 18.2.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions