expo-modules-autolinking 3.0.9 → 3.0.10

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,12 +10,17 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 3.0.10 — 2025-09-10
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 3.0.9 — 2025-09-10
14
18
 
15
19
  ### 💡 Others
16
20
 
17
21
  - [iOS] Added support for pre-install step when USE_FRAMEWORKS is set in Podfile ([#39479](https://github.com/expo/expo/pull/39479) by [@chrfalch](https://github.com/chrfalch))
18
22
  - Remove dependency on `find-up` ([#39470](https://github.com/expo/expo/pull/39470) by [@kitten](https://github.com/kitten))
23
+ - [iOS] Force codegen for `FBReactNativeSpec` when generated files are missing in React Native source ([#39512](https://github.com/expo/expo/pull/39512) by [@kitten](https://github.com/kitten))
19
24
 
20
25
  ## 3.0.8 — 2025-09-08
21
26
 
@@ -6,12 +6,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveReactNativeModule = resolveReactNativeModule;
7
7
  exports.createReactNativeConfigAsync = createReactNativeConfigAsync;
8
8
  exports.resolveAppProjectConfigAsync = resolveAppProjectConfigAsync;
9
+ const fs_1 = __importDefault(require("fs"));
9
10
  const path_1 = __importDefault(require("path"));
10
11
  const androidResolver_1 = require("./androidResolver");
11
12
  const config_1 = require("./config");
12
13
  const iosResolver_1 = require("./iosResolver");
13
14
  const ExpoModuleConfig_1 = require("../ExpoModuleConfig");
14
15
  const dependencies_1 = require("../dependencies");
16
+ const isMissingFBReactNativeSpecCodegenOutput = async (reactNativePath) => {
17
+ const generatedDir = path_1.default.resolve(reactNativePath, 'React/FBReactNativeSpec');
18
+ try {
19
+ const stat = await fs_1.default.promises.lstat(generatedDir);
20
+ return !stat.isDirectory();
21
+ }
22
+ catch {
23
+ return true;
24
+ }
25
+ };
15
26
  async function resolveReactNativeModule(resolution, projectConfig, platform, excludeNames) {
16
27
  if (excludeNames.has(resolution.name)) {
17
28
  return null;
@@ -78,6 +89,28 @@ async function createReactNativeConfigAsync({ appRoot, sourceDir, autolinkingOpt
78
89
  (0, dependencies_1.scanDependenciesRecursively)(appRoot, { limitDepth }),
79
90
  ]));
80
91
  const dependencies = await (0, dependencies_1.filterMapResolutionResult)(resolutions, (resolution) => resolveReactNativeModule(resolution, projectConfig, autolinkingOptions.platform, excludeNames));
92
+ // See: https://github.com/facebook/react-native/pull/53690
93
+ // When we're building react-native from source without these generated files, we need to force them to be generated
94
+ // Every published react-native version (or out-of-tree version) should have these files, but building from the raw repo won't (e.g. Expo Go)
95
+ const reactNativeResolution = resolutions['react-native'];
96
+ if (reactNativeResolution &&
97
+ autolinkingOptions.platform === 'ios' &&
98
+ (await isMissingFBReactNativeSpecCodegenOutput(reactNativeResolution.path))) {
99
+ dependencies['react-native'] = {
100
+ root: reactNativeResolution.path,
101
+ name: 'react-native',
102
+ platforms: {
103
+ ios: {
104
+ // This will trigger a warning in list_native_modules but will trigger the artifacts
105
+ // codegen codepath as expected
106
+ podspecPath: '',
107
+ version: reactNativeResolution.version,
108
+ configurations: [],
109
+ scriptPhases: [],
110
+ },
111
+ },
112
+ };
113
+ }
81
114
  return {
82
115
  root: appRoot,
83
116
  reactNativePath: resolutions['react-native']?.path,
@@ -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,CAA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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"]}
1
+ {"version":3,"file":"reactNativeConfig.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.ts"],"names":[],"mappings":";;;;;AAyCA,4DAgEC;AAWD,oEA0DC;AAED,oEA+BC;AA/MD,4CAAoB;AACpB,gDAAwB;AAGxB,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AAUpE,0DAAsF;AAEtF,kDAOyB;AAEzB,MAAM,uCAAuC,GAAG,KAAK,EAAE,eAAuB,EAAE,EAAE;IAChF,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC9E,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEK,KAAK,UAAU,wBAAwB,CAC5C,UAAgC,EAChC,aAAsD,EACtD,QAA2B,EAC3B,YAAyB;IAEzB,IAAI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AM,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 fs from 'fs';\nimport 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\nconst isMissingFBReactNativeSpecCodegenOutput = async (reactNativePath: string) => {\n const generatedDir = path.resolve(reactNativePath, 'React/FBReactNativeSpec');\n try {\n const stat = await fs.promises.lstat(generatedDir);\n return !stat.isDirectory();\n } catch {\n return true;\n }\n};\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 // See: https://github.com/facebook/react-native/pull/53690\n // When we're building react-native from source without these generated files, we need to force them to be generated\n // Every published react-native version (or out-of-tree version) should have these files, but building from the raw repo won't (e.g. Expo Go)\n const reactNativeResolution = resolutions['react-native'];\n if (\n reactNativeResolution &&\n autolinkingOptions.platform === 'ios' &&\n (await isMissingFBReactNativeSpecCodegenOutput(reactNativeResolution.path))\n ) {\n dependencies['react-native'] = {\n root: reactNativeResolution.path,\n name: 'react-native',\n platforms: {\n ios: {\n // This will trigger a warning in list_native_modules but will trigger the artifacts\n // codegen codepath as expected\n podspecPath: '',\n version: reactNativeResolution.version,\n configurations: [],\n scriptPhases: [],\n },\n },\n };\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.9",
3
+ "version": "3.0.10",
4
4
  "description": "Scripts that autolink Expo modules.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -46,5 +46,5 @@
46
46
  "require-from-string": "^2.0.2",
47
47
  "resolve-from": "^5.0.0"
48
48
  },
49
- "gitHead": "87186d10c8239c6469e055417e67bd4d0ed63efb"
49
+ "gitHead": "e59fa2677c1fff08b14e2e0b1b505124c85cbf54"
50
50
  }
@@ -1,3 +1,4 @@
1
+ import fs from 'fs';
1
2
  import path from 'path';
2
3
 
3
4
  import type { SupportedPlatform } from '../types';
@@ -28,6 +29,16 @@ import {
28
29
  scanDependenciesRecursively,
29
30
  } from '../dependencies';
30
31
 
32
+ const isMissingFBReactNativeSpecCodegenOutput = async (reactNativePath: string) => {
33
+ const generatedDir = path.resolve(reactNativePath, 'React/FBReactNativeSpec');
34
+ try {
35
+ const stat = await fs.promises.lstat(generatedDir);
36
+ return !stat.isDirectory();
37
+ } catch {
38
+ return true;
39
+ }
40
+ };
41
+
31
42
  export async function resolveReactNativeModule(
32
43
  resolution: DependencyResolution,
33
44
  projectConfig: RNConfigReactNativeProjectConfig | null,
@@ -130,6 +141,31 @@ export async function createReactNativeConfigAsync({
130
141
  resolveReactNativeModule(resolution, projectConfig, autolinkingOptions.platform, excludeNames)
131
142
  );
132
143
 
144
+ // See: https://github.com/facebook/react-native/pull/53690
145
+ // When we're building react-native from source without these generated files, we need to force them to be generated
146
+ // Every published react-native version (or out-of-tree version) should have these files, but building from the raw repo won't (e.g. Expo Go)
147
+ const reactNativeResolution = resolutions['react-native'];
148
+ if (
149
+ reactNativeResolution &&
150
+ autolinkingOptions.platform === 'ios' &&
151
+ (await isMissingFBReactNativeSpecCodegenOutput(reactNativeResolution.path))
152
+ ) {
153
+ dependencies['react-native'] = {
154
+ root: reactNativeResolution.path,
155
+ name: 'react-native',
156
+ platforms: {
157
+ ios: {
158
+ // This will trigger a warning in list_native_modules but will trigger the artifacts
159
+ // codegen codepath as expected
160
+ podspecPath: '',
161
+ version: reactNativeResolution.version,
162
+ configurations: [],
163
+ scriptPhases: [],
164
+ },
165
+ },
166
+ };
167
+ }
168
+
133
169
  return {
134
170
  root: appRoot,
135
171
  reactNativePath: resolutions['react-native']?.path!,