fix: define ngDevMode in dev builds to prevent ReferenceError#1089
Open
rogeru wants to merge 1 commit intoangular-architects:mainfrom
Open
fix: define ngDevMode in dev builds to prevent ReferenceError#1089rogeru wants to merge 1 commit intoangular-architects:mainfrom
rogeru wants to merge 1 commit intoangular-architects:mainfrom
Conversation
In dev mode, `ngDevMode` was not defined at all in the esbuild `define` config. Angular's compiler emits bare `ngDevMode` references in signal/input/computed debug info. When these run at module load time, they throw `ReferenceError: ngDevMode is not defined`. This sets `ngDevMode` to `'true'` in dev builds (and keeps `'false'` for production), ensuring the global is always replaced by esbuild. Fixes angular-architects#458 Fixes angular-architects#897 Related to angular-architects#552, angular-architects#815 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
Thank you for this, a bit of an unfortunate timing but I'll have a look! I just wanted to point out that both the issues you claim to fix are module-federation related while this fix is for native-federation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In dev mode,
ngDevModewas not included in esbuild'sdefineconfig. Angular's compiler emits barengDevModereferences forsignal(),input(), andcomputed()debug info. When these execute at module load time, they throw:This one-line fix sets
ngDevModeto'true'in dev builds (and keeps'false'for production), ensuring esbuild always replaces the identifier.The change
This also fixes the related issue where
isDevMode()always returnsfalse(#552), sincengDevModeis now correctly set totrueduring development.Issues
Fixes #458
Fixes #897
Related to #552, #815