fix: bootstrap NG0210 when the runtime exposes a global PerformanceObserver - #178
Open
NathanWalker wants to merge 1 commit into
Open
fix: bootstrap NG0210 when the runtime exposes a global PerformanceObserver#178NathanWalker wants to merge 1 commit into
NathanWalker wants to merge 1 commit into
Conversation
…server Angular's dev-mode ImagePerformanceWarning only bails out early when PerformanceObserver is missing or both image warnings are disabled. NativeScript runtimes that ship a Web Performance API now define that global, so the service proceeds to getDocument() and throws NG0210, failing every debug boot. Default IMAGE_CONFIG to disabled for both warnings — NativeScript has no <img> elements for them to scan. Apps can still override it, since their own providers are applied after the NativeScript ones.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
PR Checklist
@nativescript/ios9.1.0-alpha.20.)What is the current behavior?
Every debug boot fails on runtimes that ship a Web Performance API (e.g.
@nativescript/ios9.1.0-alpha.20, which doesg.PerformanceObserver = PerformanceObserver):Angular starts
ImagePerformanceWarningat the end ofinternalCreateApplicationwheneverngDevModeis on, and the service only bails out early in three cases:The missing
PerformanceObserverglobal is what used to keep this off our path. Once the runtime defines it, the service falls through togetDocument()— which reads a module-scoped variable set by Angular's internalsetDocument(), not theDOCUMENTDI token we provide viaNativeScriptDocument— and throws.What is the new behavior?
NATIVESCRIPT_MODULE_PROVIDERSnow defaultsIMAGE_CONFIGto disabling both image warnings, which restores the early return. That array feeds bothNativeScriptModuleandcreateProvidersConfig, so the NgModule and standalone bootstrap paths are both covered.Both flags are required — Angular ANDs them. The provider has to live in the app/environment injector rather than
COMMON_PROVIDERS, becauseIMAGE_CONFIGis declaredprovidedIn: 'root'and the root environment injector self-satisfies it from the token's own factory instead of delegating to the platform injector.The warnings scan the DOM for oversized and lazily-loaded
<img>elements, so they can never produce a meaningful result under NativeScript. Apps that want them back can still provide their ownIMAGE_CONFIG— app providers are applied after the NativeScript ones.Verified against Angular 21.2.x and 22.0.x: the guard is identical in both, and
IMAGE_CONFIGis public API on@angular/commonin both.