diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 97590bd251a..f791a59c63e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -53,6 +53,15 @@ pnpm install pnpm dev ``` +`mobile/` is a separate pnpm project with its own lockfile, so the root `pnpm install` leaves its +dependencies uninstalled. `pnpm build` (`build:mobile-web` fails without them) and the lint +passes that cover `mobile/` need them. Install them before building or linting, and again +when `mobile/pnpm-lock.yaml` changes: + +```bash +pnpm -C mobile install --frozen-lockfile +``` + ### Dev Profiles and Parallel Instances `pnpm dev` in a linked Git worktree uses its own userData profile, renderer port, and remote @@ -170,7 +179,7 @@ Avoid vague names like `test`, `misc`, or `changes`. ## Before Opening a PR -Run the same checks that CI runs: +Run the same checks that CI runs, after the `mobile/` install from [Local Setup](#local-setup): ```bash pnpm lint diff --git a/config/scripts/build-mobile-web-app-bundle.mjs b/config/scripts/build-mobile-web-app-bundle.mjs index 4f2d0a32b17..d7ec945614d 100644 --- a/config/scripts/build-mobile-web-app-bundle.mjs +++ b/config/scripts/build-mobile-web-app-bundle.mjs @@ -1,6 +1,7 @@ import { readFile } from 'node:fs/promises' import { readRouteSnapshot } from './mobile-web-app/mobile-web-app-route-snapshot.mjs' -import { realpathSync } from 'node:fs' +import { MOBILE_WEB_APP_DEPENDENCY_PATH } from './mobile-web-app/mobile-web-app-bundle-dependencies.mjs' +import { existsSync, realpathSync } from 'node:fs' import { basename, extname, join, resolve } from 'node:path' import { createRequire } from 'node:module' import { fileURLToPath } from 'node:url' @@ -503,6 +504,12 @@ export async function buildMobileWebAppBundle({ } if (isDirectInvocation(import.meta.url, process.argv[1])) { + if (!existsSync(MOBILE_WEB_APP_DEPENDENCY_PATH)) { + console.error( + '[build-mobile-web-app-bundle] mobile/ dependencies are not installed; run `pnpm -C mobile install --frozen-lockfile`' + ) + process.exit(1) + } try { const { manifest, outDir, routeKeys, entryStaticBytes, chunkCount } = await buildMobileWebAppBundle() diff --git a/config/scripts/mobile-web-app/mobile-web-app-bundle-dependencies.mjs b/config/scripts/mobile-web-app/mobile-web-app-bundle-dependencies.mjs index 36465dbfa1b..4d6dd232805 100644 --- a/config/scripts/mobile-web-app/mobile-web-app-bundle-dependencies.mjs +++ b/config/scripts/mobile-web-app/mobile-web-app-bundle-dependencies.mjs @@ -7,14 +7,19 @@ const projectDir = fileURLToPath(new URL('../../..', import.meta.url)) // Mobile CI requires dependencies so broken installs fail instead of silently skipping their tests. export const MOBILE_WEB_APP_DEPENDENCIES_REQUIRED_ENV = 'ORCA_MOBILE_WEB_APP_DEPS_REQUIRED' +export const MOBILE_WEB_APP_DEPENDENCY_PATH = join( + projectDir, + 'mobile', + 'node_modules', + 'react-native-web' +) + const SKIP_NOTICE = '[mobile-web-app] skipping the bundling tests: mobile/node_modules/react-native-web is absent. ' + 'They run for real in pr.yml, in the mobile_web_app job, which installs mobile dependencies.' // Sharded root tests omit mobile/node_modules; check availability before bundling react-native-web pages. -export function mobileWebAppDependenciesPresent( - modulePath = join(projectDir, 'mobile', 'node_modules', 'react-native-web') -) { +export function mobileWebAppDependenciesPresent(modulePath = MOBILE_WEB_APP_DEPENDENCY_PATH) { if (existsSync(modulePath)) { return true }