expo-modules-autolinking 3.0.7 → 3.0.9
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 +13 -0
- package/build/commands/autolinkingOptions.js +11 -9
- package/build/commands/autolinkingOptions.js.map +1 -1
- package/build/exports.js +8 -5
- package/build/exports.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 +11 -9
- package/src/exports.ts +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,19 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 3.0.9 — 2025-09-10
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- [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
|
+
- Remove dependency on `find-up` ([#39470](https://github.com/expo/expo/pull/39470) by [@kitten](https://github.com/kitten))
|
|
19
|
+
|
|
20
|
+
## 3.0.8 — 2025-09-08
|
|
21
|
+
|
|
22
|
+
### 🐛 Bug fixes
|
|
23
|
+
|
|
24
|
+
- [Android] Fix `platformOptions` not being correctly assigned. ([#39445](https://github.com/expo/expo/pull/39445) by [@alanjhughes](https://github.com/alanjhughes))
|
|
25
|
+
|
|
13
26
|
## 3.0.7 — 2025-09-04
|
|
14
27
|
|
|
15
28
|
_This version does not introduce any user-facing changes._
|
|
@@ -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';
|
|
@@ -44,9 +43,10 @@ const parsePackageJsonOptions = (packageJson, appRoot, platform) => {
|
|
|
44
43
|
const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;
|
|
45
44
|
let platformOptions = null;
|
|
46
45
|
if (platform) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
platformOptions =
|
|
47
|
+
autolinkingOptions && isJSONObject(autolinkingOptions[platform])
|
|
48
|
+
? autolinkingOptions[platform]
|
|
49
|
+
: null;
|
|
50
50
|
if (!platformOptions && platform === 'apple') {
|
|
51
51
|
// NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should
|
|
52
52
|
// be the base option for other apple platforms, but changing this now is a breaking change
|
|
@@ -109,12 +109,14 @@ const parseExtraArgumentsOptions = (args) => {
|
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
const findPackageJsonPathAsync = async (commandRoot) => {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
}
|
|
116
118
|
}
|
|
117
|
-
|
|
119
|
+
throw new Error(`Couldn't find "package.json" up from path "${root}"`);
|
|
118
120
|
};
|
|
119
121
|
const loadPackageJSONAsync = async (packageJsonPath) => {
|
|
120
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"],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CAAC,WAAW,IAAI,EAAE,CAAC;iBAC/B,CAAC;YACJ,CAAC;YACD,IAAI,qBAAqB,CAAC,YAAY,EAAE,CAAC;gBACvC,OAAO,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;YACxF,CAAC;YAED,OAAO;gBACL,GAAG,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC;gBAChD,QAAQ;aACT,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 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 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,IA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AAO,CAAC,WAAW,IAAI,EAAE,CAAC;iBAC/B,CAAC;YACJ,CAAC;YACD,IAAI,qBAAqB,CAAC,YAAY,EAAE,CAAC;gBACvC,OAAO,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;YACxF,CAAC;YAED,OAAO;gBACL,GAAG,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC;gBAChD,QAAQ;aACT,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,o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CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,8CAA8C,GAAG,GAAG,CAAC,CAAC;AACxE,CAAC;AAED,kBAAkB;AACX,KAAK,UAAU,uBAAuB,CAC3C,WAA4B,EAC5B,GAAW;IAEX,OAAO,IAAA,yCAAoB,EAAC,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
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": "87186d10c8239c6469e055417e67bd4d0ed63efb"
|
|
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
|
|
|
@@ -78,9 +77,10 @@ const parsePackageJsonOptions = (
|
|
|
78
77
|
const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;
|
|
79
78
|
let platformOptions: Record<string, unknown> | null = null;
|
|
80
79
|
if (platform) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
platformOptions =
|
|
81
|
+
autolinkingOptions && isJSONObject(autolinkingOptions[platform])
|
|
82
|
+
? autolinkingOptions[platform]
|
|
83
|
+
: null;
|
|
84
84
|
if (!platformOptions && platform === 'apple') {
|
|
85
85
|
// NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should
|
|
86
86
|
// be the base option for other apple platforms, but changing this now is a breaking change
|
|
@@ -183,12 +183,14 @@ const parseExtraArgumentsOptions = (
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
const findPackageJsonPathAsync = async (commandRoot: string | null): Promise<string> => {
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
+
}
|
|
190
192
|
}
|
|
191
|
-
|
|
193
|
+
throw new Error(`Couldn't find "package.json" up from path "${root}"`);
|
|
192
194
|
};
|
|
193
195
|
|
|
194
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 */
|