expo-modules-autolinking 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 3.0.4 — 2025-08-26
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 3.0.3 — 2025-08-21
14
18
 
15
19
  _This version does not introduce any user-facing changes._
@@ -19,6 +23,7 @@ _This version does not introduce any user-facing changes._
19
23
  ### 🐛 Bug fixes
20
24
 
21
25
  - Regression: Use the command's root instead of the app's root when resolving extra build dependencies ([#38907](https://github.com/expo/expo/pull/38907) by [@kitten](https://github.com/kitten))
26
+ - [Android] Update resolveAppProjectConfigAsync to use sourceDir ([#39125](https://github.com/expo/expo/pull/39125) by [@gabrieldonadel](https://github.com/gabrieldonadel))
22
27
 
23
28
  ### 💡 Others
24
29
 
@@ -11,6 +11,7 @@ import org.gradle.api.file.Directory
11
11
  import org.gradle.api.file.RegularFile
12
12
  import org.gradle.api.provider.Provider
13
13
  import org.gradle.api.tasks.TaskProvider
14
+ import java.io.File
14
15
  import java.nio.file.Paths
15
16
 
16
17
  const val generatedPackageListNamespace = "expo.modules"
@@ -49,7 +50,7 @@ open class ExpoAutolinkingPlugin : Plugin<Project> {
49
50
  project.logger.quiet("")
50
51
 
51
52
  // Creates a task that generates a list of expo modules.
52
- val generatePackagesList = createGeneratePackagesListTask(project, gradleExtension.options, gradleExtension.hash)
53
+ val generatePackagesList = createGeneratePackagesListTask(project, gradleExtension.options, gradleExtension.hash, gradleExtension.projectRoot)
53
54
 
54
55
  // Ensures that the task is executed before the build.
55
56
  project.tasks
@@ -79,12 +80,12 @@ open class ExpoAutolinkingPlugin : Plugin<Project> {
79
80
  return project.layout.buildDirectory.file(packageListRelativePath)
80
81
  }
81
82
 
82
- fun createGeneratePackagesListTask(project: Project, options: AutolinkingOptions, hash: String): TaskProvider<GeneratePackagesListTask> {
83
+ fun createGeneratePackagesListTask(project: Project, options: AutolinkingOptions, hash: String, projectRoot: File): TaskProvider<GeneratePackagesListTask> {
83
84
  return project.tasks.register("generatePackagesList", GeneratePackagesListTask::class.java) {
84
85
  it.hash.set(hash)
85
86
  it.namespace.set(generatedPackageListNamespace)
86
87
  it.outputFile.set(getPackageListFile(project))
87
- it.workingDir = project.rootDir
88
+ it.workingDir = projectRoot
88
89
  // Serializes the autolinking options to JSON to pass them to the task.
89
90
  // The types supported as a task input are limited to primitives, strings, and files.
90
91
  it.options.set(options.toJson())
@@ -27,7 +27,8 @@ data class AutolinkingOptions(
27
27
  */
28
28
  open class ExpoGradleExtension(
29
29
  val config: ExpoAutolinkingConfig,
30
- val options: AutolinkingOptions = AutolinkingOptions()
30
+ val options: AutolinkingOptions = AutolinkingOptions(),
31
+ val projectRoot: java.io.File,
31
32
  ) {
32
33
  /**
33
34
  * MD5 hash of the configuration.
@@ -11,13 +11,28 @@ open class ExpoAutolinkingSettingsExtension(
11
11
  val settings: Settings,
12
12
  @Inject val objects: ObjectFactory
13
13
  ) {
14
+ /**
15
+ * The root directory of the react native project.
16
+ * Should be used by projects that don't follow the /android folder structure.
17
+ *
18
+ * Defaults to `settings.rootDir`.
19
+ */
20
+ var projectRoot: File = settings.rootDir
21
+
14
22
  /**
15
23
  * Command that should be provided to `react-native` to resolve the configuration.
16
24
  */
17
- val rnConfigCommand = AutolinkingCommandBuilder()
18
- .command("react-native-config")
19
- .useJson()
20
- .build()
25
+ val rnConfigCommand by lazy {
26
+ val commandBuilder = AutolinkingCommandBuilder()
27
+ .command("react-native-config")
28
+ .useJson()
29
+
30
+ if (projectRoot != settings.rootDir) {
31
+ commandBuilder.option("project-root", projectRoot.absolutePath)
32
+ commandBuilder.option("source-dir", settings.rootDir.absolutePath)
33
+ }
34
+ commandBuilder.build()
35
+ }
21
36
 
22
37
  /**
23
38
  * A list of paths relative to the app's root directory where
@@ -41,7 +56,7 @@ open class ExpoAutolinkingSettingsExtension(
41
56
  val reactNativeGradlePlugin: File by lazy {
42
57
  File(
43
58
  settings.providers.exec { env ->
44
- env.workingDir(settings.rootDir)
59
+ env.workingDir(projectRoot)
45
60
  env.commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })")
46
61
  }.standardOutput.asText.get().trim(),
47
62
  ).parentFile
@@ -53,7 +68,7 @@ open class ExpoAutolinkingSettingsExtension(
53
68
  val reactNative: File by lazy {
54
69
  File(
55
70
  settings.providers.exec { env ->
56
- env.workingDir(settings.rootDir)
71
+ env.workingDir(projectRoot)
57
72
  env.commandLine("node", "--print", "require.resolve('react-native/package.json')")
58
73
  }.standardOutput.asText.get().trim(),
59
74
  ).parentFile
@@ -65,6 +80,7 @@ open class ExpoAutolinkingSettingsExtension(
65
80
  fun useExpoModules() {
66
81
  SettingsManager(
67
82
  settings,
83
+ projectRoot,
68
84
  searchPaths,
69
85
  ignorePaths,
70
86
  exclude
@@ -26,6 +26,7 @@ import java.io.File
26
26
 
27
27
  class SettingsManager(
28
28
  val settings: Settings,
29
+ val projectRoot: File,
29
30
  searchPaths: List<String>? = null,
30
31
  ignorePaths: List<String>? = null,
31
32
  exclude: List<String>? = null
@@ -57,7 +58,7 @@ class SettingsManager(
57
58
  .build()
58
59
 
59
60
  val result = settings.providers.exec { env ->
60
- env.workingDir(settings.rootDir)
61
+ env.workingDir(projectRoot.absolutePath)
61
62
  env.commandLine(command)
62
63
  }.standardOutput.asText.get()
63
64
 
@@ -155,7 +156,7 @@ class SettingsManager(
155
156
  }
156
157
  }
157
158
 
158
- settings.gradle.extensions.create("expoGradle", ExpoGradleExtension::class.java, config, autolinkingOptions)
159
+ settings.gradle.extensions.create("expoGradle", ExpoGradleExtension::class.java, config, autolinkingOptions, projectRoot)
159
160
  }
160
161
 
161
162
  /**
@@ -88,7 +88,7 @@ async function createReactNativeConfigAsync({ appRoot, sourceDir, autolinkingOpt
88
88
  async function resolveAppProjectConfigAsync(projectRoot, platform, sourceDir) {
89
89
  // TODO(@kitten): use the commandRoot here to find these files in non <projectRoot>/<platform> folders
90
90
  if (platform === 'android') {
91
- const androidDir = path_1.default.join(projectRoot, 'android');
91
+ const androidDir = sourceDir ?? path_1.default.join(projectRoot, 'android');
92
92
  const { gradle, manifest } = await (0, androidResolver_1.findGradleAndManifestAsync)({ androidDir, isLibrary: false });
93
93
  if (gradle == null || manifest == null) {
94
94
  return {};
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeConfig.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.ts"],"names":[],"mappings":";;;;;AA8BA,4DAgEC;AAWD,oEAiCC;AAED,oEA+BC;AA3KD,gDAAwB;AAGxB,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AAUpE,0DAAsF;AAEtF,kDAOyB;AAElB,KAAK,UAAU,wBAAwB,CAC5C,UAAgC,EAChC,aAAsD,EACtD,QAA2B,EAC3B,YAAyB;IAEzB,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,IAAA,wBAAe,EAAmC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/F,MAAM,iBAAiB,GAAG;QACxB,GAAG,aAAa,EAAE,UAAU;QAC5B,GAAG,aAAa,EAAE,YAAY,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;KAClD,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3D,8DAA8D;QAC9D,sCAAsC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,IAAI,UAAU,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAC1F,gFAAgF;QAChF,sEAAsE;Q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AE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAChG,IAAI,MAAM,IAAI,IAAI,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACvC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,IAAA,uCAAqB,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE9E,OAAO;YACL,OAAO,EAAE;gBACP,WAAW,EAAE,WAAW,IAAI,EAAE;gBAC9B,SAAS,EAAE,SAAS,IAAI,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;aAC1D;SACF,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO;YACL,GAAG,EAAE;gBACH,SAAS,EAAE,SAAS,IAAI,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;aACtD;SACF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import path from 'path';\n\nimport type { SupportedPlatform } from '../types';\nimport {\n findGradleAndManifestAsync,\n parsePackageNameAsync,\n resolveDependencyConfigImplAndroidAsync,\n} from './androidResolver';\nimport { loadConfigAsync } from './config';\nimport { resolveDependencyConfigImplIosAsync } from './iosResolver';\nimport type {\n RNConfigDependency,\n RNConfigDependencyAndroid,\n RNConfigDependencyIos,\n RNConfigReactNativeAppProjectConfig,\n RNConfigReactNativeLibraryConfig,\n RNConfigReactNativeProjectConfig,\n RNConfigResult,\n} from './reactNativeConfig.types';\nimport { discoverExpoModuleConfigAsync, ExpoModuleConfig } from '../ExpoModuleConfig';\nimport { AutolinkingOptions } from '../commands/autolinkingOptions';\nimport {\n DependencyResolution,\n filterMapResolutionResult,\n mergeResolutionResults,\n scanDependenciesFromRNProjectConfig,\n scanDependenciesInSearchPath,\n scanDependenciesRecursively,\n} from '../dependencies';\n\nexport async function resolveReactNativeModule(\n resolution: DependencyResolution,\n projectConfig: RNConfigReactNativeProjectConfig | null,\n platform: SupportedPlatform,\n excludeNames: Set<string>\n): Promise<RNConfigDependency | null> {\n if (excludeNames.has(resolution.name)) {\n return null;\n }\n\n const libraryConfig = await loadConfigAsync<RNConfigReactNativeLibraryConfig>(resolution.path);\n const reactNativeConfig = {\n ...libraryConfig?.dependency,\n ...projectConfig?.dependencies?.[resolution.name],\n };\n\n if (Object.keys(libraryConfig?.platforms ?? {}).length > 0) {\n // Package defines platforms would be a platform host package.\n // The rnc-cli will skip this package.\n return null;\n } else if (resolution.name === 'react-native' || resolution.name === 'react-native-macos') {\n // Starting from version 0.76, the `react-native` package only defines platforms\n // when @react-native-community/cli-platform-android/ios is installed.\n // Therefore, we need to manually filter it out.\n return null;\n }\n\n let maybeExpoModuleConfig: ExpoModuleConfig | null | undefined;\n if (!libraryConfig) {\n // NOTE(@kitten): If we don't have an explicit react-native.config.{js,ts} file,\n // we should pass the Expo Module config (if it exists) to the resolvers below,\n // which can then decide if the React Native inferred config and Expo Module\n // configs conflict\n try {\n maybeExpoModuleConfig = await discoverExpoModuleConfigAsync(resolution.path);\n } catch {\n // We ignore invalid Expo Modules for the purpose of auto-linking and\n // pretend the config doesn't exist, if it isn't valid JSON\n }\n }\n\n let platformData: RNConfigDependencyAndroid | RNConfigDependencyIos | null = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n resolution.path,\n reactNativeConfig.platforms?.android,\n maybeExpoModuleConfig\n );\n } else if (platform === 'ios') {\n platformData = await resolveDependencyConfigImplIosAsync(\n resolution,\n reactNativeConfig.platforms?.ios,\n maybeExpoModuleConfig\n );\n }\n return (\n platformData && {\n root: resolution.path,\n name: resolution.name,\n platforms: {\n [platform]: platformData,\n },\n }\n );\n}\n\ninterface CreateRNConfigParams {\n appRoot: string;\n sourceDir: string | undefined;\n autolinkingOptions: AutolinkingOptions & { platform: SupportedPlatform };\n}\n\n/**\n * Create config for react-native core autolinking.\n */\nexport async function createReactNativeConfigAsync({\n appRoot,\n sourceDir,\n autolinkingOptions,\n}: CreateRNConfigParams): Promise<RNConfigResult> {\n const excludeNames = new Set(autolinkingOptions.exclude);\n const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(appRoot);\n\n // custom native modules should be resolved first so that they can override other modules\n const searchPaths = autolinkingOptions.nativeModulesDir\n ? [autolinkingOptions.nativeModulesDir, ...autolinkingOptions.searchPaths]\n : autolinkingOptions.searchPaths;\n\n const limitDepth = autolinkingOptions.legacy_shallowReactNativeLinking ? 1 : undefined;\n\n const resolutions = mergeResolutionResults(\n await Promise.all([\n scanDependenciesFromRNProjectConfig(appRoot, projectConfig),\n ...searchPaths.map((searchPath) => scanDependenciesInSearchPath(searchPath)),\n scanDependenciesRecursively(appRoot, { limitDepth }),\n ])\n );\n\n const dependencies = await filterMapResolutionResult(resolutions, (resolution) =>\n resolveReactNativeModule(resolution, projectConfig, autolinkingOptions.platform, excludeNames)\n );\n\n return {\n root: appRoot,\n reactNativePath: resolutions['react-native']?.path!,\n dependencies,\n project: await resolveAppProjectConfigAsync(appRoot, autolinkingOptions.platform, sourceDir),\n };\n}\n\nexport async function resolveAppProjectConfigAsync(\n projectRoot: string,\n platform: SupportedPlatform,\n sourceDir?: string\n): Promise<RNConfigReactNativeAppProjectConfig> {\n // TODO(@kitten): use the commandRoot here to find these files in non <projectRoot>/<platform> folders\n if (platform === 'android') {\n const androidDir = path.join(projectRoot, 'android');\n const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });\n if (gradle == null || manifest == null) {\n return {};\n }\n const packageName = await parsePackageNameAsync(androidDir, manifest, gradle);\n\n return {\n android: {\n packageName: packageName ?? '',\n sourceDir: sourceDir ?? path.join(projectRoot, 'android'),\n },\n };\n }\n\n if (platform === 'ios') {\n return {\n ios: {\n sourceDir: sourceDir ?? path.join(projectRoot, 'ios'),\n },\n };\n }\n\n return {};\n}\n"]}
1
+ {"version":3,"file":"reactNativeConfig.js","sourceRoot":"","sources":["../../src/reactNativ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I,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;aAC1D;SACF,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO;YACL,GAAG,EAAE;gBACH,SAAS,EAAE,SAAS,IAAI,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;aACtD;SACF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import path from 'path';\n\nimport type { SupportedPlatform } from '../types';\nimport {\n findGradleAndManifestAsync,\n parsePackageNameAsync,\n resolveDependencyConfigImplAndroidAsync,\n} from './androidResolver';\nimport { loadConfigAsync } from './config';\nimport { resolveDependencyConfigImplIosAsync } from './iosResolver';\nimport type {\n RNConfigDependency,\n RNConfigDependencyAndroid,\n RNConfigDependencyIos,\n RNConfigReactNativeAppProjectConfig,\n RNConfigReactNativeLibraryConfig,\n RNConfigReactNativeProjectConfig,\n RNConfigResult,\n} from './reactNativeConfig.types';\nimport { discoverExpoModuleConfigAsync, ExpoModuleConfig } from '../ExpoModuleConfig';\nimport { AutolinkingOptions } from '../commands/autolinkingOptions';\nimport {\n DependencyResolution,\n filterMapResolutionResult,\n mergeResolutionResults,\n scanDependenciesFromRNProjectConfig,\n scanDependenciesInSearchPath,\n scanDependenciesRecursively,\n} from '../dependencies';\n\nexport async function resolveReactNativeModule(\n resolution: DependencyResolution,\n projectConfig: RNConfigReactNativeProjectConfig | null,\n platform: SupportedPlatform,\n excludeNames: Set<string>\n): Promise<RNConfigDependency | null> {\n if (excludeNames.has(resolution.name)) {\n return null;\n }\n\n const libraryConfig = await loadConfigAsync<RNConfigReactNativeLibraryConfig>(resolution.path);\n const reactNativeConfig = {\n ...libraryConfig?.dependency,\n ...projectConfig?.dependencies?.[resolution.name],\n };\n\n if (Object.keys(libraryConfig?.platforms ?? {}).length > 0) {\n // Package defines platforms would be a platform host package.\n // The rnc-cli will skip this package.\n return null;\n } else if (resolution.name === 'react-native' || resolution.name === 'react-native-macos') {\n // Starting from version 0.76, the `react-native` package only defines platforms\n // when @react-native-community/cli-platform-android/ios is installed.\n // Therefore, we need to manually filter it out.\n return null;\n }\n\n let maybeExpoModuleConfig: ExpoModuleConfig | null | undefined;\n if (!libraryConfig) {\n // NOTE(@kitten): If we don't have an explicit react-native.config.{js,ts} file,\n // we should pass the Expo Module config (if it exists) to the resolvers below,\n // which can then decide if the React Native inferred config and Expo Module\n // configs conflict\n try {\n maybeExpoModuleConfig = await discoverExpoModuleConfigAsync(resolution.path);\n } catch {\n // We ignore invalid Expo Modules for the purpose of auto-linking and\n // pretend the config doesn't exist, if it isn't valid JSON\n }\n }\n\n let platformData: RNConfigDependencyAndroid | RNConfigDependencyIos | null = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n resolution.path,\n reactNativeConfig.platforms?.android,\n maybeExpoModuleConfig\n );\n } else if (platform === 'ios') {\n platformData = await resolveDependencyConfigImplIosAsync(\n resolution,\n reactNativeConfig.platforms?.ios,\n maybeExpoModuleConfig\n );\n }\n return (\n platformData && {\n root: resolution.path,\n name: resolution.name,\n platforms: {\n [platform]: platformData,\n },\n }\n );\n}\n\ninterface CreateRNConfigParams {\n appRoot: string;\n sourceDir: string | undefined;\n autolinkingOptions: AutolinkingOptions & { platform: SupportedPlatform };\n}\n\n/**\n * Create config for react-native core autolinking.\n */\nexport async function createReactNativeConfigAsync({\n appRoot,\n sourceDir,\n autolinkingOptions,\n}: CreateRNConfigParams): Promise<RNConfigResult> {\n const excludeNames = new Set(autolinkingOptions.exclude);\n const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(appRoot);\n\n // custom native modules should be resolved first so that they can override other modules\n const searchPaths = autolinkingOptions.nativeModulesDir\n ? [autolinkingOptions.nativeModulesDir, ...autolinkingOptions.searchPaths]\n : autolinkingOptions.searchPaths;\n\n const limitDepth = autolinkingOptions.legacy_shallowReactNativeLinking ? 1 : undefined;\n\n const resolutions = mergeResolutionResults(\n await Promise.all([\n scanDependenciesFromRNProjectConfig(appRoot, projectConfig),\n ...searchPaths.map((searchPath) => scanDependenciesInSearchPath(searchPath)),\n scanDependenciesRecursively(appRoot, { limitDepth }),\n ])\n );\n\n const dependencies = await filterMapResolutionResult(resolutions, (resolution) =>\n resolveReactNativeModule(resolution, projectConfig, autolinkingOptions.platform, excludeNames)\n );\n\n return {\n root: appRoot,\n reactNativePath: resolutions['react-native']?.path!,\n dependencies,\n project: await resolveAppProjectConfigAsync(appRoot, autolinkingOptions.platform, sourceDir),\n };\n}\n\nexport async function resolveAppProjectConfigAsync(\n projectRoot: string,\n platform: SupportedPlatform,\n sourceDir?: string\n): Promise<RNConfigReactNativeAppProjectConfig> {\n // TODO(@kitten): use the commandRoot here to find these files in non <projectRoot>/<platform> folders\n if (platform === 'android') {\n const androidDir = sourceDir ?? path.join(projectRoot, 'android');\n const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });\n if (gradle == null || manifest == null) {\n return {};\n }\n const packageName = await parsePackageNameAsync(androidDir, manifest, gradle);\n\n return {\n android: {\n packageName: packageName ?? '',\n sourceDir: sourceDir ?? path.join(projectRoot, 'android'),\n },\n };\n }\n\n if (platform === 'ios') {\n return {\n ios: {\n sourceDir: sourceDir ?? path.join(projectRoot, 'ios'),\n },\n };\n }\n\n return {};\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-autolinking",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Scripts that autolink Expo modules.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "license": "MIT",
35
35
  "homepage": "https://github.com/expo/expo/tree/main/packages/expo-modules-autolinking#readme",
36
36
  "devDependencies": {
37
- "expo-module-scripts": "~5.0.3",
37
+ "expo-module-scripts": "~5.0.4",
38
38
  "memfs": "^3.2.0",
39
39
  "minimatch": "^9.0.0"
40
40
  },
@@ -47,5 +47,5 @@
47
47
  "require-from-string": "^2.0.2",
48
48
  "resolve-from": "^5.0.0"
49
49
  },
50
- "gitHead": "f2270a4447fa0939e0d6f95c92bf5238e7162a73"
50
+ "gitHead": "d44e41c9c0714a838b1652556d27bcb506fabbdf"
51
51
  }
@@ -145,7 +145,7 @@ export async function resolveAppProjectConfigAsync(
145
145
  ): Promise<RNConfigReactNativeAppProjectConfig> {
146
146
  // TODO(@kitten): use the commandRoot here to find these files in non <projectRoot>/<platform> folders
147
147
  if (platform === 'android') {
148
- const androidDir = path.join(projectRoot, 'android');
148
+ const androidDir = sourceDir ?? path.join(projectRoot, 'android');
149
149
  const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });
150
150
  if (gradle == null || manifest == null) {
151
151
  return {};