Skip to content

refactor: share JavaScript across demo apps - #509

Open
ArekChr wants to merge 4 commits into
callstack:mainfrom
ArekChr:refactor/shared-demo-runtime
Open

ArekChr wants to merge 4 commits into
callstack:mainfrom
ArekChr:refactor/shared-demo-runtime

Conversation

@ArekChr

@ArekChr ArekChr commented Oct 21, 2026 •

Copy link
Copy Markdown

Summary

The vanilla RN demo and the Expo demos duplicate runtime code, and some runtime helpers are currently bundled from a test package. Move the shared code into the private @callstack/shared-runtime workspace and rename the test-only workspace to @callstack/shared-tests.

  • Share the Expo screens, components, styles and JS assets, plus the counter, alert helpers, test IDs and fully-displayed hook used by the demos.
  • Keep app entry registration, Router route files, stores and native configuration local. Preserve the SDK 57/58 labels, native navigation flags and SDK 57-only "Pop To Native" action.
  • Update Jest, Detox, local scripts and CI paths, including the Android logcat wrapper path after changing into apps/AndroidApp.
  • Run the shared integration suites against Expo 57 as well as Expo 58 and vanilla RN. Keep dependency types resolved from each consuming app.

Most file changes are moves and removal of duplicate files. Published packages and generated native bindings are unchanged; no package release is needed.

Validation

  • yarn test:apps: 36 tests passed across vanilla RN, Expo 57, Expo 58 and shared Node tests.
  • yarn test:scripts: 18 tests passed.
  • yarn lint, yarn typecheck, yarn build: passed.
  • iOS JS bundles: vanilla RN, Expo 57 and Expo 58 passed. Web exports: both Expo demos passed.
  • Expo 57/58 tsc --noEmit: passed after navigation codegen/build; generated bindings were restored afterwards.
  • Android logcat wrapper: verified from the Android app directory that it preserves the wrapped command's failure status.

Native iOS host E2E

All 11 Detox tests passed with the JavaScript bundle embedded in the native AppleApp host (no Metro):

  • Vanilla RN: 5/5 — open RN from the native shell, increment the shared-store counter, send a native toast, navigate to native settings and referrals.
  • Expo 57: 3/3 — open Expo from the native shell, send a native toast, and render the RN postMessage bubble.
  • Expo 58: 3/3 — the same Expo host scenarios.

