Skip to content

fix(example): load the runtime components entry so iOS dev builds start - #604

Merged
danstepanov merged 1 commit into
nativewind:mainfrom
sammoore:fix/example-components-entry
Dec 4, 2026
Merged

danstepanov merged 1 commit into
nativewind:mainfrom
sammoore:fix/example-components-entry

Conversation

@sammoore

@sammoore sammoore commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

The example app crashes at startup on iOS in dev with Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.

The root tsconfig maps react-native-css/* to ./src/*, so the example's Metro resolves react-native-css/components to src/components/index.ts (the types-only entry). Babel compiles its export * from "react-native" into __esModule getters, and Fast Refresh reads all of them, including PushNotificationIOS. Its native module (React-RCTPushNotification) isn't linked by default, so iOS's NativeEventEmitter throws.

This redirects that resolution to src/components/index.cts, the lazy CommonJS entry that exports already gives apps, and adds cts to sourceExts so Metro tracks it.

Example-only; published installs resolve index.cjs and were never affected.

@sammoore
sammoore force-pushed the fix/example-components-entry branch from 8386127 to c76967c Compare December 3, 2026 21:58
The root tsconfig maps react-native-css/* to ./src/*, so the example's
Metro resolved react-native-css/components to src/components/index.ts,
the types-only entry. Babel compiles its `export * from "react-native"`
into __esModule getters, and Fast Refresh reads every one, including
PushNotificationIOS. Its native module isn't linked by default, so iOS's
NativeEventEmitter threw and the app crashed at startup.

Redirect that resolution to src/components/index.cts, the lazy CommonJS
entry the package's exports map already gives apps, and add cts to
sourceExts so Metro tracks it. Published installs were never affected.
@danstepanov
danstepanov force-pushed the fix/example-components-entry branch from c76967c to 34fe2f4 Compare December 4, 2026 03:30
@danstepanov
danstepanov merged commit 39899d4 into nativewind:main Dec 4, 2026
6 checks passed
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