Files
orca/config/scripts/mobile-web-app/mobile-web-app-bundle-dependencies.mjs
T
Oleksandr SuvorovandNeil 3bfb2bd094 fix(build): explain missing mobile/ deps instead of failing build:mobile-web (#24325)
mobile/ is a separate pnpm project, so the root pnpm install leaves
mobile/node_modules empty and pnpm build failed in build:mobile-web with
hundreds of unexplained esbuild "Could not resolve" errors.

build-mobile-web-app-bundle now checks for mobile/node_modules first and
exits with the one command that fixes it. The probe path is shared with
the bundle tests' dependency check. CONTRIBUTING documents the install in
Local Setup and points "Before Opening a PR" at it.

Fixes #24324

Co-authored-by: Neil <neil@stably.ai>
2026-10-28 05:27:25 -07:00

34 lines
1.2 KiB
JavaScript

import { existsSync } from 'node:fs'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
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 = MOBILE_WEB_APP_DEPENDENCY_PATH) {
if (existsSync(modulePath)) {
return true
}
if (process.env[MOBILE_WEB_APP_DEPENDENCIES_REQUIRED_ENV] === '1') {
throw new Error(
`[mobile-web-app] ${modulePath} is missing in a job that installs mobile dependencies`
)
}
console.log(SKIP_NOTICE)
return false
}