-
Notifications
You must be signed in to change notification settings - Fork 191
fix metro resolver for monorepo #1002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix metro resolver for monorepo #1002
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughUpdates CI workflows to adjust Yarn flags and verbosity, adds Babel config and @babel/runtime, restructures root workspaces with nohoist rules, modifies Metro resolver settings in two apps, refreshes demo-app README, and updates a demo-app test to assert Text content instead of Button titles. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant GH as GitHub Actions
participant Yarn as Yarn Workspaces
Note over GH,Yarn: mobile-sdk-demo-ci "Build dependencies (topological)"
GH->>Yarn: yarn workspaces foreach -R -t --from demo-app run build:deps
Yarn-->>GH: Build tasks executed in topo order (selected workspaces)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package.json (1)
41-48: Avoid pinning RN/React via bothresolutionsand rootdependencies.Keeping
react/react-nativeat the root creates an extra copy and fights your goal of keeping RN local to each app/workspace. This duplication is a common cause of Metro/Native module resolution errors (e.g., multiple Reacts).Action:
- Keep versions in
resolutionsto enforce consistency.- Remove
reactandreact-nativefrom rootdependencies.- Ensure each RN app/package declares its own
reactandreact-nativedependencies.This should also help with the reported “Cannot find module '@react-native-picker/picker'” and
react-native-svg-circle-country-flagsissues once those deps are added to the correct workspaces."dependencies": { - "@babel/runtime": "^7.28.3", - "react": "^18.3.1", - "react-native": "0.76.9" + "@babel/runtime": "^7.28.3" },
🧹 Nitpick comments (7)
app/metro.config.cjs (1)
213-214: Sync Metro flags with Jest and confirm version support
• Metro-config v0.76.9 includes bothresolver.unstable_enableSymlinksandresolver.disableHierarchicalLookupflags (unpkg.com, github.com).
• Mirror these options in your Jest setup to ensure module resolution parity, e.g. in jest.config.js:module.exports = { resolver: "metro-resolver", resolverOptions: { unstable_enableSymlinks: true, disableHierarchicalLookup: true, }, // … };Existing declarations of
react-native-svg-circle-country-flagsin app and@react-native-picker/pickerin demo-app satisfy the nohoist requirements.babel.config.js (1)
5-7: Scope RN Babel preset to mobile workspaces & enable runtime + reanimated plugins
Limit the RN preset toapp,packages/mobile-sdk-alpha, and itsdemo-appto avoid Hardhat/Node-tooling collisions; detected@babel/runtimeandreact-native-reanimatedusage—add corresponding plugins.module.exports = { - presets: ['module:@react-native/babel-preset'], -}; + overrides: [ + { + test: ['./app', './packages/mobile-sdk-alpha', './packages/mobile-sdk-alpha/demo-app'], + presets: ['module:@react-native/babel-preset'], + plugins: [ + ['@babel/plugin-transform-runtime', {helpers: true}], + 'react-native-reanimated/plugin', + ], + }, + ], +};packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx (1)
12-18: Reduce brittleness: avoid strict equality on Text.children; flatten or use testing-library queriesIn RN, Text children can be arrays/fragments/nested nodes; strict
=== labelcan miss matches and cause flaky tests. Flatten text or switch to @testing-library/react-native.Minimal change approach:
- const textNodes = rendered.root.findAllByType(Text); - expect(textNodes.some(node => node.props.children === 'Self Demo App')).toBe(true); - ['✅ Generate Mock Data', '⏳ Register Document', '⏳ Prove QR Code'].forEach(label => { - expect(textNodes.some(node => node.props.children === label)).toBe(true); - }); + const textNodes = rendered.root.findAllByType(Text); + const toText = (n) => { + const c = n.props.children; + if (Array.isArray(c)) return c.flat(Infinity).join(''); + return typeof c === 'string' ? c : (c ?? '').toString(); + }; + const contents = textNodes.map(toText); + expect(contents).toContain('Self Demo App'); + ['✅ Generate Mock Data', '⏳ Register Document', '⏳ Prove QR Code'].forEach(label => { + expect(contents).toContain(label); + });If allowed, prefer:
- import renderer from 'react-test-renderer'; - import { Text } from 'react-native'; + import { render, screen } from '@testing-library/react-native'; ... - const rendered = renderer.create(<App />); - const textNodes = rendered.root.findAllByType(Text); - ... - rendered.unmount(); + const { unmount } = render(<App />); + expect(screen.getByText('Self Demo App')).toBeTruthy(); + ['✅ Generate Mock Data', '⏳ Register Document', '⏳ Prove QR Code'].forEach(t => { + expect(screen.getByText(t)).toBeTruthy(); + }); + unmount();packages/mobile-sdk-alpha/demo-app/README.md (2)
7-20: Add cache reset steps after toggling New Architecture/Fabric.Switching Fabric/TM often requires a full native clean; otherwise builds can fail nondeterministically. Please add explicit steps:
- Android:
cd android && ./gradlew clean- iOS:
cd ios && rm -rf Pods Podfile.lock && pod install(orpod deintegrate && pod install)This will reduce CI and local flakiness when devs flip the switches.
21-33: Add cache reset steps after toggling Hermes.Similar to Fabric, toggling Hermes typically requires a clean native rebuild (Gradle clean and Pods reinstall). Adding these commands here will prevent “duplicate symbol” and missing-header issues post-toggle.
package.json (1)
22-40: Add preflight scripts to catch missing RN deps early.Given current failures:
- Missing:
@react-native-picker/picker- Missing:
react-native-svg-circle-country-flagsAdd a workspace guard script that checks each RN app for required native deps and fails fast with actionable messages. This prevents opaque Metro errors later.
I can generate a small Node script to scan RN imports and verify workspace
dependencies; say the word..github/workflows/mobile-sdk-demo-ci.yml (1)
26-31: Fail fast if demo-app’s native deps are missing.To surface the known missing modules earlier, add a quick dependency check before tests/build. This saves CI minutes and yields clearer errors.
Example:
- name: Run demo app tests run: | - yarn workspace demo-app test + node -e "const p=require('./packages/mobile-sdk-alpha/demo-app/package.json');const d=new Set(Object.keys({...p.dependencies,...p.devDependencies}));const req=['@react-native-picker/picker','react-native-svg-circle-country-flags'];const miss=req.filter(x=>!d.has(x)); if(miss.length){console.error('Missing deps in demo-app:', miss); process.exit(1)}" + yarn workspace demo-app test
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (8)
.github/workflows/mobile-e2e.yml(2 hunks).github/workflows/mobile-sdk-demo-ci.yml(1 hunks)app/metro.config.cjs(1 hunks)babel.config.js(1 hunks)package.json(2 hunks)packages/mobile-sdk-alpha/demo-app/README.md(1 hunks)packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx(1 hunks)packages/mobile-sdk-alpha/demo-app/metro.config.cjs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{test,spec}.{ts,js,tsx,jsx}
⚙️ CodeRabbit configuration file
**/*.{test,spec}.{ts,js,tsx,jsx}: Review test files for:
- Test coverage completeness
- Test case quality and edge cases
- Mock usage appropriateness
- Test readability and maintainability
Files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}: Review alpha mobile SDK code for:
- API consistency with core SDK
- Platform-neutral abstractions
- Performance considerations
- Clear experimental notes or TODOs
Files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
🧠 Learnings (27)
📓 Common learnings
Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: After review changes, re-run yarn nice, yarn test, yarn types
Learnt from: CR
PR: selfxyz/self#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:29:47.727Z
Learning: Before PRs, ensure yarn build succeeds for all workspaces
Learnt from: CR
PR: selfxyz/self#0
File: .cursorrules:0-0
Timestamp: 2025-08-24T18:52:25.796Z
Learning: Use yarn scripts: yarn ios/android for builds, yarn test for unit tests, and Fastlane for deployments
Learnt from: CR
PR: selfxyz/self#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:29:47.727Z
Learning: After addressing review feedback, re-run yarn nice, yarn test, yarn types
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Run yarn nice, yarn types, and yarn test before commits and PRs
Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: yarn nice passes (fixes linting and formatting) before PR
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to app/jest.config.cjs : Use Jest in the app with a React Native preset configured in app/jest.config.cjs
Applied to files:
babel.config.js
📚 Learning: 2025-08-29T15:30:12.210Z
Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: Verify iOS build succeeds via yarn ios
Applied to files:
.github/workflows/mobile-e2e.yml
📚 Learning: 2025-08-24T18:52:25.796Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursorrules:0-0
Timestamp: 2025-08-24T18:52:25.796Z
Learning: Use yarn scripts: yarn ios/android for builds, yarn test for unit tests, and Fastlane for deployments
Applied to files:
.github/workflows/mobile-e2e.yml.github/workflows/mobile-sdk-demo-ci.yml
📚 Learning: 2025-08-29T15:30:12.210Z
Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: Verify Android build succeeds via yarn android
Applied to files:
.github/workflows/mobile-e2e.yml
📚 Learning: 2025-08-29T15:30:12.210Z
Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: From app/ios, run bundle install && bundle exec pod install (or from app run npx pod-install)
Applied to files:
.github/workflows/mobile-e2e.yml
📚 Learning: 2025-08-29T15:30:12.210Z
Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: Run the app with yarn ios during development as needed
Applied to files:
.github/workflows/mobile-e2e.yml
📚 Learning: 2025-08-25T14:25:57.586Z
Learnt from: aaronmgdr
PR: selfxyz/self#951
File: app/src/providers/authProvider.web.tsx:17-18
Timestamp: 2025-08-25T14:25:57.586Z
Learning: The selfxyz/mobile-sdk-alpha/constants/analytics import path is properly configured with SDK exports, Metro aliases, and TypeScript resolution. Import changes from @/consts/analytics to this path are part of valid analytics migration, not TypeScript resolution issues.
Applied to files:
packages/mobile-sdk-alpha/demo-app/metro.config.cjs
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/package.json : Enable tree shaking for the SDK (e.g., ensure 'sideEffects' is correctly set in package.json and exports are ESM-friendly)
Applied to files:
packages/mobile-sdk-alpha/demo-app/metro.config.cjspackage.json
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/README.md : Document new/updated SDK modules and usage in packages/mobile-sdk-alpha/README.md
Applied to files:
packages/mobile-sdk-alpha/demo-app/README.md
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/demo/** : Provide an in-SDK lightweight React Native demo under packages/mobile-sdk-alpha/demo/
Applied to files:
packages/mobile-sdk-alpha/demo-app/README.mdpackages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:30:12.210Z
Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: Document complex native module changes for AI review
Applied to files:
packages/mobile-sdk-alpha/demo-app/README.md
📚 Learning: 2025-08-24T18:55:07.940Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/technical-specification.mdc:0-0
Timestamp: 2025-08-24T18:55:07.940Z
Learning: Applies to package.json : Distribute the SDK via npm/yarn with proper package metadata
Applied to files:
package.json
📚 Learning: 2025-06-30T15:51:11.193Z
Learnt from: transphorm
PR: selfxyz/self#636
File: app/android/app/build.gradle:76-76
Timestamp: 2025-06-30T15:51:11.193Z
Learning: For React Native 0.80, the correct JSC version is `io.github.react-native-community:jsc-android:2026004.+`. This version was specifically built with Android NDK r23 to align with React Native 0.80's NDK requirements and prevent compatibility issues. The `2026004` version pattern is the official version for RN 0.80, not an outdated pin.
Applied to files:
package.json
📚 Learning: 2025-06-30T15:27:13.795Z
Learnt from: transphorm
PR: selfxyz/self#636
File: app/ios/Podfile:14-14
Timestamp: 2025-06-30T15:27:13.795Z
Learning: React Native 0.80 supports iOS 15.1 as the minimum deployment target, not iOS 16.0. This allows for broader device compatibility while still being compatible with the React Native 0.80 upgrade.
Applied to files:
package.json
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Use actual imports from selfxyz/mobile-sdk-alpha in tests
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Do NOT mock selfxyz/mobile-sdk-alpha in tests (avoid jest.mock('selfxyz/mobile-sdk-alpha') and replacing real functions with mocks)
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Never use real user PII in tests; use only synthetic, anonymized, or approved test vectors
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Verify extractMRZInfo() using published sample MRZ strings (e.g., ICAO examples)
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Write integration tests that exercise the real validation logic (not mocks)
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Ensure parseNFCResponse() works with representative, synthetic NFC data
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Test isPassportDataValid() with realistic synthetic passport data (never real user data)
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/tests/setup.ts : Provide Vitest setup file at packages/mobile-sdk-alpha/tests/setup.ts to suppress console noise
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-24T18:52:25.796Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursorrules:0-0
Timestamp: 2025-08-24T18:52:25.796Z
Learning: Applies to tests/src/**/*.{test,spec}.{ts,tsx,js,jsx} : Use renderHook for custom hook testing
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-26T14:41:41.821Z
Learnt from: shazarre
PR: selfxyz/self#936
File: app/src/screens/aesop/PassportOnboardingScreen.tsx:0-0
Timestamp: 2025-08-26T14:41:41.821Z
Learning: When verifying provider hierarchies in React Native apps, always check the main App.tsx file at the app root, not just navigation/index.tsx and layout files, as providers are often configured at the top-level App component.
Applied to files:
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx
📚 Learning: 2025-08-29T15:29:47.727Z
Learnt from: CR
PR: selfxyz/self#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:29:47.727Z
Learning: Before PRs, ensure yarn build succeeds for all workspaces
Applied to files:
.github/workflows/mobile-sdk-demo-ci.yml
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to app/package.json : Expose a 'test:build' script in the app's package.json that builds deps, types, performs bundle analysis, and runs tests
Applied to files:
.github/workflows/mobile-sdk-demo-ci.yml
🪛 LanguageTool
packages/mobile-sdk-alpha/demo-app/README.md
[grammar] ~37-~37: There might be a mistake here.
Context: ...ttings - New Architecture: Disabled - Hermes: Enabled ## Build Commands Af...
(QB_NEW_EN)
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-ios
- GitHub Check: e2e-ios
🔇 Additional comments (5)
packages/mobile-sdk-alpha/demo-app/__tests__/App.test.tsx (1)
7-7: Import looks fine given the test strategyUsing Text directly is OK here; if you migrate to testing-library, this import becomes unnecessary.
.github/workflows/mobile-e2e.yml (2)
93-93: Good call: surface build:deps logs in CIDropping --silent improves diagnosability for monorepo resolution issues.
228-228: Same here for iOS path—keep verbose logs for dependency buildThis will help trace Metro/Yarn workspace resolution problems early in the job.
packages/mobile-sdk-alpha/demo-app/README.md (1)
42-47: No action needed:yarn cleanscript is present in demo-app
The"clean"script is defined in packages/mobile-sdk-alpha/demo-app/package.json, so the documented workflow works as expected..github/workflows/mobile-sdk-demo-ci.yml (1)
25-25: Confirm-R -t --from demo-appstill builds transitive dependencies.Previously
-A -t --from demo-appguaranteed dependents/dependencies coverage. With-R, selection semantics change in Yarn 4 and may skip some needed builds.Please verify the actual workspace set before building, and consider adding an explicit list step.
Proposed tweak:
- yarn workspaces foreach -R -t --from demo-app run build + yarn workspaces list -R --from demo-app --json + yarn workspaces foreach -R -t --from demo-app run buildExpected: the list includes
@selfxyz/mobile-sdk-alphaand any internal packages the demo app imports.
| "workspaces": { | ||
| "packages": [ | ||
| "app", | ||
| "circuits", | ||
| "common", | ||
| "contracts", | ||
| "packages/*", | ||
| "prover/tests", | ||
| "sdk/*", | ||
| "scripts/tests", | ||
| "packages/mobile-sdk-alpha/demo-app" | ||
| ], | ||
| "nohoist": [ | ||
| "**/react-native", | ||
| "**/react-native/**", | ||
| "**/@babel/runtime", | ||
| "**/@babel/runtime/**" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yarn 4 ignores workspaces.nohoist; use .yarnrc.yml hoisting controls instead.
In Yarn Berry (v2+), nohoist is not supported. With packageManager: "[email protected]", these entries won’t take effect and will undermine the RN-localization intent, causing “Cannot find module …” at runtime.
Action:
- Remove
workspaces.nohoistfrom package.json. - In
.yarnrc.yml, set:nodeLinker: node-modulesnmHoistingLimits: workspaces(ordependenciesif you prefer tighter limits)- Optional:
pnpMode: looseonly if you move to PnP later.
This aligns with RN’s monorepo guidance and Metro symlink resolution.
Apply:
"workspaces": {
- "packages": [
+ "packages": [
"app",
"circuits",
"common",
"contracts",
"packages/*",
"prover/tests",
"sdk/*",
"scripts/tests",
"packages/mobile-sdk-alpha/demo-app"
- ],
- "nohoist": [
- "**/react-native",
- "**/react-native/**",
- "**/@babel/runtime",
- "**/@babel/runtime/**"
- ]
+ ]
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "workspaces": { | |
| "packages": [ | |
| "app", | |
| "circuits", | |
| "common", | |
| "contracts", | |
| "packages/*", | |
| "prover/tests", | |
| "sdk/*", | |
| "scripts/tests", | |
| "packages/mobile-sdk-alpha/demo-app" | |
| ], | |
| "nohoist": [ | |
| "**/react-native", | |
| "**/react-native/**", | |
| "**/@babel/runtime", | |
| "**/@babel/runtime/**" | |
| ] | |
| }, | |
| "workspaces": { | |
| "packages": [ | |
| "app", | |
| "circuits", | |
| "common", | |
| "contracts", | |
| "packages/*", | |
| "prover/tests", | |
| "sdk/*", | |
| "scripts/tests", | |
| "packages/mobile-sdk-alpha/demo-app" | |
| ] | |
| }, |
🤖 Prompt for AI Agents
In package.json around lines 3 to 21, the workspaces.nohoist section is present
but Yarn v2+ (including [email protected]) ignores nohoist, which breaks React Native
module resolution; remove the entire workspaces.nohoist key from package.json
and instead add/update .yarnrc.yml to use node-modules linking and controlled
hoisting by setting nodeLinker: node-modules and nmHoistingLimits: workspaces
(or nmHoistingLimits: dependencies for stricter hoisting), and optionally set
pnpMode: loose only if you later adopt PnP; ensure packageManager remains
correct.
| "dependencies": { | ||
| "@babel/runtime": "^7.28.3", | ||
| "react": "^18.3.1", | ||
| "react-native": "0.76.9" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Place @babel/runtime where it’s actually required (per package).
@babel/runtime should be a direct dependency of each package whose emitted JS uses helpers (async/await, generators). Keeping it only at the root risks accidental breakage if hoisting changes. Recommend adding it to:
@selfxyz/mobile-sdk-alpha- any RN app packages that compile TS/JS with the RN Babel preset
You can keep the root resolutions pin for consistency across workspaces.
🤖 Prompt for AI Agents
In package.json around lines 49 to 53, @babel/runtime is declared only at the
root but should be a direct dependency of any workspace packages that emit code
using Babel helpers (e.g., @selfxyz/mobile-sdk-alpha and RN app packages using
the RN Babel preset); add @babel/runtime@^7.28.3 (or the pinned resolution
version) to each such package.json dependencies, keep the root resolutions pin
for version consistency, and run yarn/npm install and a workspace build to
verify no hoisting-related runtime failures.
| unstable_enableSymlinks: true, | ||
| disableHierarchicalLookup: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Monorepo resolution: good addition; ensure Jest/moduleNameMapper mirrors Metro
Enabling symlinks and disabling hierarchical lookup helps Metro, but Jest (or ts-jest) won’t honor this automatically. Mirror critical aliases/nodeModulesPaths in Jest config to avoid test-time “Cannot find module …” even when Metro works.
If Jest is used here, confirm mappings with:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
fd -a "jest.config.*" packages/mobile-sdk-alpha/demo-app || echo "ℹ️ No Jest config in demo-app; ensure upstream config maps RN deps if tests run here."Length of output: 148
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Metro config ==="
sed -n '1,200p' packages/mobile-sdk-alpha/demo-app/metro.config.cjs
echo "=== Jest config ==="
sed -n '1,200p' packages/mobile-sdk-alpha/demo-app/jest.config.cjsLength of output: 1620
Mirror Metro resolver settings in demo-app/jest.config.cjs
Add moduleDirectories ['node_modules','/../../../node_modules'] and moduleNameMapper aliases for @babel/runtime, react, react-native and @selfxyz/* to match Metro’s extraNodeModules and nodeModulesPaths.
🤖 Prompt for AI Agents
In packages/mobile-sdk-alpha/demo-app/jest.config.cjs (mirror Metro resolver
settings from metro.config.cjs lines ~22-23): add moduleDirectories:
['node_modules','<rootDir>/../../../node_modules'] and add moduleNameMapper
entries that point Jest to the same node_modules used by Metro — e.g. map
^@babel/runtime(.*)$ to '<rootDir>/../../../node_modules/@babel/runtime$1',
^react$ to '<rootDir>/../../../node_modules/react', ^react-native$ to
'<rootDir>/../../../node_modules/react-native', and ^@selfxyz/(.*)$ to
'<rootDir>/../../../node_modules/@selfxyz/$1'; update the existing
jest.config.cjs export to include these keys so Jest resolves modules the same
way Metro does.
Summary
Testing
yarn workspaces foreach -p -v --topological-dev --since=HEAD run nice --if-present(fails: Cannot find module '@react-native-picker/picker')yarn lint(fails: Unable to resolve module 'react-native-svg-circle-country-flags')yarn build(fails: build failed in @selfxyz/mobile-sdk-alpha)yarn workspace @selfxyz/contracts build(fails: Hardhat config error)yarn types(fails: Cannot find module 'react-native-svg-circle-country-flags')yarn workspace @selfxyz/mobile-app test(fails: Cannot find module '@react-native-picker/picker')yarn workspace demo-app test*(fails: renders menu buttons)yarn workspace demo-app build(fails: Cannot find module '@react-native-picker/picker')https://chatgpt.com/codex/tasks/task_b_68b9dd8390f0832db7acf96700d85dd0
Summary by CodeRabbit