You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ngDevMode is undefined in an MFE with external or shared dependencies #4699
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
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.
Activity
markostanimirovic commentedon Feb 11, 2025
ngDevModeis used instead ofisDevMode()to enforce tree shaking. In other words, ifisDevMode()is used, assertions will end up in the production bundle even though they're not used.bh3605 commentedon Feb 12, 2025
Thanks for the quick turnaround!
fix(signals): skip assertions when ngDevMode is not defined (#4703)