Local environment: Xcode 26.3 / Swift 6.2.4, iOS 26.1 simulator. The Expo simulator apps and their embedded frameworks were signed ad hoc after the build (CODE_SIGNING_ALLOWED=NO otherwise left ExpoFont unsigned). Expo 58 also required a temporary local compatibility workaround in expo-modules-jsi@58.0.4 for the upstream Swift 6.2 constructor-annotation and pointer-capture errors (Expo issue #50067, upstream fix #51040). Dependency originals were restored afterwards; no workaround or generated native files are included in the PR. The unmodified Expo 58 iOS build remains unverified on a compatible Xcode toolchain.

The earlier standalone RNApp attempt reported a missing BrownfieldStore (also reproduced with the original counter). The actual native host initializes that store, and its counter E2E passes. Native Android E2E was not run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active critical findings can remove the required Lottie native dependency from the Expo 57 AAR and cause Android startup failure, while the Jest preset also has an unsatisfied peer version.

3 open issues
What changed in this PR

This pull request refactors the demo applications to share JavaScript through the private @callstack/shared-runtime workspace and renames the test-only workspace to @callstack/shared-tests. It preserves app-specific entry points, native configuration, SDK labels, navigation behavior, and test coverage across vanilla RN, Expo 57, and Expo 58.

Changes:

  • Moves shared Expo screens, components, styles, assets, counters, alerts, test IDs, and display hooks into apps/shared-runtime.
  • Renames and expands shared Jest/Detox infrastructure under apps/shared-tests.
  • Updates consuming apps, dependency metadata, CI workflows, local E2E scripts, Android logcat handling, and documentation.

Review findings:

  • Critical, 2 votes: Preserve the Expo 57 lottie-react-native native-dependency shim in the local wrapper or an equivalent SDK-specific implementation.
  • Critical, 1 vote: Keep the SDK 57 native-dependency reference when using the shared home screen.
  • Moderate, 2 votes: Align Expo 57’s @react-native/jest-preset version with the peer range required by jest-expo@57.0.6.
  • Moderate, 1 vote: Synchronize brownfieldE2E mode in apps/ExpoApp57/entry.tsx as done for Expo 58.
  • Nit, 1 vote: Correct the stale ExpoApp56 label in the Android Detox variants comment.
File Summary
yarn.lock Updates workspace names and shared dependency resolutions.
scripts/​ci-local-appleapp-ios-e2e.sh Uses shared AppleApp Detox helpers.
scripts/​ci-local-androidapp-android-e2e.sh Updates Android Detox and emulator helper paths.
CONTRIBUTING.md Documents the shared workspace structure and test commands.
apps/​shared-tests/​tsconfig.json Adds shared test TypeScript configuration.
apps/​shared-tests/​src/​suites/​userAlert.suite.ts Uses shared runtime alert helpers.
apps/​shared-tests/​src/​suites/​postMessageTab.suite.tsx Adds shared postMessage tests.
apps/​shared-tests/​src/​suites/​homeScreen.suite.tsx Updates shared home-screen tests.
apps/​shared-tests/​src/​suites/​expoRnApp.suite.tsx Tests SDK-specific Expo behavior.
apps/​shared-tests/​src/​suites/​counter.suite.tsx Adds shared counter tests.
apps/​shared-tests/​src/​index.ts Exports shared test suites.
apps/​shared-tests/​src/​global.d.ts Declares shared test globals.
apps/​shared-tests/​scripts/​run-with-android-logcat.sh Captures Android logcat while preserving command status.
apps/​shared-tests/​scripts/​prepare-android-emulator-for-detox.sh Prepares Android emulators for Detox.
apps/​shared-tests/​package.json Renames the test workspace and updates dependencies.
apps/​shared-tests/​jest/​setup.js Provides shared Jest setup and mocks.
apps/​shared-tests/​jest/​expo-config.js Configures Expo Jest resolution.
apps/​shared-tests/​e2eTestIds.test.cjs Verifies Detox IDs against runtime IDs.
apps/​shared-tests/​e2e/​rnAppBrownfield.e2e.js Updates RNApp Detox imports.
apps/​shared-tests/​e2e/​expoPostMessageBrownfield.e2e.js Updates Expo postMessage Detox imports.
apps/​shared-tests/​e2e/​e2eTestIds.cjs Provides shared Detox identifiers.
apps/​shared-tests/​e2e/​detoxTiming.cjs Centralizes Detox timing constants.
apps/​shared-tests/​e2e/​createDetoxJestConfig.cjs Creates shared Detox Jest configuration.
apps/​shared-tests/​e2e/​appleAppExpoBrownfield.e2e.js Updates AppleApp Expo E2E imports.
apps/​shared-tests/​e2e/​appleAppDetoxUtils.cjs Updates AppleApp Detox utilities.
apps/​shared-tests/​e2e/​appleAppBrownfield.e2e.js Updates vanilla AppleApp E2E imports.
apps/​shared-tests/​e2e/​androidAppExpoBrownfield.e2e.js Updates AndroidApp Expo E2E imports.
apps/​shared-tests/​e2e/​androidAppDetoxUtils.cjs Updates AndroidApp Detox utilities.
apps/​shared-tests/​e2e/​androidAppBrownfield.e2e.js Updates vanilla AndroidApp E2E imports.
apps/​shared-tests/​detox-rc-ios-sim-debug.cjs Defines shared iOS simulator Detox configuration.
apps/​shared-tests/​detox-rc-appleapp-ios-sim-debug.cjs Defines shared AppleApp iOS Detox configuration.
apps/​shared-tests/​detox-rc-androidapp-emulator-release.test.cjs Tests Android Detox configuration.
apps/​shared-tests/​detox-rc-androidapp-emulator-release.cjs Defines shared AndroidApp Detox configuration.
apps/​shared-tests/​detox-ios-simulator-device.test.cjs Tests iOS simulator selection.
apps/​shared-tests/​detox-ios-simulator-device.cjs Selects an available iOS simulator.
apps/​shared-tests/​detox-artifacts-config.cjs Centralizes Detox artifact settings.
apps/​shared-tests/​detox-appleapp-variants.cjs Defines AppleApp host variants.
apps/​shared-tests/​detox-androidapp-variants.cjs Defines AndroidApp host variants.
apps/​shared-tests/​detox-android-emulator-device.cjs Resolves Android emulator devices.
apps/​shared-tests/​CHANGELOG.md Updates the workspace name.
apps/​shared-runtime/​src/​userAlert.ts Provides shared alert and E2E-mode helpers.
apps/​shared-runtime/​src/​useMarkFullyDisplayed.ts Provides the shared display hook.
apps/​shared-runtime/​src/​index.ts Exports shared runtime helpers.
apps/​shared-runtime/​src/​expo/​utils/​expo-rn-updates.ts Moves Expo update handling into shared runtime.
apps/​shared-runtime/​src/​expo/​RNApp.tsx Provides the shared Expo RN surface.
apps/​shared-runtime/​src/​expo/​hooks/​use-theme.ts Shares theme selection logic.
apps/​shared-runtime/​src/​expo/​hooks/​use-color-scheme.web.ts Shares web color-scheme handling.
apps/​shared-runtime/​src/​expo/​hooks/​use-color-scheme.ts Shares native color-scheme handling.
apps/​shared-runtime/​src/​expo/​global.css Provides shared Expo web styles.
apps/​shared-runtime/​src/​expo/​constants/​theme.ts Defines shared Expo theme values.
apps/​shared-runtime/​src/​expo/​components/​web-badge.tsx Provides the shared web badge.
apps/​shared-runtime/​src/​expo/​components/​ui/​collapsible.tsx Provides the shared collapsible component.
apps/​shared-runtime/​src/​expo/​components/​themed-view.tsx Provides the shared themed view.
apps/​shared-runtime/​src/​expo/​components/​themed-text.tsx Provides the shared themed text.
apps/​shared-runtime/​src/​expo/​components/​postMessage/​MessageBubble.tsx Provides shared postMessage bubbles.
apps/​shared-runtime/​src/​expo/​components/​postMessage/​Message.ts Defines shared postMessage data.
apps/​shared-runtime/​src/​expo/​components/​hint-row.tsx Provides shared Expo hint rows.
apps/​shared-runtime/​src/​expo/​components/​external-link.tsx Provides shared external-link behavior.
apps/​shared-runtime/​src/​expo/​components/​app-tabs.web.tsx Provides shared web tab navigation.
apps/​shared-runtime/​src/​expo/​components/​app-tabs.tsx Provides shared native tab navigation.
apps/​shared-runtime/​src/​expo/​components/​animated-icon.web.tsx Provides the shared web animated icon.
apps/​shared-runtime/​src/​expo/​components/​animated-icon.tsx Provides the shared native animated icon.
apps/​shared-runtime/​src/​expo/​components/​animated-icon.module.css Styles the shared web animated icon.
apps/​shared-runtime/​src/​expo/​app/​postMessage.tsx Provides the shared postMessage screen.
apps/​shared-runtime/​src/​expo/​app/​layout.tsx Provides the shared Router layout.
apps/​shared-runtime/​src/​expo/​app/​home.tsx Provides the shared Expo home screen.
apps/​shared-runtime/​src/​expo/​app/​explore.tsx Provides the shared Expo explore screen.
apps/​shared-runtime/​src/​e2eTestIds.ts Defines shared runtime Detox IDs.
apps/​shared-runtime/​src/​components/​counter.tsx Provides the shared counter component.
apps/​shared-runtime/​README.md Documents runtime ownership and boundaries.
apps/​shared-runtime/​package.json Defines the private runtime workspace.
apps/​shared-runtime/​eslint.config.mjs Applies the shared ESLint configuration.
apps/​shared-runtime/​assets/​images/​tabIcons/​home@3x.png Adds the shared high-density home icon.
apps/​shared-runtime/​assets/​images/​tabIcons/​home@2x.png Adds the shared medium-density home icon.
apps/​shared-runtime/​assets/​images/​tabIcons/​home.png Adds the shared home icon.
apps/​shared-runtime/​assets/​images/​tabIcons/​explore@3x.png Adds the shared high-density explore icon.
apps/​shared-runtime/​assets/​images/​tabIcons/​explore@2x.png Adds the shared medium-density explore icon.
apps/​shared-runtime/​assets/​images/​tabIcons/​explore.png Adds the shared explore icon.
apps/​shared-runtime/​assets/​images/​expo-logo.png Adds the shared Expo logo.
apps/​shared-runtime/​assets/​images/​expo-badge.png Adds the shared light Expo badge.
apps/​shared-runtime/​assets/​images/​expo-badge-white.png Adds the shared dark Expo badge.
apps/​RNApp/​tsconfig.json Preserves shared workspace type resolution.
apps/​RNApp/​src/​HomeScreen.tsx Uses shared IDs, counter, and display hook.
apps/​RNApp/​src/​App.tsx Uses shared runtime props and helpers.
apps/​RNApp/​package.json Switches to shared runtime and test workspaces.
apps/​RNApp/​jest.setup.js Uses the renamed shared Jest setup.
apps/​RNApp/​jest.config.js Transforms shared workspace sources.
apps/​RNApp/​e2e/​jest.config.cjs Uses shared Detox configuration.
apps/​RNApp/​.detoxrc.cjs Uses shared iOS Detox configuration.
apps/​RNApp/​__tests__/​brownfield.example.test.tsx Runs shared RN integration suites.
apps/​README.md Documents the shared JavaScript workspaces.
apps/​ExpoApp58/​tsconfig.json Preserves shared type and symlink resolution.
apps/​ExpoApp58/​src/​hooks/​use-theme.ts Removes the duplicated theme hook.
apps/​ExpoApp58/​src/​hooks/​use-mark-fully-displayed.ts Removes the duplicated display hook.
apps/​ExpoApp58/​src/​hooks/​use-color-scheme.ts Removes the duplicated color-scheme hook.
apps/​ExpoApp58/​src/​constants/​theme.ts Removes duplicated theme constants.
apps/​ExpoApp58/​src/​components/​web-badge.tsx Removes the duplicated web badge.
apps/​ExpoApp58/​src/​components/​themed-view.tsx Removes the duplicated themed view.
apps/​ExpoApp58/​src/​components/​themed-text.tsx Removes the duplicated themed text.
apps/​ExpoApp58/​src/​components/​postMessage/​Message.ts Removes duplicated message typing.
apps/​ExpoApp58/​src/​components/​counter/​index.tsx Removes the duplicated counter.
apps/​ExpoApp58/​src/​components/​animated-icon.web.tsx Removes the duplicated web animation.
apps/​ExpoApp58/​src/​components/​animated-icon.tsx Removes the duplicated native animation.
apps/​ExpoApp58/​src/​components/​animated-icon.module.css Removes duplicated animation styles.
apps/​ExpoApp58/​src/​app/​postMessage.tsx Re-exports the shared postMessage screen.
apps/​ExpoApp58/​src/​app/​index.tsx Wraps the shared SDK 58 home screen.
apps/​ExpoApp58/​src/​app/​explore.tsx Re-exports the shared explore screen.
apps/​ExpoApp58/​src/​app/​_layout.tsx Re-exports the shared Router layout.
apps/​ExpoApp58/​RNApp.tsx Wraps shared RNApp behavior for SDK 58.
apps/​ExpoApp58/​package.json Adds shared runtime and test dependencies.
apps/​ExpoApp58/​jest.setup.js Uses shared Jest setup.
apps/​ExpoApp58/​jest.config.js Uses shared Expo Jest configuration.
apps/​ExpoApp58/​entry.tsx Uses shared runtime helpers and E2E synchronization.
apps/​ExpoApp58/​__tests__/​brownfield.example.test.tsx Runs shared Expo 58 suites.
apps/​ExpoApp57/​tsconfig.json Preserves shared type and symlink resolution.
apps/​ExpoApp57/​src/​utils/​expo-rn-updates.ts Removes the duplicated update helper.
apps/​ExpoApp57/​src/​hooks/​use-mark-fully-displayed.ts Removes the duplicated display hook.
apps/​ExpoApp57/​src/​hooks/​use-color-scheme.web.ts Removes the duplicated web color hook.
apps/​ExpoApp57/​src/​global.css Removes duplicated global styles.
apps/​ExpoApp57/​src/​components/​ui/​collapsible.tsx Removes the duplicated collapsible component.
apps/​ExpoApp57/​src/​components/​themed-view.tsx Removes the duplicated themed view.
apps/​ExpoApp57/​src/​components/​postMessage/​MessageBubble.tsx Removes the duplicated message bubble.
apps/​ExpoApp57/​src/​components/​hint-row.tsx Removes the duplicated hint row.
apps/​ExpoApp57/​src/​components/​external-link.tsx Removes the duplicated external link.
apps/​ExpoApp57/​src/​components/​counter/​index.tsx Removes the duplicated counter.
apps/​ExpoApp57/​src/​components/​app-tabs.web.tsx Removes the duplicated web tabs.
apps/​ExpoApp57/​src/​components/​app-tabs.tsx Removes the duplicated native tabs.
apps/​ExpoApp57/​src/​app/​postMessage.tsx Re-exports the shared postMessage screen.
apps/​ExpoApp57/​src/​app/​index.tsx Wraps the shared SDK 57 home screen.
apps/​ExpoApp57/​src/​app/​explore.tsx Re-exports the shared explore screen.
apps/​ExpoApp57/​src/​app/​_layout.tsx Re-exports the shared Router layout.
apps/​ExpoApp57/​RNApp.tsx Wraps shared RNApp behavior for SDK 57.
apps/​ExpoApp57/​package.json Adds shared runtime, test, and Jest dependencies.
apps/​ExpoApp57/​jest/​cssMock.js Mocks CSS imports for Jest.
apps/​ExpoApp57/​jest.setup.js Adds shared Jest setup and safe-area mocks.
apps/​ExpoApp57/​jest.config.js Adds Expo 57 Jest configuration.
apps/​ExpoApp57/​entry.tsx Uses the shared fully-displayed hook.
apps/​ExpoApp57/​__tests__/​brownfield.example.test.tsx Runs shared Expo 57 suites.
apps/​AppleApp/​package.json Uses the renamed shared test workspace.
apps/​AppleApp/​e2e/​jest.config.expo58.cjs Uses shared Expo 58 E2E configuration.
apps/​AppleApp/​e2e/​jest.config.expo57.cjs Uses shared Expo 57 E2E configuration.
apps/​AppleApp/​e2e/​jest.config.cjs Uses shared vanilla E2E configuration.
apps/​AppleApp/​Brownfield Apple App/​E2eTestIds.swift Updates native E2E ID references.
apps/​AppleApp/​.detoxrc.expo58.cjs Uses shared Expo 58 Detox settings.
apps/​AppleApp/​.detoxrc.expo57.cjs Uses shared Expo 57 Detox settings.
apps/​AppleApp/​.detoxrc.cjs Uses shared vanilla Detox settings.
apps/​AndroidApp/​package.json Uses the renamed shared test workspace.
apps/​AndroidApp/​e2e/​jest.config.expo58.cjs Uses shared Expo 58 E2E configuration.
apps/​AndroidApp/​e2e/​jest.config.expo57.cjs Uses shared Expo 57 E2E configuration.
apps/​AndroidApp/​e2e/​jest.config.cjs Uses shared vanilla E2E configuration.
apps/​AndroidApp/​app/​src/​main/​java/​com/​callstack/​brownfield/​android/​example/​E2eTestIds.kt Updates native E2E ID references.
apps/​AndroidApp/​.detoxrc.expo58.cjs Uses shared Expo 58 Detox settings.
apps/​AndroidApp/​.detoxrc.expo57.cjs Uses shared Expo 57 Detox settings.
apps/​AndroidApp/​.detoxrc.cjs Uses shared vanilla Detox settings.
.github/​workflows/​ci.yml Updates CI path filters for shared workspaces.
.github/​actions/​appleapp-road-test/​action.yml Updates AppleApp shared paths and cache inputs.
.github/​actions/​androidapp-road-test/​action.yml Updates AndroidApp helpers and logcat invocation.

Review effort: Lite

Comment thread apps/ExpoApp57/src/app/index.tsx Resolved
Comment thread apps/ExpoApp57/package.json Resolved

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.

3 participants