Skip to content

ngDevMode is undefined in an MFE with external or shared dependencies #4699

Closed

Description

@bh3605

Which @ngrx/* package(s) are the source of the bug?

signals

Minimal reproduction of the bug/regression with instructions

Kinda hard to replicate because it involves multiple projects, but the issue still remains this library is relying on an internal Angular flag when it should be calling the public api isDevMode()

Expected behavior

assertUniqueStoreMembers() relies on the isDevMode() method instead of the ngDevMode flag.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

NgRx: 18.*
Angular: 18.*

Other information

The issue is when this library is used in a micro-frontend that is using an external map of angular/core or specifying angular/core as a shared dependency then the call to assertUniqueStoreMembers() throws an error because ngDevMode is undefined. This method was introduced in version 18. What you should be doing is calling isDevMode() from @angular/core so as to not create a direct dependency on an internal Angular flag.

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Activity

  1. markostanimirovic commented on Feb 11, 2025

    @markostanimirovic
    Member

    ngDevMode is used instead of isDevMode() to enforce tree shaking. In other words, if isDevMode() is used, assertions will end up in the production bundle even though they're not used.

  2. bh3605 commented on Feb 12, 2025

    @bh3605
    Author

    Thanks for the quick turnaround!

  3. added a commit that references this issue on Feb 14, 2025
    0b43014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions