Sitelet https://github.com/NativeScript/NativeScript/pull/11360
Skip to content

fix(core): install global polyfills only when missing, without materializing lazy runtime globals - #11360

Merged
NathanWalker merged 1 commit into
mainfrom
fix/conditional-global-polyfill-install
Aug 25, 2026
Merged

fix(core): install global polyfills only when missing, without materializing lazy runtime globals#11360
NathanWalker merged 1 commit into
mainfrom
fix/conditional-global-polyfill-install

Conversation

@edusperoni

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

  • registerOnGlobalContext (the lazy CJS install path) checks for an existing global with a property read (if (global[exportName])). On runtimes that expose lazy self-installing globals (e.g. TextDecoder), that read forces the native implementation to materialize eagerly, defeating the runtime's laziness. Truthiness also means a defined-but-falsy global would get shadowed.
  • installPolyfills (eager ESM/snapshot path) loads the polyfill module even when the runtime already provides every requested export.
  • global.crypto is overwritten unconditionally, clobbering a runtime-provided crypto.

What is the new behavior?

Polyfills are installed only when the corresponding global is actually missing, and presence is always checked with the in operator, which does a HasProperty lookup without invoking getters or lazy-property callbacks — so checking for TextDecoder no longer evaluates it. (Object.getOwnPropertyDescriptor would not be safe here either: V8 resolves lazy data properties to produce the descriptor.)

  • installPolyfills filters the export list down to names missing from global first, and skips loading the polyfill module entirely when the runtime provides everything.
  • registerOnGlobalContext bails out via exportName in global instead of reading the property.
  • global.crypto is only assigned when absent.

@nx-cloud

nx-cloud Bot commented Aug 25, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 0a043a7

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 4m 10s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-25 20:19:54 UTC

@NathanWalker
NathanWalker merged commit 21d59d6 into main Aug 25, 2026
8 checks passed
@NathanWalker
NathanWalker deleted the fix/conditional-global-polyfill-install branch August 25, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants