-
Notifications
You must be signed in to change notification settings - Fork 187
fix(android): 打补丁让 @expo/cli 相对 --entry-file 按项目根解析(SDK 54 Windows + pnpm monorepo release 构建) - #758
Open
k6G52m4Dz75W wants to merge 1 commit into
Open
Conversation
...t project root SDK 54's @expo/cli (54.0.23) fails to bundle a release APK when react-native's gradle plugin passes a relative --entry-file on Windows inside a pnpm monorepo: resolveRealEntryFilePath() returns the relative path unchanged, so Metro resolves it against the monorepo root instead of the app dir and fails with 'Unable to resolve module ./index.js from <repo-root>/'. Mirror the upstream fix from expo/expo#44414 (SDK 55, not backported): resolve a relative entry-file to an absolute path against the project root before the existing realpath handling. Verified end-to-end: gradle assembleRelease now produces a signed APK; relative and absolute --entry-file both bundle. Applied via pnpm patch (patches/@expo__cli@54.0.23.patch) so pnpm install re-applies it automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 Windows + pnpm monorepo 环境下,用 Expo SDK 54 构建 Android release APK 会失败。
gradle assembleRelease的createBundleReleaseJsAndAssets阶段必现报错:Metro 把 monorepo 根目录当作解析基准,而不是 app 目录。原因是 react-native 的 gradle 插件在 Windows 上传递相对路径的
--entry-file(其File.cliPath()在 macOS/Linux 返回绝对路径、Windows 返回相对路径),而 SDK 54 的@expo/cli(resolveRealEntryFilePath)对相对路径原样返回,没有按项目根解析成绝对路径。macOS 上不触发(gradle 传绝对路径),所以上游在 macOS 构建正常、Windows 用户无法本地出包。
上游反馈
修复
移植 expo/expo#44414 的核心改动:
resolveRealEntryFilePath对相对路径先基于projectRoot解析为绝对路径,再走原有 realpath 逻辑:通过 pnpm patch(
patches/@expo__cli@54.0.23.patch)应用,pnpm install自动重新应用,可持续维护。升级 SDK 55+ 后可移除。验证
expo export:embed相对 entry-file:Bundled 成功(修复前Unable to resolve ./index.js from <repo-root>)gradle assembleRelease:BUILD SUCCESSFUL,产出签名 APK--entry-file均能打包备注
@expo/cli54.0.23);SDK 55 已内置修复,无需此补丁metro.config.js中手动watchFolders/nodeModulesPaths属废弃写法(expo 官方建议清理),与本 PR 独立