Skip to content

bug(MATERIAL): Hashed Imports are generated in a .d.ts for a Library based on Angular Material >= 19.2.4 #30913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
DerAlbertCom opened this issue Apr 21, 2025 · 2 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@DerAlbertCom
Copy link

DerAlbertCom commented Apr 21, 2025

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

19.2.3

Description

We have an internal Component Library which is based on Angular Material.

Since Angular Material Version 19.2.4 and up to19.2.10 some of our Services are a created wrong, the included import with a concrete hash in the .d.ts which obviously tends to compile time problems if the user does not also have the exact Angular Material Version in his project.

I created a “minimal” repo, based on our library project structure.

I also saw other Issues with a similar problem (also with 19.2.4), but it appears that this is different because it still happens with the current version of Angular Material.

Reproduction

https://stackblitz.com/~/github.com/DerAlbertCom/AngularMaterialBug

Reproduce

  1. cd ng-mono
  2. npm install
  3. npm run lib:build
  4. look at the generated file
  5. https://stackblitz.com/~/github.com/DerAlbertCom/AngularMaterialBug?file=ng-mono/dist/%40dummy/unity-lib/confirm/dummy-confirmation.service.d.ts

Expected Behavior

Creating a d.ts file with the general import, without the hash, like in all Version before 19.2.4.

export declare class DummyConfirmationService {
    private readonly matDialog;
    confirm$<T = boolean>(data?: DummyDialogConfirmComponentData<T>, options?: MatDialogConfig<DummyDialogConfirmComponentData<T>>): import("@angular/material/dialog").MatDialogRef<DummyDialogConfirmComponent<T>, T | null>;
    dialog$<T, D = any, R = any>(component: ComponentType<T>, data?: D, options?: MatDialogConfig<D>): import("@angular/material/dialog").MatDialogRef<T, R>;
    static ɵfac: i0.ɵɵFactoryDeclaration<DummyConfirmationService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<DummyConfirmationService>;
}

Actual Behavior

The d.ts file is generated with the Hash in the import, this happens since Version 19.2.4

export declare class DummyConfirmationService {
    private readonly matDialog;
    confirm$<T = boolean>(data?: DummyDialogConfirmComponentData<T>, options?: MatDialogConfig<DummyDialogConfirmComponentData<T>>): import("@angular/material/dialog.d-Dvsbu-0E").MatDialogRef<DummyDialogConfirmComponent<T>, T | null>;
    dialog$<T, D = any, R = any>(component: ComponentType<T>, data?: D, options?: MatDialogConfig<D>): import("@angular/material/dialog.d-Dvsbu-0E").MatDialogRef<T, R>;
    static ɵfac: i0.ɵɵFactoryDeclaration<DummyConfirmationService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<DummyConfirmationService>;
}

Environment

  • Angular: 19.x,
  • CDK/Material:19.2.4 to 19.2.10
  • Operating System: Windows 11 24H2
@DerAlbertCom DerAlbertCom added the needs triage This issue needs to be triaged by the team label Apr 21, 2025
@DerAlbertCom DerAlbertCom changed the title bug(COMPONENT): TITLE bug(MATERIAL): Hashed Imports are generated in a .d.ts for a Library based on Angular Material >= 19.2.4 Apr 21, 2025
@crisbeto
Copy link
Member

cc @devversion

@EricKnudsen256
Copy link

I can confirm that the update from 19.2.3 to 19.2.4 has also been causing different issues in the module federation environment that I am currently working with. Before 19.2.4, everything works as expected, but after updating to 19.2.4 or higher, I start getting tons of NG0912 warnings like so:

Image

While I don't know much about the inner workings of this repo, I would suspect that something with the hashed imports are throwing off the library sharing capabilities of nx's module federation. I made an issue on their repo yesterday because I thought the problem was on their end, but it seems like this is more likely the core issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

3 participants