expo-modules-autolinking 3.0.8 → 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 +12 -0
- package/build/commands/autolinkingOptions.js +7 -6
- package/build/commands/autolinkingOptions.js.map +1 -1
- package/build/exports.js +8 -5
- package/build/exports.js.map +1 -1
- package/build/reactNativeConfig/reactNativeConfig.js +33 -0
- package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
- package/package.json +3 -4
- package/scripts/ios/autolinking_manager.rb +5 -0
- package/scripts/ios/cocoapods/installer.rb +70 -0
- package/src/commands/autolinkingOptions.ts +7 -6
- package/src/exports.ts +8 -5
- package/src/reactNativeConfig/reactNativeConfig.ts +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,18 @@
|
|
|
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
|
+
|
|
17
|
+
## 3.0.9 — 2025-09-10
|
|
18
|
+
|
|
19
|
+
### 💡 Others
|
|
20
|
+
|
|
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))
|
|
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))
|
|
24
|
+
|
|
13
25
|
## 3.0.8 — 2025-09-08
|
|
14
26
|
|
|
15
27
|
### 🐛 Bug fixes
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.filterMapSearchPaths = void 0;
|
|
7
7
|
exports.registerAutolinkingArguments = registerAutolinkingArguments;
|
|
8
8
|
exports.createAutolinkingOptionsLoader = createAutolinkingOptionsLoader;
|
|
9
|
-
const find_up_1 = __importDefault(require("find-up"));
|
|
10
9
|
const fs_1 = __importDefault(require("fs"));
|
|
11
10
|
const path_1 = __importDefault(require("path"));
|
|
12
11
|
const isJSONObject = (x) => x != null && typeof x === 'object';
|
|
@@ -110,12 +109,14 @@ const parseExtraArgumentsOptions = (args) => {
|
|
|
110
109
|
};
|
|
111
110
|
};
|
|
112
111
|
const findPackageJsonPathAsync = async (commandRoot) => {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
const root = commandRoot || process.cwd();
|
|
113
|
+
for (let dir = root; path_1.default.dirname(dir) !== dir; dir = path_1.default.dirname(dir)) {
|
|
114
|
+
const file = path_1.default.resolve(dir, 'package.json');
|
|
115
|
+
if (fs_1.default.existsSync(file)) {
|
|
116
|
+
return file;
|
|
117
|
+
}
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
+
throw new Error(`Couldn't find "package.json" up from path "${root}"`);
|
|
119
120
|
};
|
|
120
121
|
const loadPackageJSONAsync = async (packageJsonPath) => {
|
|
121
122
|
const packageJsonText = await fs_1.default.promises.readFile(packageJsonPath, 'utf8');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autolinkingOptions.js","sourceRoot":"","sources":["../../src/commands/autolinkingOptions.ts"],"names":[],"mappings":";;;;;;AAyIA,oEAmBC;AAoDD,wEAyCC;AAxPD,sDAA6B;AAC7B,4CAAoB;AACpB,gDAAwB;AAmCxB,MAAM,YAAY,GAAG,CAAC,CAAU,EAAgC,EAAE,CAChE,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAE,QAAgB,EAAiB,EAAE;IAC5E,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;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AC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,2BAA2B,GAAG,CAClC,OAAoC,EACpC,OAAe,EACK,EAAE;IACtB,OAAO;QACL,gCAAgC,EAAE,OAAO,CAAC,gCAAgC,IAAI,KAAK;QACnF,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YACxC,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;YAC/D,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;QACpD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import commander from 'commander';\nimport findUp from 'find-up';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { SupportedPlatform } from '../types';\n\nexport interface AutolinkingOptions {\n /** Only scan direct \"dependencies\" of a project for React Native modules, rather than including transitive dependencies.\n * @remarks\n * Before SDK 54, React Native modules would only be linked if they were listed as dependencies\n * of a project. However, in SDK 54+ transitive React Native modules dependencies are also\n * auto-linked, unless this flag is enabled.\n * @defaultValue `false`\n */\n legacy_shallowReactNativeLinking: boolean;\n /** Extra modules directories to search for native modules.\n * @defaultValue `[]`\n */\n searchPaths: string[];\n /** Local native modules directory to add to autolinking.\n * @defaultValue `\"./modules\"`\n */\n nativeModulesDir: string | null;\n /** Native modules to exclude from autolinking by name.\n * @defaultValue `[]`\n */\n exclude: string[];\n /** A list of package names to opt out of prebuilt Expo modules (Android-only)\n * @defaultValue `[]`\n */\n buildFromSource?: string[];\n /** CocoaPods flags to pass to each autolinked pod (Apple/iOS-only)\n * @defaultValue `[]`\n */\n flags?: Record<string, any>;\n}\n\nconst isJSONObject = (x: unknown): x is Record<string, unknown> =>\n x != null && typeof x === 'object';\n\nconst resolvePathMaybe = (target: unknown, basePath: string): string | null => {\n if (typeof target !== 'string') {\n return null;\n }\n let resolved = path.resolve(basePath, target);\n if (fs.existsSync(resolved)) {\n return resolved;\n } else if ((resolved = path.resolve(target)) && fs.existsSync(target)) {\n // TODO(@kitten): This is here for legacy support. However, this *will* be inconsistent\n // This relies on the current working directory, and hence, can behave differently depending\n // on where the command was invoked.\n return target;\n } else {\n return null;\n }\n};\n\nexport const filterMapSearchPaths = (\n searchPaths: unknown,\n basePath: string\n): string[] | undefined => {\n if (Array.isArray(searchPaths)) {\n return searchPaths\n .map((searchPath) => resolvePathMaybe(searchPath, basePath))\n .filter((searchPath) => searchPath != null);\n } else {\n return undefined;\n }\n};\n\nconst parsePackageJsonOptions = (\n packageJson: Record<string, unknown>,\n appRoot: string,\n platform: SupportedPlatform | null | undefined\n): Partial<AutolinkingOptions> => {\n const expo = isJSONObject(packageJson.expo) ? packageJson.expo : null;\n const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;\n let platformOptions: Record<string, unknown> | null = null;\n if (platform) {\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions[platform])\n ? autolinkingOptions[platform]\n : null;\n if (!platformOptions && platform === 'apple') {\n // NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should\n // be the base option for other apple platforms, but changing this now is a breaking change\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions.ios) ? autolinkingOptions.ios : null;\n }\n }\n const mergedOptions = { ...autolinkingOptions, ...platformOptions };\n const outputOptions: Partial<AutolinkingOptions> = {};\n // legacy_shallowReactNativeLinking\n if (mergedOptions.legacy_shallowReactNativeLinking != null) {\n outputOptions.legacy_shallowReactNativeLinking =\n !!mergedOptions.legacy_shallowReactNativeLinking;\n }\n // searchPaths\n if (typeof mergedOptions.searchPaths === 'string' || Array.isArray(mergedOptions.searchPaths)) {\n const rawSearchPaths =\n typeof mergedOptions.searchPaths === 'string'\n ? [mergedOptions.searchPaths]\n : mergedOptions.searchPaths;\n outputOptions.searchPaths = filterMapSearchPaths(rawSearchPaths, appRoot);\n }\n // nativeModulesDir\n if (typeof mergedOptions.nativeModulesDir === 'string') {\n outputOptions.nativeModulesDir = resolvePathMaybe(mergedOptions.nativeModulesDir, appRoot);\n }\n // exclude\n if (Array.isArray(mergedOptions.exclude)) {\n outputOptions.exclude = mergedOptions.exclude.filter((x) => typeof x === 'string');\n }\n // buildFromSource\n if (Array.isArray(mergedOptions.buildFromSource)) {\n outputOptions.buildFromSource = mergedOptions.buildFromSource.filter(\n (x) => typeof x === 'string'\n );\n }\n // flags\n if (isJSONObject(mergedOptions.flags)) {\n outputOptions.flags = { ...mergedOptions.flags };\n }\n return outputOptions;\n};\n\n/** Common commandline arguments for autolinking commands (Not to be confused with `AutolinkingOptions` */\nexport interface AutolinkingCommonArguments {\n projectRoot?: string | null;\n // NOTE(@kitten): These are added to other `searchPaths` entries\n searchPaths?: string[] | null;\n // NOTE(@kitten): These are added to other `exclude` entries\n exclude?: string[] | null;\n platform?: SupportedPlatform | null;\n}\n\nexport function registerAutolinkingArguments(command: commander.Command): commander.Command {\n return command\n .option<string[] | null>(\n '-e, --exclude <exclude...>',\n 'Package names to exclude when looking up for modules.',\n (value, previous) => (previous ?? []).concat(value)\n )\n .option(\n '-p, --platform [platform]',\n 'The platform that the resulting modules must support. Available options: \"apple\", \"android\"',\n 'apple'\n )\n .option(\n // NOTE(@kitten): For backwards-compatibility, this is still called `project-root`, but it\n // really is a replacement path for the current working directory. Henceforth called `commandRoot`\n '--project-root <projectRoot>',\n 'The path to the root of the project. Defaults to current working directory',\n process.cwd()\n );\n}\n\ninterface ArgumentsAutolinkingOptions {\n /** The root directory that will be considered the base path for all other target paths */\n commandRoot: string;\n /** The platform to autolink against. If not passed or unknown, no specific autolinking search logic will be applied */\n platform?: SupportedPlatform;\n /** Added search paths to search for native modules (Usually passed as CLI rest argument. */\n extraSearchPaths?: string[];\n /** Added native module names to exclude from autolined native modules (Usually passed as CLI argument) */\n extraExclude?: string[];\n}\n\nconst parseExtraArgumentsOptions = (\n args: AutolinkingCommonArguments\n): ArgumentsAutolinkingOptions => {\n const cwd = process.cwd();\n const platform = args.platform || undefined;\n const commandRoot = resolvePathMaybe(args.projectRoot, cwd) || cwd;\n const extraSearchPaths = filterMapSearchPaths(args.searchPaths, commandRoot);\n const extraExclude = args.exclude?.filter((name) => typeof name === 'string');\n return {\n platform,\n commandRoot,\n extraSearchPaths,\n extraExclude,\n };\n};\n\nconst findPackageJsonPathAsync = async (commandRoot: string | null): Promise<string> => {\n const cwd = process.cwd();\n const result = await findUp('package.json', { cwd: commandRoot || cwd });\n if (!result) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${commandRoot || cwd}\"`);\n }\n return result;\n};\n\nconst loadPackageJSONAsync = async (packageJsonPath: string): Promise<Record<string, unknown>> => {\n const packageJsonText = await fs.promises.readFile(packageJsonPath, 'utf8');\n return JSON.parse(packageJsonText);\n};\n\nexport interface LinkingOptionsLoader {\n getCommandRoot(): string;\n getAppRoot(): Promise<string>;\n getPlatformOptions<T extends SupportedPlatform | undefined>(\n platform: T\n ): Promise<AutolinkingOptions & { platform: T }>;\n getPlatformOptions(): Promise<AutolinkingOptions>;\n}\n\nexport function createAutolinkingOptionsLoader(\n argumentsOptions?: AutolinkingCommonArguments\n): LinkingOptionsLoader {\n const extraArgumentsOptions = parseExtraArgumentsOptions(argumentsOptions ?? {});\n const { commandRoot } = extraArgumentsOptions;\n\n let _packageJsonPath$: Promise<string> | undefined;\n const getPackageJsonPath = () => {\n return _packageJsonPath$ || (_packageJsonPath$ = findPackageJsonPathAsync(commandRoot));\n };\n\n let _packageJson$: Promise<Record<string, unknown>> | undefined;\n const getPackageJson = async () =>\n _packageJson$ || (_packageJson$ = loadPackageJSONAsync(await getPackageJsonPath()));\n\n const getAppRoot = async () => path.dirname(await getPackageJsonPath());\n\n return {\n getCommandRoot: () => commandRoot,\n getAppRoot,\n async getPlatformOptions(platform = extraArgumentsOptions.platform) {\n const packageJson = await getPackageJson();\n const appRoot = await getAppRoot();\n const options = parsePackageJsonOptions(packageJson, appRoot, platform);\n\n if (extraArgumentsOptions.extraSearchPaths) {\n options.searchPaths = [\n ...extraArgumentsOptions.extraSearchPaths,\n ...(options.searchPaths ?? []),\n ];\n }\n if (extraArgumentsOptions.extraExclude) {\n options.exclude = [...(options.exclude ?? []), ...extraArgumentsOptions.extraExclude];\n }\n\n return {\n ...normalizeAutolinkingOptions(options, appRoot),\n platform,\n };\n },\n };\n}\n\nconst normalizeAutolinkingOptions = (\n options: Partial<AutolinkingOptions>,\n appRoot: string\n): AutolinkingOptions => {\n return {\n legacy_shallowReactNativeLinking: options.legacy_shallowReactNativeLinking ?? false,\n searchPaths: options.searchPaths ?? [],\n nativeModulesDir: options.nativeModulesDir\n ? (resolvePathMaybe(options.nativeModulesDir, appRoot) ?? null)\n : (resolvePathMaybe('./modules', appRoot) ?? null),\n exclude: options.exclude ?? [],\n buildFromSource: options.buildFromSource,\n flags: options.flags,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"autolinkingOptions.js","sourceRoot":"","sources":["../../src/commands/autolinkingOptions.ts"],"names":[],"mappings":";;;;;;AAwIA,oEAmBC;AAsDD,wEAyCC;AAzPD,4CAAoB;AACpB,gDAAwB;AAmCxB,MAAM,YAAY,GAAG,CAAC,CAAU,EAAgC,EAAE,CAChE,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAE,QAAgB,EAAiB,EAAE;IAC5E,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC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CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,2BAA2B,GAAG,CAClC,OAAoC,EACpC,OAAe,EACK,EAAE;IACtB,OAAO;QACL,gCAAgC,EAAE,OAAO,CAAC,gCAAgC,IAAI,KAAK;QACnF,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YACxC,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;YAC/D,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;QACpD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import commander from 'commander';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { SupportedPlatform } from '../types';\n\nexport interface AutolinkingOptions {\n /** Only scan direct \"dependencies\" of a project for React Native modules, rather than including transitive dependencies.\n * @remarks\n * Before SDK 54, React Native modules would only be linked if they were listed as dependencies\n * of a project. However, in SDK 54+ transitive React Native modules dependencies are also\n * auto-linked, unless this flag is enabled.\n * @defaultValue `false`\n */\n legacy_shallowReactNativeLinking: boolean;\n /** Extra modules directories to search for native modules.\n * @defaultValue `[]`\n */\n searchPaths: string[];\n /** Local native modules directory to add to autolinking.\n * @defaultValue `\"./modules\"`\n */\n nativeModulesDir: string | null;\n /** Native modules to exclude from autolinking by name.\n * @defaultValue `[]`\n */\n exclude: string[];\n /** A list of package names to opt out of prebuilt Expo modules (Android-only)\n * @defaultValue `[]`\n */\n buildFromSource?: string[];\n /** CocoaPods flags to pass to each autolinked pod (Apple/iOS-only)\n * @defaultValue `[]`\n */\n flags?: Record<string, any>;\n}\n\nconst isJSONObject = (x: unknown): x is Record<string, unknown> =>\n x != null && typeof x === 'object';\n\nconst resolvePathMaybe = (target: unknown, basePath: string): string | null => {\n if (typeof target !== 'string') {\n return null;\n }\n let resolved = path.resolve(basePath, target);\n if (fs.existsSync(resolved)) {\n return resolved;\n } else if ((resolved = path.resolve(target)) && fs.existsSync(target)) {\n // TODO(@kitten): This is here for legacy support. However, this *will* be inconsistent\n // This relies on the current working directory, and hence, can behave differently depending\n // on where the command was invoked.\n return target;\n } else {\n return null;\n }\n};\n\nexport const filterMapSearchPaths = (\n searchPaths: unknown,\n basePath: string\n): string[] | undefined => {\n if (Array.isArray(searchPaths)) {\n return searchPaths\n .map((searchPath) => resolvePathMaybe(searchPath, basePath))\n .filter((searchPath) => searchPath != null);\n } else {\n return undefined;\n }\n};\n\nconst parsePackageJsonOptions = (\n packageJson: Record<string, unknown>,\n appRoot: string,\n platform: SupportedPlatform | null | undefined\n): Partial<AutolinkingOptions> => {\n const expo = isJSONObject(packageJson.expo) ? packageJson.expo : null;\n const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;\n let platformOptions: Record<string, unknown> | null = null;\n if (platform) {\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions[platform])\n ? autolinkingOptions[platform]\n : null;\n if (!platformOptions && platform === 'apple') {\n // NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should\n // be the base option for other apple platforms, but changing this now is a breaking change\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions.ios) ? autolinkingOptions.ios : null;\n }\n }\n const mergedOptions = { ...autolinkingOptions, ...platformOptions };\n const outputOptions: Partial<AutolinkingOptions> = {};\n // legacy_shallowReactNativeLinking\n if (mergedOptions.legacy_shallowReactNativeLinking != null) {\n outputOptions.legacy_shallowReactNativeLinking =\n !!mergedOptions.legacy_shallowReactNativeLinking;\n }\n // searchPaths\n if (typeof mergedOptions.searchPaths === 'string' || Array.isArray(mergedOptions.searchPaths)) {\n const rawSearchPaths =\n typeof mergedOptions.searchPaths === 'string'\n ? [mergedOptions.searchPaths]\n : mergedOptions.searchPaths;\n outputOptions.searchPaths = filterMapSearchPaths(rawSearchPaths, appRoot);\n }\n // nativeModulesDir\n if (typeof mergedOptions.nativeModulesDir === 'string') {\n outputOptions.nativeModulesDir = resolvePathMaybe(mergedOptions.nativeModulesDir, appRoot);\n }\n // exclude\n if (Array.isArray(mergedOptions.exclude)) {\n outputOptions.exclude = mergedOptions.exclude.filter((x) => typeof x === 'string');\n }\n // buildFromSource\n if (Array.isArray(mergedOptions.buildFromSource)) {\n outputOptions.buildFromSource = mergedOptions.buildFromSource.filter(\n (x) => typeof x === 'string'\n );\n }\n // flags\n if (isJSONObject(mergedOptions.flags)) {\n outputOptions.flags = { ...mergedOptions.flags };\n }\n return outputOptions;\n};\n\n/** Common commandline arguments for autolinking commands (Not to be confused with `AutolinkingOptions` */\nexport interface AutolinkingCommonArguments {\n projectRoot?: string | null;\n // NOTE(@kitten): These are added to other `searchPaths` entries\n searchPaths?: string[] | null;\n // NOTE(@kitten): These are added to other `exclude` entries\n exclude?: string[] | null;\n platform?: SupportedPlatform | null;\n}\n\nexport function registerAutolinkingArguments(command: commander.Command): commander.Command {\n return command\n .option<string[] | null>(\n '-e, --exclude <exclude...>',\n 'Package names to exclude when looking up for modules.',\n (value, previous) => (previous ?? []).concat(value)\n )\n .option(\n '-p, --platform [platform]',\n 'The platform that the resulting modules must support. Available options: \"apple\", \"android\"',\n 'apple'\n )\n .option(\n // NOTE(@kitten): For backwards-compatibility, this is still called `project-root`, but it\n // really is a replacement path for the current working directory. Henceforth called `commandRoot`\n '--project-root <projectRoot>',\n 'The path to the root of the project. Defaults to current working directory',\n process.cwd()\n );\n}\n\ninterface ArgumentsAutolinkingOptions {\n /** The root directory that will be considered the base path for all other target paths */\n commandRoot: string;\n /** The platform to autolink against. If not passed or unknown, no specific autolinking search logic will be applied */\n platform?: SupportedPlatform;\n /** Added search paths to search for native modules (Usually passed as CLI rest argument. */\n extraSearchPaths?: string[];\n /** Added native module names to exclude from autolined native modules (Usually passed as CLI argument) */\n extraExclude?: string[];\n}\n\nconst parseExtraArgumentsOptions = (\n args: AutolinkingCommonArguments\n): ArgumentsAutolinkingOptions => {\n const cwd = process.cwd();\n const platform = args.platform || undefined;\n const commandRoot = resolvePathMaybe(args.projectRoot, cwd) || cwd;\n const extraSearchPaths = filterMapSearchPaths(args.searchPaths, commandRoot);\n const extraExclude = args.exclude?.filter((name) => typeof name === 'string');\n return {\n platform,\n commandRoot,\n extraSearchPaths,\n extraExclude,\n };\n};\n\nconst findPackageJsonPathAsync = async (commandRoot: string | null): Promise<string> => {\n const root = commandRoot || process.cwd();\n for (let dir = root; path.dirname(dir) !== dir; dir = path.dirname(dir)) {\n const file = path.resolve(dir, 'package.json');\n if (fs.existsSync(file)) {\n return file;\n }\n }\n throw new Error(`Couldn't find \"package.json\" up from path \"${root}\"`);\n};\n\nconst loadPackageJSONAsync = async (packageJsonPath: string): Promise<Record<string, unknown>> => {\n const packageJsonText = await fs.promises.readFile(packageJsonPath, 'utf8');\n return JSON.parse(packageJsonText);\n};\n\nexport interface LinkingOptionsLoader {\n getCommandRoot(): string;\n getAppRoot(): Promise<string>;\n getPlatformOptions<T extends SupportedPlatform | undefined>(\n platform: T\n ): Promise<AutolinkingOptions & { platform: T }>;\n getPlatformOptions(): Promise<AutolinkingOptions>;\n}\n\nexport function createAutolinkingOptionsLoader(\n argumentsOptions?: AutolinkingCommonArguments\n): LinkingOptionsLoader {\n const extraArgumentsOptions = parseExtraArgumentsOptions(argumentsOptions ?? {});\n const { commandRoot } = extraArgumentsOptions;\n\n let _packageJsonPath$: Promise<string> | undefined;\n const getPackageJsonPath = () => {\n return _packageJsonPath$ || (_packageJsonPath$ = findPackageJsonPathAsync(commandRoot));\n };\n\n let _packageJson$: Promise<Record<string, unknown>> | undefined;\n const getPackageJson = async () =>\n _packageJson$ || (_packageJson$ = loadPackageJSONAsync(await getPackageJsonPath()));\n\n const getAppRoot = async () => path.dirname(await getPackageJsonPath());\n\n return {\n getCommandRoot: () => commandRoot,\n getAppRoot,\n async getPlatformOptions(platform = extraArgumentsOptions.platform) {\n const packageJson = await getPackageJson();\n const appRoot = await getAppRoot();\n const options = parsePackageJsonOptions(packageJson, appRoot, platform);\n\n if (extraArgumentsOptions.extraSearchPaths) {\n options.searchPaths = [\n ...extraArgumentsOptions.extraSearchPaths,\n ...(options.searchPaths ?? []),\n ];\n }\n if (extraArgumentsOptions.extraExclude) {\n options.exclude = [...(options.exclude ?? []), ...extraArgumentsOptions.extraExclude];\n }\n\n return {\n ...normalizeAutolinkingOptions(options, appRoot),\n platform,\n };\n },\n };\n}\n\nconst normalizeAutolinkingOptions = (\n options: Partial<AutolinkingOptions>,\n appRoot: string\n): AutolinkingOptions => {\n return {\n legacy_shallowReactNativeLinking: options.legacy_shallowReactNativeLinking ?? false,\n searchPaths: options.searchPaths ?? [],\n nativeModulesDir: options.nativeModulesDir\n ? (resolvePathMaybe(options.nativeModulesDir, appRoot) ?? null)\n : (resolvePathMaybe('./modules', appRoot) ?? null),\n exclude: options.exclude ?? [],\n buildFromSource: options.buildFromSource,\n flags: options.flags,\n };\n};\n"]}
|
package/build/exports.js
CHANGED
|
@@ -22,7 +22,8 @@ exports.mergeLinkingOptionsAsync = mergeLinkingOptionsAsync;
|
|
|
22
22
|
exports.queryAutolinkingModulesFromProjectAsync = queryAutolinkingModulesFromProjectAsync;
|
|
23
23
|
exports.findProjectRootSync = findProjectRootSync;
|
|
24
24
|
exports.resolveSearchPathsAsync = resolveSearchPathsAsync;
|
|
25
|
-
const
|
|
25
|
+
const fs_1 = __importDefault(require("fs"));
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
26
27
|
const findModules_1 = require("./autolinking/findModules");
|
|
27
28
|
const resolveModules_1 = require("./autolinking/resolveModules");
|
|
28
29
|
const autolinkingOptions_1 = require("./commands/autolinkingOptions");
|
|
@@ -56,11 +57,13 @@ async function queryAutolinkingModulesFromProjectAsync(projectRoot, options) {
|
|
|
56
57
|
}
|
|
57
58
|
/** @deprecated */
|
|
58
59
|
function findProjectRootSync(cwd = process.cwd()) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
for (let dir = cwd; path_1.default.dirname(dir) !== dir; dir = path_1.default.dirname(dir)) {
|
|
61
|
+
const file = path_1.default.resolve(dir, 'package.json');
|
|
62
|
+
if (fs_1.default.existsSync(file)) {
|
|
63
|
+
return file;
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
throw new Error(`Couldn't find "package.json" up from path "${cwd}"`);
|
|
64
67
|
}
|
|
65
68
|
/** @deprecated */
|
|
66
69
|
async function resolveSearchPathsAsync(searchPaths, cwd) {
|
package/build/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,4DASC;AAQD,0FAaC;AAGD,kDAQC;AAGD,0DAKC;AA/ED,4CAAoB;AACpB,gDAAwB;AAExB,2DAA6D;AAC7D,iEAAmE;AACnE,sEAKuC;AAGvC,0CAAwB;AACxB,gDAA8B;AAC9B,8CAA4B;AAE5B,+CAUwB;AAHtB,4HAAA,4BAA4B,OAAA;AAC5B,oIAAA,oCAAoC,OAAA;AACpC,oIAAA,oCAAoC,OAAA;AAGtC,kBAAkB;AACX,KAAK,UAAU,wBAAwB,CAC5C,gBAAyB;IAEzB,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC,gBAAgB,CAAC,CAAC;IAClF,OAAO;QACL,GAAG,gBAAgB;QACnB,GAAG,CAAC,MAAM,wBAAwB,CAAC,kBAAkB,EAAE,CAAC;QACxD,WAAW,EAAE,wBAAwB,CAAC,UAAU,EAAE;KACnD,CAAC;AACJ,C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import { findModulesAsync } from './autolinking/findModules';\nimport { resolveModulesAsync } from './autolinking/resolveModules';\nimport {\n AutolinkingCommonArguments,\n AutolinkingOptions,\n createAutolinkingOptionsLoader,\n filterMapSearchPaths,\n} from './commands/autolinkingOptions';\nimport { ModuleDescriptor, SupportedPlatform } from './types';\n\nexport * from './types';\nexport * from './autolinking';\nexport * from './platforms';\n\nexport {\n ResolutionResult,\n BaseDependencyResolution,\n DependencyResolution,\n DependencyResolutionSource,\n CachedDependenciesLinker,\n CachedDependenciesSearchOptions,\n makeCachedDependenciesLinker,\n scanDependencyResolutionsForPlatform,\n scanExpoModuleResolutionsForPlatform,\n} from './dependencies';\n\n/** @deprecated */\nexport async function mergeLinkingOptionsAsync<Options extends Partial<AutolinkingCommonArguments>>(\n argumentsOptions: Options\n): Promise<Options & AutolinkingOptions> {\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader(argumentsOptions);\n return {\n ...argumentsOptions,\n ...(await autolinkingOptionsLoader.getPlatformOptions()),\n projectRoot: autolinkingOptionsLoader.getAppRoot(),\n };\n}\n\ninterface QueryAutolinkingModulesFromProjectParams extends Partial<AutolinkingCommonArguments> {\n platform: SupportedPlatform;\n [extra: string]: unknown;\n}\n\n/** @deprecated */\nexport async function queryAutolinkingModulesFromProjectAsync(\n projectRoot: string,\n options: QueryAutolinkingModulesFromProjectParams\n): Promise<ModuleDescriptor[]> {\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n ...options,\n // NOTE(@kitten): This has always been duplicated\n projectRoot: options.projectRoot ?? projectRoot,\n });\n const appRoot = await autolinkingOptionsLoader.getAppRoot();\n const autolinkingOptions = await autolinkingOptionsLoader.getPlatformOptions(options.platform);\n const searchResults = await findModulesAsync({ appRoot, autolinkingOptions });\n return await resolveModulesAsync(searchResults, autolinkingOptions);\n}\n\n/** @deprecated */\nexport function findProjectRootSync(cwd: string = process.cwd()): string {\n for (let dir = cwd; path.dirname(dir) !== dir; dir = path.dirname(dir)) {\n const file = path.resolve(dir, 'package.json');\n if (fs.existsSync(file)) {\n return file;\n }\n }\n throw new Error(`Couldn't find \"package.json\" up from path \"${cwd}\"`);\n}\n\n/** @deprecated */\nexport async function resolveSearchPathsAsync(\n searchPaths: string[] | null,\n cwd: string\n): Promise<string[]> {\n return filterMapSearchPaths(searchPaths, cwd) ?? [];\n}\n"]}
|
|
@@ -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,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,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ePackageNameAsync,\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,YAAY,CAAC,GAAG,CAAC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AQ,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.
|
|
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",
|
|
@@ -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.
|
|
37
|
+
"expo-module-scripts": "~5.0.7",
|
|
38
38
|
"memfs": "^3.2.0",
|
|
39
39
|
"minimatch": "^9.0.0"
|
|
40
40
|
},
|
|
@@ -42,10 +42,9 @@
|
|
|
42
42
|
"@expo/spawn-async": "^1.7.2",
|
|
43
43
|
"chalk": "^4.1.0",
|
|
44
44
|
"commander": "^7.2.0",
|
|
45
|
-
"find-up": "^5.0.0",
|
|
46
45
|
"glob": "^10.4.2",
|
|
47
46
|
"require-from-string": "^2.0.2",
|
|
48
47
|
"resolve-from": "^5.0.0"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "e59fa2677c1fff08b14e2e0b1b505124c85cbf54"
|
|
51
50
|
}
|
|
@@ -6,6 +6,7 @@ require_relative 'packages_config'
|
|
|
6
6
|
require_relative 'cocoapods/sandbox'
|
|
7
7
|
require_relative 'cocoapods/target_definition'
|
|
8
8
|
require_relative 'cocoapods/user_project_integrator'
|
|
9
|
+
require_relative 'cocoapods/installer'
|
|
9
10
|
|
|
10
11
|
module Expo
|
|
11
12
|
class AutolinkingManager
|
|
@@ -35,6 +36,10 @@ module Expo
|
|
|
35
36
|
tests_only = @options.fetch(:testsOnly, false)
|
|
36
37
|
include_tests = @options.fetch(:includeTests, false)
|
|
37
38
|
|
|
39
|
+
# Add any additional framework modules to patch using the patched Podfile class in installer.rb
|
|
40
|
+
additional_framework_modules_to_path = @options.fetch(:additionalFrameworkModulesToPatch, [])
|
|
41
|
+
@podfile.expo_add_modules_to_patch(additional_framework_modules_to_path) if !additional_framework_modules_to_path.empty?
|
|
42
|
+
|
|
38
43
|
project_directory = Pod::Config.instance.project_root
|
|
39
44
|
|
|
40
45
|
UI.section 'Using Expo modules' do
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Overrides CocoaPods `Installer`/'Podfile' classes to patch podspecs on the fly
|
|
2
|
+
# See: https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/installer.rb
|
|
3
|
+
# See: https://github.com/CocoaPods/Core/blob/master/lib/cocoapods-core/podfile.rb#L160
|
|
4
|
+
#
|
|
5
|
+
# This is necessary to disable `USE_FRAMEWORKS` for specific pods that include
|
|
6
|
+
# React Native Core headers in their public headers, which causes issues when
|
|
7
|
+
# building them as dynamic frameworks with modular headers enabled.
|
|
8
|
+
|
|
9
|
+
module Pod
|
|
10
|
+
class Podfile
|
|
11
|
+
public
|
|
12
|
+
|
|
13
|
+
def framework_modules_to_patch
|
|
14
|
+
@framework_modules_to_patch ||= ['ExpoModulesCore', 'Expo', 'ReactAppDependencyProvider', 'expo-dev-menu']
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def expo_add_modules_to_patch(modules)
|
|
18
|
+
framework_modules_to_patch.concat(modules)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class Installer
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
_original_run_podfile_pre_install_hooks = instance_method(:run_podfile_pre_install_hooks)
|
|
26
|
+
|
|
27
|
+
public
|
|
28
|
+
|
|
29
|
+
define_method(:run_podfile_pre_install_hooks) do
|
|
30
|
+
# Call original implementation first
|
|
31
|
+
_original_run_podfile_pre_install_hooks.bind(self).()
|
|
32
|
+
|
|
33
|
+
return unless should_disable_use_frameworks_for_core_expo_pods?()
|
|
34
|
+
|
|
35
|
+
# Disable USE_FRAMEWORKS in core targets when USE_FRAMEWORKS is set
|
|
36
|
+
# This method overrides the build_type field to always use static_library for
|
|
37
|
+
# the following pod targets:
|
|
38
|
+
# - ExpoModulesCore, Expo, ReactAppDependencyProvider, expo-dev-menu
|
|
39
|
+
# These are all including files from React Native Core in their public header files,
|
|
40
|
+
# which causes their own modular headers to be invalid.
|
|
41
|
+
Pod::UI.puts "[Expo] ".blue + "Disabling USE_FRAMEWORKS for modules #{@podfile.framework_modules_to_patch.join(', ')}"
|
|
42
|
+
self.pod_targets.each do |t|
|
|
43
|
+
if @podfile.framework_modules_to_patch.include?(t.name)
|
|
44
|
+
def t.build_type
|
|
45
|
+
Pod::BuildType.static_library
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
# We should only disable USE_FRAMEWORKS for specific pods when:
|
|
54
|
+
# - RCT_USE_PREBUILT_RNCORE is not '1'
|
|
55
|
+
# - USE_FRAMEWORKS is not set
|
|
56
|
+
def should_disable_use_frameworks_for_core_expo_pods?()
|
|
57
|
+
return false if ENV['RCT_USE_PREBUILT_RNCORE'] != '1'
|
|
58
|
+
return true if get_linkage?() != nil
|
|
59
|
+
false
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Returns the linkage type if USE_FRAMEWORKS is set, otherwise returns nil
|
|
63
|
+
def get_linkage?()
|
|
64
|
+
return nil if ENV["USE_FRAMEWORKS"] == nil
|
|
65
|
+
return :dynamic if ENV["USE_FRAMEWORKS"].downcase == 'dynamic'
|
|
66
|
+
return :static if ENV["USE_FRAMEWORKS"].downcase == 'static'
|
|
67
|
+
nil
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import commander from 'commander';
|
|
2
|
-
import findUp from 'find-up';
|
|
3
2
|
import fs from 'fs';
|
|
4
3
|
import path from 'path';
|
|
5
4
|
|
|
@@ -184,12 +183,14 @@ const parseExtraArgumentsOptions = (
|
|
|
184
183
|
};
|
|
185
184
|
|
|
186
185
|
const findPackageJsonPathAsync = async (commandRoot: string | null): Promise<string> => {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
const root = commandRoot || process.cwd();
|
|
187
|
+
for (let dir = root; path.dirname(dir) !== dir; dir = path.dirname(dir)) {
|
|
188
|
+
const file = path.resolve(dir, 'package.json');
|
|
189
|
+
if (fs.existsSync(file)) {
|
|
190
|
+
return file;
|
|
191
|
+
}
|
|
191
192
|
}
|
|
192
|
-
|
|
193
|
+
throw new Error(`Couldn't find "package.json" up from path "${root}"`);
|
|
193
194
|
};
|
|
194
195
|
|
|
195
196
|
const loadPackageJSONAsync = async (packageJsonPath: string): Promise<Record<string, unknown>> => {
|
package/src/exports.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
|
|
3
4
|
import { findModulesAsync } from './autolinking/findModules';
|
|
4
5
|
import { resolveModulesAsync } from './autolinking/resolveModules';
|
|
@@ -61,11 +62,13 @@ export async function queryAutolinkingModulesFromProjectAsync(
|
|
|
61
62
|
|
|
62
63
|
/** @deprecated */
|
|
63
64
|
export function findProjectRootSync(cwd: string = process.cwd()): string {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
for (let dir = cwd; path.dirname(dir) !== dir; dir = path.dirname(dir)) {
|
|
66
|
+
const file = path.resolve(dir, 'package.json');
|
|
67
|
+
if (fs.existsSync(file)) {
|
|
68
|
+
return file;
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
|
-
|
|
71
|
+
throw new Error(`Couldn't find "package.json" up from path "${cwd}"`);
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
/** @deprecated */
|
|
@@ -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!,
|