← 输入框|github.com|刷新
Skip to content

fix(windows): break import cycle between view and animation modules - #11581

Open
aleclarson wants to merge 1 commit into
NativeScript:feat/windowsfrom
aleclarson:fix/windows-view-animation-cycle
Open

aleclarson wants to merge 1 commit into
NativeScript:feat/windowsfrom
aleclarson:fix/windows-view-animation-cycle

Conversation

@aleclarson

Copy link
Copy Markdown
Contributor

Summary

  • view-common imports Animation from ui/animation, whose Windows index imported _ensureNativeTransforms back from the platform view barrel (ui/core/view/index) — a view-common → animation → view → view-common cycle that does not exist on Android (index.android.ts has no such import).
  • When the bundler (Vite/rolldown) flattens both modules into one chunk it evaluates the platform View class body — [originXProperty.setNative], [isEnabledProperty.setNative], etc. — before view-common's property declarations run, so the app crashes at startup with TypeError: Cannot read properties of undefined (reading 'setNative'). Under plain ESM evaluation the same cycle produces a TDZ error.
  • Moves _ensureNativeTransforms into a leaf module (native-transforms.windows) imported by both files; it only touches WinRT types, so the edge from animation back into the view module disappears. The public re-export from ui/core/view is preserved (.d.ts unchanged in shape — _ensureNativeTransforms remains exported from the same specifier).

Test plan

  • tsc --noEmit -p packages/core/tsconfig.lib.json — clean
  • Rebuilt an Octane Xplat Windows app (@nativescript/core@abae298 + this change applied as a patch): generated vendor.mjs no longer references the uninitialized binding; the packaged app boots past module evaluation
  • apps/toolbox Windows run

view-common imports Animation from ui/animation, whose Windows index
imported _ensureNativeTransforms back from the platform view barrel.
When the bundler flattened both modules into one chunk it evaluated the
platform View class body — [originXProperty.setNative] and friends —
before view-common's property declarations ran, so the app crashed at
startup with 'Cannot read properties of undefined (reading setNative)'.

Move _ensureNativeTransforms into a leaf module (native-transforms)
imported by both files; it only touches WinRT types, so the edge from
animation back into the view module disappears. The public re-export
from ui/core/view is preserved.
@nx-cloud

nx-cloud Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 8c98608

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 51s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded 7s View ↗

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


☁️ Nx Cloud last updated this comment at 2026-10-23 20:42:48 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11581
npm i https://pkg.pr.new/@nativescript/vite@11581
npm i https://pkg.pr.new/@nativescript/webpack@11581

commit: 8c98608

This branch has not been deployed

No deployments
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.

1 participant