expo-modules-autolinking 55.0.17 → 55.0.18
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 +11 -0
- package/build/dependencies/CachedDependenciesLinker.d.ts +2 -1
- package/build/dependencies/CachedDependenciesLinker.js +10 -5
- package/build/dependencies/CachedDependenciesLinker.js.map +1 -1
- package/build/dependencies/index.d.ts +1 -1
- package/build/dependencies/index.js +2 -1
- package/build/dependencies/index.js.map +1 -1
- package/build/dependencies/scanning.d.ts +3 -1
- package/build/dependencies/scanning.js +15 -0
- package/build/dependencies/scanning.js.map +1 -1
- package/build/exports.d.ts +1 -0
- package/build/exports.js +1 -0
- package/build/exports.js.map +1 -1
- package/build/reactNativeConfig/reactNativeConfig.js +21 -4
- package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
- package/build/utilities/index.d.ts +1 -0
- package/build/utilities/index.js +7 -0
- package/build/utilities/index.js.map +1 -0
- package/build/utilities/isNativeModule.d.ts +2 -0
- package/build/utilities/isNativeModule.js +13 -0
- package/build/utilities/isNativeModule.js.map +1 -0
- package/package.json +2 -2
- package/scripts/ios/autolinking_manager.rb +1 -0
- package/scripts/ios/precompiled_modules.rb +105 -2
- package/src/dependencies/CachedDependenciesLinker.ts +21 -11
- package/src/dependencies/index.ts +1 -1
- package/src/dependencies/scanning.ts +15 -0
- package/src/exports.ts +2 -0
- package/src/reactNativeConfig/reactNativeConfig.ts +25 -5
- package/src/utilities/index.ts +3 -0
- package/src/utilities/isNativeModule.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 55.0.18 — 2026-04-21
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix missing deep object merging that should allow a project config to override a dependency's per-platform config options selectively ([#44668](https://github.com/expo/expo/pull/44668) by [@kitten](https://github.com/kitten))
|
|
18
|
+
|
|
19
|
+
### 💡 Others
|
|
20
|
+
|
|
21
|
+
- Expose `isNativeModuleAsync` utility in internal exports ([#44458](https://github.com/expo/expo/pull/44458) by [@kitten](https://github.com/kitten))
|
|
22
|
+
|
|
13
23
|
## 55.0.17 — 2026-04-10
|
|
14
24
|
|
|
15
25
|
_This version does not introduce any user-facing changes._
|
|
@@ -215,6 +225,7 @@ _This version does not introduce any user-facing changes._
|
|
|
215
225
|
|
|
216
226
|
### 💡 Others
|
|
217
227
|
|
|
228
|
+
- [iOS] Added modular headers for companion pods ([#44805](https://github.com/expo/expo/pull/44805) by [@chrfalch](https://github.com/chrfalch))
|
|
218
229
|
- [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))
|
|
219
230
|
- Remove dependency on `find-up` ([#39470](https://github.com/expo/expo/pull/39470) by [@kitten](https://github.com/kitten))
|
|
220
231
|
- [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))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PackageRevision, SupportedPlatform } from '../types';
|
|
2
|
-
import { type ResolutionResult } from './types';
|
|
2
|
+
import { type ResolutionResult, DependencyResolution } from './types';
|
|
3
3
|
import { type Memoizer } from '../memoize';
|
|
4
4
|
import { RNConfigReactNativeProjectConfig } from '../reactNativeConfig';
|
|
5
5
|
export interface CachedDependenciesSearchOptions {
|
|
@@ -18,5 +18,6 @@ export interface CachedDependenciesLinker {
|
|
|
18
18
|
export declare function makeCachedDependenciesLinker(params: {
|
|
19
19
|
projectRoot: string;
|
|
20
20
|
}): CachedDependenciesLinker;
|
|
21
|
+
export declare function isNativeModuleAsync(resolution: DependencyResolution, reactNativeProjectConfig: RNConfigReactNativeProjectConfig | null, platform: SupportedPlatform, excludeNames: Set<string>): Promise<boolean>;
|
|
21
22
|
export declare function scanDependencyResolutionsForPlatform(linker: CachedDependenciesLinker, platform: SupportedPlatform, extraInclude?: string[]): Promise<ResolutionResult>;
|
|
22
23
|
export declare function scanExpoModuleResolutionsForPlatform(linker: CachedDependenciesLinker, platform: SupportedPlatform, extraInclude?: string[]): Promise<Record<string, PackageRevision>>;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeCachedDependenciesLinker = makeCachedDependenciesLinker;
|
|
7
|
+
exports.isNativeModuleAsync = isNativeModuleAsync;
|
|
7
8
|
exports.scanDependencyResolutionsForPlatform = scanDependencyResolutionsForPlatform;
|
|
8
9
|
exports.scanExpoModuleResolutionsForPlatform = scanExpoModuleResolutionsForPlatform;
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -64,6 +65,13 @@ function makeCachedDependenciesLinker(params) {
|
|
|
64
65
|
},
|
|
65
66
|
};
|
|
66
67
|
}
|
|
68
|
+
async function isNativeModuleAsync(resolution, reactNativeProjectConfig, platform, excludeNames) {
|
|
69
|
+
const [reactNativeModule, expoModule] = await Promise.all([
|
|
70
|
+
(0, reactNativeConfig_1.resolveReactNativeModule)(resolution, reactNativeProjectConfig, platform, excludeNames),
|
|
71
|
+
(0, findModules_1.resolveExpoModule)(resolution, platform, excludeNames),
|
|
72
|
+
]);
|
|
73
|
+
return !!reactNativeModule || !!expoModule;
|
|
74
|
+
}
|
|
67
75
|
async function scanDependencyResolutionsForPlatform(linker, platform, extraInclude) {
|
|
68
76
|
const opts = await linker.getOptionsForPlatform(platform, extraInclude);
|
|
69
77
|
const reactNativeProjectConfig = await linker.loadReactNativeProjectConfig();
|
|
@@ -91,11 +99,8 @@ async function scanDependencyResolutionsForPlatform(linker, platform, extraInclu
|
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
101
|
else {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
(0, findModules_1.resolveExpoModule)(resolution, platform, opts.excludeNames),
|
|
97
|
-
]);
|
|
98
|
-
if (!reactNativeModule && !expoModule) {
|
|
102
|
+
const isNativeModule = await isNativeModuleAsync(resolution, reactNativeProjectConfig, platform, opts.excludeNames);
|
|
103
|
+
if (!isNativeModule) {
|
|
99
104
|
return null;
|
|
100
105
|
}
|
|
101
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CachedDependenciesLinker.js","sourceRoot":"","sources":["../../src/dependencies/CachedDependenciesLinker.ts"],"names":[],"mappings":";;;;;AAgCA,oEA8DC;AAED,oFAuDC;AAED,oFAuBC;AAhLD,4CAAoB;AAGpB,6CAA2D;AAC3D,6CAAmE;AACnE,yCAA0D;AAE1D,mCAA4E;AAC5E,4DAA+D;AAC/D,uEAAoG;AACpG,wCAA2D;AAC3D,4DAAkG;AAClG,wDAA8D;AAoB9D,SAAgB,4BAA4B,CAAC,MAE5C;IACC,MAAM,QAAQ,GAAG,IAAA,wBAAc,GAAE,CAAC;IAElC,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;QAC9D,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC;IAEH,IAAI,OAAoC,CAAC;IACzC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,IAAI,CAAC,OAAO,GAAG,wBAAwB,CAAC,UAAU,EAAE,CAAC,CAAC;IAEtF,MAAM,8BAA8B,GAAG,IAAI,GAAG,EAAqC,CAAC;IACpF,IAAI,wBAAsF,CAAC;IAC3F,IAAI,oCAA2E,CAAC;IAChF,IAAI,qBAA4D,CAAC;IAEjE,OAAO;QACL,QAAQ;QACR,KAAK,CAAC,qBAAqB,CAAC,QAAQ,EAAE,YAAY;YAChD,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YAC5E,OAAO,mCAAmC,CAAC,OAAO,EAAE,Y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,QAAQ,EAAE,YAAY,CAAC;gBAC7D,CAAC,CAAC,IAAI,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,mCAAmC,GAAG,CAC1C,OAA2B,EAC3B,YAAuB,EACvB,EAAE,CAAC,CAAC;IACJ,YAAY,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;IACtC,YAAY,EAAE,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7F,WAAW,EACT,OAAO,CAAC,gBAAgB,IAAI,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACjE,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;CAClC,CAAC,CAAC","sourcesContent":["import fs from 'fs';\n\nimport { PackageRevision, SupportedPlatform } from '../types';\nimport { scanDependenciesRecursively } from './resolution';\nimport { scanDependenciesFromRNProjectConfig } from './rncliLocal';\nimport { scanDependenciesInSearchPath } from './scanning';\nimport { type ResolutionResult, DependencyResolutionSource } from './types';\nimport { filterMapResolutionResult, mergeResolutionResults } from './utils';\nimport { resolveExpoModule } from '../autolinking/findModules';\nimport { AutolinkingOptions, createAutolinkingOptionsLoader } from '../commands/autolinkingOptions';\nimport { createMemoizer, type Memoizer } from '../memoize';\nimport { resolveReactNativeModule, RNConfigReactNativeProjectConfig } from '../reactNativeConfig';\nimport { loadConfigAsync } from '../reactNativeConfig/config';\n\nexport interface CachedDependenciesSearchOptions {\n includeNames: Set<string>;\n excludeNames: Set<string>;\n searchPaths: string[];\n}\n\nexport interface CachedDependenciesLinker {\n memoizer: Memoizer;\n getOptionsForPlatform(\n platform: SupportedPlatform,\n extraInclude?: string[]\n ): Promise<CachedDependenciesSearchOptions>;\n loadReactNativeProjectConfig(): Promise<RNConfigReactNativeProjectConfig | null>;\n scanDependenciesFromRNProjectConfig(): Promise<ResolutionResult>;\n scanDependenciesRecursively(): Promise<ResolutionResult>;\n scanDependenciesInSearchPath(searchPath: string): Promise<ResolutionResult>;\n}\n\nexport function makeCachedDependenciesLinker(params: {\n projectRoot: string;\n}): CachedDependenciesLinker {\n const memoizer = createMemoizer();\n\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n projectRoot: params.projectRoot,\n });\n\n let appRoot: Promise<string> | undefined;\n const getAppRoot = () => appRoot || (appRoot = autolinkingOptionsLoader.getAppRoot());\n\n const dependenciesResultBySearchPath = new Map<string, Promise<ResolutionResult>>();\n let reactNativeProjectConfig: Promise<RNConfigReactNativeProjectConfig | null> | undefined;\n let reactNativeProjectConfigDependencies: Promise<ResolutionResult> | undefined;\n let recursiveDependencies: Promise<ResolutionResult> | undefined;\n\n return {\n memoizer,\n async getOptionsForPlatform(platform, extraInclude) {\n const options = await autolinkingOptionsLoader.getPlatformOptions(platform);\n return makeCachedDependenciesSearchOptions(options, extraInclude);\n },\n async loadReactNativeProjectConfig() {\n if (reactNativeProjectConfig === undefined) {\n reactNativeProjectConfig = memoizer.call(\n loadConfigAsync,\n await getAppRoot()\n ) as Promise<RNConfigReactNativeProjectConfig | null>;\n }\n return reactNativeProjectConfig;\n },\n async scanDependenciesFromRNProjectConfig() {\n if (reactNativeProjectConfigDependencies === undefined) {\n reactNativeProjectConfigDependencies = memoizer.withMemoizer(async () => {\n return await scanDependenciesFromRNProjectConfig(\n await getAppRoot(),\n await this.loadReactNativeProjectConfig()\n );\n });\n }\n return reactNativeProjectConfigDependencies;\n },\n async scanDependenciesRecursively() {\n if (recursiveDependencies === undefined) {\n recursiveDependencies = memoizer.withMemoizer(async () => {\n return scanDependenciesRecursively(await getAppRoot());\n });\n }\n return recursiveDependencies;\n },\n async scanDependenciesInSearchPath(searchPath: string) {\n let result = dependenciesResultBySearchPath.get(searchPath);\n if (!result) {\n dependenciesResultBySearchPath.set(\n searchPath,\n (result = memoizer.withMemoizer(scanDependenciesInSearchPath, searchPath))\n );\n }\n return result;\n },\n };\n}\n\nexport async function scanDependencyResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform,\n extraInclude?: string[]\n): Promise<ResolutionResult> {\n const opts = await linker.getOptionsForPlatform(platform, extraInclude);\n const reactNativeProjectConfig = await linker.loadReactNativeProjectConfig();\n\n const resolutions = mergeResolutionResults(\n await Promise.all([\n linker.scanDependenciesFromRNProjectConfig(),\n ...opts.searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n linker.scanDependenciesRecursively(),\n ])\n );\n\n return await linker.memoizer.withMemoizer(async () => {\n const dependencies = await filterMapResolutionResult(resolutions, async (resolution) => {\n if (opts.excludeNames.has(resolution.name)) {\n return null;\n } else if (opts.includeNames.has(resolution.name)) {\n return resolution;\n } else if (resolution.source === DependencyResolutionSource.RN_CLI_LOCAL) {\n // If the dependency was resolved frpom the React Native project config, we'll only\n // attempt to resolve it as a React Native module\n const reactNativeModuleDesc = await resolveReactNativeModule(\n resolution,\n reactNativeProjectConfig,\n platform,\n opts.excludeNames\n );\n if (!reactNativeModuleDesc) {\n return null;\n }\n } else {\n const [reactNativeModule, expoModule] = await Promise.all([\n resolveReactNativeModule(\n resolution,\n reactNativeProjectConfig,\n platform,\n opts.excludeNames\n ),\n resolveExpoModule(resolution, platform, opts.excludeNames),\n ]);\n if (!reactNativeModule && !expoModule) {\n return null;\n }\n }\n return resolution;\n });\n\n return dependencies;\n });\n}\n\nexport async function scanExpoModuleResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform,\n extraInclude?: string[]\n): Promise<Record<string, PackageRevision>> {\n const { excludeNames, searchPaths } = await linker.getOptionsForPlatform(platform, extraInclude);\n const resolutions = mergeResolutionResults(\n await Promise.all(\n [\n ...searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n linker.scanDependenciesRecursively(),\n ].filter((x) => x != null)\n )\n );\n return await linker.memoizer.withMemoizer(async () => {\n return await filterMapResolutionResult(resolutions, async (resolution) => {\n return !excludeNames.has(resolution.name)\n ? await resolveExpoModule(resolution, platform, excludeNames)\n : null;\n });\n });\n}\n\nconst makeCachedDependenciesSearchOptions = (\n options: AutolinkingOptions,\n extraInclude?: string[]\n) => ({\n excludeNames: new Set(options.exclude),\n includeNames: new Set(extraInclude ? [...options.include, ...extraInclude] : options.include),\n searchPaths:\n options.nativeModulesDir && fs.existsSync(options.nativeModulesDir)\n ? [options.nativeModulesDir, ...(options.searchPaths ?? [])]\n : (options.searchPaths ?? []),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"CachedDependenciesLinker.js","sourceRoot":"","sources":["../../src/dependencies/CachedDependenciesLinker.ts"],"names":[],"mappings":";;;;;AAgCA,oEA8DC;AAED,kDAWC;AAED,oFAoDC;AAED,oFAuBC;AA1LD,4CAAoB;AAGpB,6CAA2D;AAC3D,6CAAmE;AACnE,yCAA0D;AAE1D,mCAA4E;AAC5E,4DAA+D;AAC/D,uEAAoG;AACpG,wCAA2D;AAC3D,4DAAkG;AAClG,wDAA8D;AAoB9D,SAAgB,4BAA4B,CAAC,MAE5C;IACC,MAAM,QAAQ,GAAG,IAAA,wBAAc,GAAE,CAAC;IAElC,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;QAC9D,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC;IAEH,IAAI,OAAoC,CAAC;IACzC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,IAAI,CAAC,OAAO,GAAG,wBAAwB,CAAC,UAAU,EAAE,CAAC,CAAC;IAEtF,MAAM,8BAA8B,GAAG,IAAI,GAAG,EAAqC,CAAC;IACpF,IAAI,wBAAsF,CAAC;IAC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ively } from './resolution';\nimport { scanDependenciesFromRNProjectConfig } from './rncliLocal';\nimport { scanDependenciesInSearchPath } from './scanning';\nimport { type ResolutionResult, DependencyResolution, DependencyResolutionSource } from './types';\nimport { filterMapResolutionResult, mergeResolutionResults } from './utils';\nimport { resolveExpoModule } from '../autolinking/findModules';\nimport { AutolinkingOptions, createAutolinkingOptionsLoader } from '../commands/autolinkingOptions';\nimport { createMemoizer, type Memoizer } from '../memoize';\nimport { resolveReactNativeModule, RNConfigReactNativeProjectConfig } from '../reactNativeConfig';\nimport { loadConfigAsync } from '../reactNativeConfig/config';\n\nexport interface CachedDependenciesSearchOptions {\n includeNames: Set<string>;\n excludeNames: Set<string>;\n searchPaths: string[];\n}\n\nexport interface CachedDependenciesLinker {\n memoizer: Memoizer;\n getOptionsForPlatform(\n platform: SupportedPlatform,\n extraInclude?: string[]\n ): Promise<CachedDependenciesSearchOptions>;\n loadReactNativeProjectConfig(): Promise<RNConfigReactNativeProjectConfig | null>;\n scanDependenciesFromRNProjectConfig(): Promise<ResolutionResult>;\n scanDependenciesRecursively(): Promise<ResolutionResult>;\n scanDependenciesInSearchPath(searchPath: string): Promise<ResolutionResult>;\n}\n\nexport function makeCachedDependenciesLinker(params: {\n projectRoot: string;\n}): CachedDependenciesLinker {\n const memoizer = createMemoizer();\n\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n projectRoot: params.projectRoot,\n });\n\n let appRoot: Promise<string> | undefined;\n const getAppRoot = () => appRoot || (appRoot = autolinkingOptionsLoader.getAppRoot());\n\n const dependenciesResultBySearchPath = new Map<string, Promise<ResolutionResult>>();\n let reactNativeProjectConfig: Promise<RNConfigReactNativeProjectConfig | null> | undefined;\n let reactNativeProjectConfigDependencies: Promise<ResolutionResult> | undefined;\n let recursiveDependencies: Promise<ResolutionResult> | undefined;\n\n return {\n memoizer,\n async getOptionsForPlatform(platform, extraInclude) {\n const options = await autolinkingOptionsLoader.getPlatformOptions(platform);\n return makeCachedDependenciesSearchOptions(options, extraInclude);\n },\n async loadReactNativeProjectConfig() {\n if (reactNativeProjectConfig === undefined) {\n reactNativeProjectConfig = memoizer.call(\n loadConfigAsync,\n await getAppRoot()\n ) as Promise<RNConfigReactNativeProjectConfig | null>;\n }\n return reactNativeProjectConfig;\n },\n async scanDependenciesFromRNProjectConfig() {\n if (reactNativeProjectConfigDependencies === undefined) {\n reactNativeProjectConfigDependencies = memoizer.withMemoizer(async () => {\n return await scanDependenciesFromRNProjectConfig(\n await getAppRoot(),\n await this.loadReactNativeProjectConfig()\n );\n });\n }\n return reactNativeProjectConfigDependencies;\n },\n async scanDependenciesRecursively() {\n if (recursiveDependencies === undefined) {\n recursiveDependencies = memoizer.withMemoizer(async () => {\n return scanDependenciesRecursively(await getAppRoot());\n });\n }\n return recursiveDependencies;\n },\n async scanDependenciesInSearchPath(searchPath: string) {\n let result = dependenciesResultBySearchPath.get(searchPath);\n if (!result) {\n dependenciesResultBySearchPath.set(\n searchPath,\n (result = memoizer.withMemoizer(scanDependenciesInSearchPath, searchPath))\n );\n }\n return result;\n },\n };\n}\n\nexport async function isNativeModuleAsync(\n resolution: DependencyResolution,\n reactNativeProjectConfig: RNConfigReactNativeProjectConfig | null,\n platform: SupportedPlatform,\n excludeNames: Set<string>\n) {\n const [reactNativeModule, expoModule] = await Promise.all([\n resolveReactNativeModule(resolution, reactNativeProjectConfig, platform, excludeNames),\n resolveExpoModule(resolution, platform, excludeNames),\n ]);\n return !!reactNativeModule || !!expoModule;\n}\n\nexport async function scanDependencyResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform,\n extraInclude?: string[]\n): Promise<ResolutionResult> {\n const opts = await linker.getOptionsForPlatform(platform, extraInclude);\n const reactNativeProjectConfig = await linker.loadReactNativeProjectConfig();\n\n const resolutions = mergeResolutionResults(\n await Promise.all([\n linker.scanDependenciesFromRNProjectConfig(),\n ...opts.searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n linker.scanDependenciesRecursively(),\n ])\n );\n\n return await linker.memoizer.withMemoizer(async () => {\n const dependencies = await filterMapResolutionResult(resolutions, async (resolution) => {\n if (opts.excludeNames.has(resolution.name)) {\n return null;\n } else if (opts.includeNames.has(resolution.name)) {\n return resolution;\n } else if (resolution.source === DependencyResolutionSource.RN_CLI_LOCAL) {\n // If the dependency was resolved frpom the React Native project config, we'll only\n // attempt to resolve it as a React Native module\n const reactNativeModuleDesc = await resolveReactNativeModule(\n resolution,\n reactNativeProjectConfig,\n platform,\n opts.excludeNames\n );\n if (!reactNativeModuleDesc) {\n return null;\n }\n } else {\n const isNativeModule = await isNativeModuleAsync(\n resolution,\n reactNativeProjectConfig,\n platform,\n opts.excludeNames\n );\n if (!isNativeModule) {\n return null;\n }\n }\n return resolution;\n });\n\n return dependencies;\n });\n}\n\nexport async function scanExpoModuleResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform,\n extraInclude?: string[]\n): Promise<Record<string, PackageRevision>> {\n const { excludeNames, searchPaths } = await linker.getOptionsForPlatform(platform, extraInclude);\n const resolutions = mergeResolutionResults(\n await Promise.all(\n [\n ...searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n linker.scanDependenciesRecursively(),\n ].filter((x) => x != null)\n )\n );\n return await linker.memoizer.withMemoizer(async () => {\n return await filterMapResolutionResult(resolutions, async (resolution) => {\n return !excludeNames.has(resolution.name)\n ? await resolveExpoModule(resolution, platform, excludeNames)\n : null;\n });\n });\n}\n\nconst makeCachedDependenciesSearchOptions = (\n options: AutolinkingOptions,\n extraInclude?: string[]\n) => ({\n excludeNames: new Set(options.exclude),\n includeNames: new Set(extraInclude ? [...options.include, ...extraInclude] : options.include),\n searchPaths:\n options.nativeModulesDir && fs.existsSync(options.nativeModulesDir)\n ? [options.nativeModulesDir, ...(options.searchPaths ?? [])]\n : (options.searchPaths ?? []),\n});\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { scanDependenciesRecursively } from './resolution';
|
|
2
|
-
export { scanDependenciesInSearchPath } from './scanning';
|
|
2
|
+
export { scanDependenciesInSearchPath, mockDependencyAtPath } from './scanning';
|
|
3
3
|
export { scanDependenciesFromRNProjectConfig } from './rncliLocal';
|
|
4
4
|
export { filterMapResolutionResult, mergeResolutionResults } from './utils';
|
|
5
5
|
export * from './CachedDependenciesLinker';
|
|
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.mergeResolutionResults = exports.filterMapResolutionResult = exports.scanDependenciesFromRNProjectConfig = exports.scanDependenciesInSearchPath = exports.scanDependenciesRecursively = void 0;
|
|
17
|
+
exports.mergeResolutionResults = exports.filterMapResolutionResult = exports.scanDependenciesFromRNProjectConfig = exports.mockDependencyAtPath = exports.scanDependenciesInSearchPath = exports.scanDependenciesRecursively = void 0;
|
|
18
18
|
var resolution_1 = require("./resolution");
|
|
19
19
|
Object.defineProperty(exports, "scanDependenciesRecursively", { enumerable: true, get: function () { return resolution_1.scanDependenciesRecursively; } });
|
|
20
20
|
var scanning_1 = require("./scanning");
|
|
21
21
|
Object.defineProperty(exports, "scanDependenciesInSearchPath", { enumerable: true, get: function () { return scanning_1.scanDependenciesInSearchPath; } });
|
|
22
|
+
Object.defineProperty(exports, "mockDependencyAtPath", { enumerable: true, get: function () { return scanning_1.mockDependencyAtPath; } });
|
|
22
23
|
var rncliLocal_1 = require("./rncliLocal");
|
|
23
24
|
Object.defineProperty(exports, "scanDependenciesFromRNProjectConfig", { enumerable: true, get: function () { return rncliLocal_1.scanDependenciesFromRNProjectConfig; } });
|
|
24
25
|
var utils_1 = require("./utils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dependencies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAA2D;AAAlD,yHAAA,2BAA2B,OAAA;AACpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dependencies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAA2D;AAAlD,yHAAA,2BAA2B,OAAA;AACpC,uCAAgF;AAAvE,wHAAA,4BAA4B,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AAC3D,2CAAmE;AAA1D,iIAAA,mCAAmC,OAAA;AAC5C,iCAA4E;AAAnE,kHAAA,yBAAyB,OAAA;AAAE,+GAAA,sBAAsB,OAAA;AAC1D,6DAA2C;AAC3C,0CAAwB","sourcesContent":["export { scanDependenciesRecursively } from './resolution';\nexport { scanDependenciesInSearchPath, mockDependencyAtPath } from './scanning';\nexport { scanDependenciesFromRNProjectConfig } from './rncliLocal';\nexport { filterMapResolutionResult, mergeResolutionResults } from './utils';\nexport * from './CachedDependenciesLinker';\nexport * from './types';\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { type ResolutionResult } from './types';
|
|
1
|
+
import { type ResolutionResult, type DependencyResolution } from './types';
|
|
2
|
+
/** Create a mock resolution for a local search path dependency at the given path */
|
|
3
|
+
export declare function mockDependencyAtPath(originPath: string): Promise<DependencyResolution>;
|
|
2
4
|
interface ResolutionOptions {
|
|
3
5
|
shouldIncludeDependency?(name: string): boolean;
|
|
4
6
|
}
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mockDependencyAtPath = mockDependencyAtPath;
|
|
6
7
|
exports.scanDependenciesInSearchPath = scanDependenciesInSearchPath;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const concurrency_1 = require("../concurrency");
|
|
@@ -41,6 +42,20 @@ async function resolveDependency(basePath, dependencyName, shouldIncludeDependen
|
|
|
41
42
|
return null;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
/** Create a mock resolution for a local search path dependency at the given path */
|
|
46
|
+
async function mockDependencyAtPath(originPath) {
|
|
47
|
+
const realPath = await (0, utils_2.maybeRealpath)(originPath);
|
|
48
|
+
const packageJson = await (0, utils_2.loadPackageJson)((0, utils_2.fastJoin)(realPath || originPath, 'package.json'));
|
|
49
|
+
return {
|
|
50
|
+
source: 1 /* DependencyResolutionSource.SEARCH_PATH */,
|
|
51
|
+
name: packageJson?.name || 'local-module', // NOTE: Mock name
|
|
52
|
+
version: packageJson?.version ?? '',
|
|
53
|
+
path: realPath ?? originPath,
|
|
54
|
+
originPath,
|
|
55
|
+
duplicates: null,
|
|
56
|
+
depth: 0,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
44
59
|
async function scanDependenciesInSearchPath(rawPath, { shouldIncludeDependency = utils_1.defaultShouldIncludeDependency } = {}) {
|
|
45
60
|
const rootPath = await (0, utils_2.maybeRealpath)(rawPath);
|
|
46
61
|
const searchResults = Object.create(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanning.js","sourceRoot":"","sources":["../../src/dependencies/scanning.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"scanning.js","sourceRoot":"","sources":["../../src/dependencies/scanning.ts"],"names":[],"mappings":";;;;;AAgDA,oDAYC;AAMD,oEAuEC;AAzID,4CAAoB;AAOpB,gDAAyC;AACzC,mCAAyD;AACzD,oCAAoE;AAEpE,KAAK,UAAU,iBAAiB,CAC9B,QAAgB,EAChB,cAA6B,EAC7B,uBAA4D;IAE5D,IAAI,cAAc,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,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AAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAC3D,MAAM,UAAU,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC7C,MAAM,SAAS,GAAG,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,SAAS,IAAI,IAAI,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;YAC5D,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;gBACzD,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,OAAO,EAAE,UAAU,CAAC,OAAO;gBAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,UAAU,EAAE,UAAU,CAAC,UAAU;aAClC,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7B,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import fs from 'fs';\n\nimport {\n type ResolutionResult,\n type DependencyResolution,\n DependencyResolutionSource,\n} from './types';\nimport { taskAll } from '../concurrency';\nimport { defaultShouldIncludeDependency } from './utils';\nimport { loadPackageJson, maybeRealpath, fastJoin } from '../utils';\n\nasync function resolveDependency(\n basePath: string,\n dependencyName: string | null,\n shouldIncludeDependency: (dependencyName: string) => boolean\n): Promise<DependencyResolution | null> {\n if (dependencyName && !shouldIncludeDependency(dependencyName)) {\n return null;\n }\n const originPath = dependencyName ? fastJoin(basePath, dependencyName) : basePath;\n const realPath = await maybeRealpath(originPath);\n const packageJson = await loadPackageJson(fastJoin(realPath || originPath, 'package.json'));\n if (packageJson) {\n return {\n source: DependencyResolutionSource.SEARCH_PATH,\n name: packageJson.name || '',\n version: packageJson.version || '',\n path: realPath || originPath,\n originPath,\n duplicates: null,\n depth: 0,\n };\n } else if (dependencyName && realPath) {\n return {\n source: DependencyResolutionSource.SEARCH_PATH,\n name: dependencyName.toLowerCase(),\n version: '',\n path: realPath,\n originPath,\n duplicates: null,\n depth: 0,\n };\n } else {\n return null;\n }\n}\n\n/** Create a mock resolution for a local search path dependency at the given path */\nexport async function mockDependencyAtPath(originPath: string): Promise<DependencyResolution> {\n const realPath = await maybeRealpath(originPath);\n const packageJson = await loadPackageJson(fastJoin(realPath || originPath, 'package.json'));\n return {\n source: DependencyResolutionSource.SEARCH_PATH,\n name: packageJson?.name || 'local-module', // NOTE: Mock name\n version: packageJson?.version ?? '',\n path: realPath ?? originPath,\n originPath,\n duplicates: null,\n depth: 0,\n };\n}\n\ninterface ResolutionOptions {\n shouldIncludeDependency?(name: string): boolean;\n}\n\nexport async function scanDependenciesInSearchPath(\n rawPath: string,\n { shouldIncludeDependency = defaultShouldIncludeDependency }: ResolutionOptions = {}\n): Promise<ResolutionResult> {\n const rootPath = await maybeRealpath(rawPath);\n const searchResults: ResolutionResult = Object.create(null);\n if (!rootPath) {\n return searchResults;\n }\n\n const resolvedDependencies: DependencyResolution[] = [];\n\n const localModuleTarget = await maybeRealpath(fastJoin(rootPath, 'package.json'));\n if (localModuleTarget) {\n // If we have a `package.json` file in the search path, we're already dealing with a node module\n // and can skip the rest. This is a special case created by create-expo-module's `nativeModulesDir: ../`\n const resolution = await resolveDependency(rootPath, null, shouldIncludeDependency);\n if (resolution) resolvedDependencies.push(resolution);\n } else {\n const dirents = await fs.promises.readdir(rootPath!, { withFileTypes: true });\n await taskAll(dirents, async (entry) => {\n if (entry.isSymbolicLink()) {\n const resolution = await resolveDependency(rootPath, entry.name, shouldIncludeDependency);\n if (resolution) resolvedDependencies.push(resolution);\n } else if (entry.isDirectory()) {\n if (entry.name === 'node_modules') {\n // Ignore nested node_modules folder\n }\n if (entry.name[0] === '.') {\n // Ignore hidden folders\n } else if (entry.name[0] === '@') {\n // NOTE: We don't expect @-scope folders to be symlinks\n const entryPath = fastJoin(rootPath, entry.name);\n const childEntries = await fs.promises.readdir(entryPath, { withFileTypes: true });\n await Promise.all(\n childEntries.map(async (child) => {\n const dependencyName = `${entry.name}/${child.name}`;\n if (child.isDirectory() || child.isSymbolicLink()) {\n const resolution = await resolveDependency(\n rootPath,\n dependencyName,\n shouldIncludeDependency\n );\n if (resolution) resolvedDependencies.push(resolution);\n }\n })\n );\n } else {\n const resolution = await resolveDependency(rootPath, entry.name, shouldIncludeDependency);\n if (resolution) resolvedDependencies.push(resolution);\n }\n }\n });\n }\n\n for (let idx = 0; idx < resolvedDependencies.length; idx++) {\n const resolution = resolvedDependencies[idx];\n const prevEntry = searchResults[resolution.name];\n if (prevEntry != null && resolution.path !== prevEntry.path) {\n (prevEntry.duplicates ?? (prevEntry.duplicates = [])).push({\n name: resolution.name,\n version: resolution.version,\n path: resolution.path,\n originPath: resolution.originPath,\n });\n } else if (prevEntry == null) {\n searchResults[resolution.name] = resolution;\n }\n }\n\n return searchResults;\n}\n"]}
|
package/build/exports.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './types';
|
|
|
4
4
|
export * from './autolinking';
|
|
5
5
|
export * from './platforms';
|
|
6
6
|
export { ResolutionResult, BaseDependencyResolution, DependencyResolution, DependencyResolutionSource, CachedDependenciesLinker, CachedDependenciesSearchOptions, makeCachedDependenciesLinker, scanDependencyResolutionsForPlatform, scanExpoModuleResolutionsForPlatform, } from './dependencies';
|
|
7
|
+
export * from './utilities';
|
|
7
8
|
/** @deprecated */
|
|
8
9
|
export declare function mergeLinkingOptionsAsync<Options extends Partial<AutolinkingCommonArguments>>(argumentsOptions: Options): Promise<Options & AutolinkingOptions>;
|
|
9
10
|
interface QueryAutolinkingModulesFromProjectParams extends Partial<AutolinkingCommonArguments> {
|
package/build/exports.js
CHANGED
|
@@ -34,6 +34,7 @@ var dependencies_1 = require("./dependencies");
|
|
|
34
34
|
Object.defineProperty(exports, "makeCachedDependenciesLinker", { enumerable: true, get: function () { return dependencies_1.makeCachedDependenciesLinker; } });
|
|
35
35
|
Object.defineProperty(exports, "scanDependencyResolutionsForPlatform", { enumerable: true, get: function () { return dependencies_1.scanDependencyResolutionsForPlatform; } });
|
|
36
36
|
Object.defineProperty(exports, "scanExpoModuleResolutionsForPlatform", { enumerable: true, get: function () { return dependencies_1.scanExpoModuleResolutionsForPlatform; } });
|
|
37
|
+
__exportStar(require("./utilities"), exports);
|
|
37
38
|
/** @deprecated */
|
|
38
39
|
async function mergeLinkingOptionsAsync(argumentsOptions) {
|
|
39
40
|
const autolinkingOptionsLoader = (0, autolinkingOptions_1.createAutolinkingOptionsLoader)(argumentsOptions);
|
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":";;;;;;;;;;;;;;;;;;;;AAgCA,4DASC;AAQD,0FAaC;AAGD,kDAQC;AAGD,0DAKC;AAjFD,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,8CAA4B;AAE5B,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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AC,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\nexport * from './utilities';\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"]}
|
|
@@ -14,6 +14,22 @@ const iosResolver_1 = require("./iosResolver");
|
|
|
14
14
|
const ExpoModuleConfig_1 = require("../ExpoModuleConfig");
|
|
15
15
|
const dependencies_1 = require("../dependencies");
|
|
16
16
|
const webResolver_1 = require("./webResolver");
|
|
17
|
+
const deepObjectMerge = (target, source) => {
|
|
18
|
+
if (source !== undefined &&
|
|
19
|
+
typeof target === 'object' &&
|
|
20
|
+
target != null &&
|
|
21
|
+
!Array.isArray(target) &&
|
|
22
|
+
(!target.constructor || target.constructor === Object) &&
|
|
23
|
+
typeof source === 'object' &&
|
|
24
|
+
!Array.isArray(source)) {
|
|
25
|
+
target = { ...target };
|
|
26
|
+
for (const key in source) {
|
|
27
|
+
target[key] = deepObjectMerge(target[key], source[key]);
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
return source !== undefined ? source : target;
|
|
32
|
+
};
|
|
17
33
|
const isMissingFBReactNativeSpecCodegenOutput = async (reactNativePath) => {
|
|
18
34
|
const generatedDir = path_1.default.resolve(reactNativePath, 'React/FBReactNativeSpec');
|
|
19
35
|
try {
|
|
@@ -42,15 +58,16 @@ async function resolveReactNativeModule(resolution, projectConfig, platform, exc
|
|
|
42
58
|
const shouldUseOriginPath = platform === 'android' && resolution.path.includes('=') && resolution.path.includes('.pnpm');
|
|
43
59
|
const modulePath = shouldUseOriginPath ? resolution.originPath : resolution.path;
|
|
44
60
|
const libraryConfig = (await (0, config_1.loadConfigAsync)(modulePath));
|
|
45
|
-
const reactNativeConfig = {
|
|
46
|
-
...libraryConfig?.dependency,
|
|
47
|
-
...projectConfig?.dependencies?.[resolution.name],
|
|
48
|
-
};
|
|
49
61
|
if (Object.keys(libraryConfig?.platforms ?? {}).length > 0) {
|
|
50
62
|
// Package defines platforms would be a platform host package.
|
|
51
63
|
// The rnc-cli will skip this package.
|
|
52
64
|
return null;
|
|
53
65
|
}
|
|
66
|
+
let reactNativeConfig = libraryConfig?.dependency ?? {};
|
|
67
|
+
const projectDependencyOverride = projectConfig?.dependencies?.[resolution.name];
|
|
68
|
+
if (projectDependencyOverride != null) {
|
|
69
|
+
reactNativeConfig = deepObjectMerge(reactNativeConfig, projectDependencyOverride);
|
|
70
|
+
}
|
|
54
71
|
let maybeExpoModuleConfig;
|
|
55
72
|
if (!libraryConfig) {
|
|
56
73
|
// NOTE(@kitten): If we don't have an explicit react-native.config.{js,ts} file,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeConfig.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.ts"],"names":[],"mappings":";;;;;AA2CA,4DAmFC;AAWD,oEA0DC;AAED,oEA+BC;AApOD,4CAAoB;AACpB,gDAAwB;AAGxB,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AAWpE,0DAAsF;AAEtF,kDAOyB;AACzB,+CAAwD;AAExD,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,U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;QACL,IAAI,EAAE,OAAO;QACb,eAAe,EAAE,WAAW,CAAC,cAAc,CAAC,EAAE,IAAK;QACnD,YAAY;QACZ,OAAO,EAAE,MAAM,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC;KAC7F,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,4BAA4B,CAChD,WAAmB,EACnB,QAA2B,EAC3B,SAAkB;IAElB,sGAAsG;IACtG,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,SAAS,IAAI,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAClE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,4CAA0B,EAAC,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAChG,IAAI,MAAM,IAAI,IAAI,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACvC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,IAAA,uCAAqB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAElE,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 RNConfigDependencyWeb,\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';\nimport { checkDependencyWebAsync } from './webResolver';\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 } 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 // NOTE(@kitten): `loadConfigAsync` is skipped too, because react-native's config is too slow\n return null;\n }\n\n // Workaround for Android Gradle/Prefab issue with special characters in paths.\n // pnpm creates virtual store paths with '=' characters (e.g., _patch_hash=abc123),\n // which cause build failures on Android due to Prefab not properly escaping them.\n // See: https://github.com/google/prefab/issues/187\n const shouldUseOriginPath =\n platform === 'android' && resolution.path.includes('=') && resolution.path.includes('.pnpm');\n const modulePath = shouldUseOriginPath ? resolution.originPath : resolution.path;\n\n const libraryConfig = (await loadConfigAsync(modulePath)) as RNConfigReactNativeLibraryConfig;\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 }\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:\n | RNConfigDependencyAndroid\n | RNConfigDependencyIos\n | RNConfigDependencyWeb\n | null = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n modulePath,\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 } else if (platform === 'web') {\n platformData = await checkDependencyWebAsync(\n resolution,\n reactNativeConfig,\n maybeExpoModuleConfig\n );\n }\n return (\n platformData && {\n root: modulePath,\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(appRoot)) as RNConfigReactNativeProjectConfig;\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(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":";;;;;AA8DA,4DAoFC;AAWD,oEA0DC;AAED,oEA+BC;AAxPD,4CAAoB;AACpB,gDAAwB;AAGxB,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AAWpE,0DAAsF;AAEtF,kDAOyB;AACzB,+CAAwD;AAExD,MAAM,eAAe,GAAG,CAAC,MAAW,EAAE,MAAW,EAAO,EAAE;IACxD,IACE,MAAM,KAAK,SAAS;QACpB,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,IAAI,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACtB,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC;QACtD,OAAO,MAAM,KAAK,QAAQ;QAC1B,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACtB,CAAC;QACD,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AAChD,C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AC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAElE,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 RNConfigDependencyWeb,\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';\nimport { checkDependencyWebAsync } from './webResolver';\n\nconst deepObjectMerge = (target: any, source: any): any => {\n if (\n source !== undefined &&\n typeof target === 'object' &&\n target != null &&\n !Array.isArray(target) &&\n (!target.constructor || target.constructor === Object) &&\n typeof source === 'object' &&\n !Array.isArray(source)\n ) {\n target = { ...target };\n for (const key in source) {\n target[key] = deepObjectMerge(target[key], source[key]);\n }\n return target;\n }\n return source !== undefined ? source : target;\n};\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 } 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 // NOTE(@kitten): `loadConfigAsync` is skipped too, because react-native's config is too slow\n return null;\n }\n\n // Workaround for Android Gradle/Prefab issue with special characters in paths.\n // pnpm creates virtual store paths with '=' characters (e.g., _patch_hash=abc123),\n // which cause build failures on Android due to Prefab not properly escaping them.\n // See: https://github.com/google/prefab/issues/187\n const shouldUseOriginPath =\n platform === 'android' && resolution.path.includes('=') && resolution.path.includes('.pnpm');\n const modulePath = shouldUseOriginPath ? resolution.originPath : resolution.path;\n\n const libraryConfig = (await loadConfigAsync(modulePath)) as RNConfigReactNativeLibraryConfig;\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 }\n\n let reactNativeConfig = libraryConfig?.dependency ?? {};\n const projectDependencyOverride = projectConfig?.dependencies?.[resolution.name];\n if (projectDependencyOverride != null) {\n reactNativeConfig = deepObjectMerge(reactNativeConfig, projectDependencyOverride);\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:\n | RNConfigDependencyAndroid\n | RNConfigDependencyIos\n | RNConfigDependencyWeb\n | null = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n modulePath,\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 } else if (platform === 'web') {\n platformData = await checkDependencyWebAsync(\n resolution,\n reactNativeConfig,\n maybeExpoModuleConfig\n );\n }\n return (\n platformData && {\n root: modulePath,\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(appRoot)) as RNConfigReactNativeProjectConfig;\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(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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isNativeModuleAsync } from './isNativeModule';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// NOTE: `./utilities` is meant as stable API utilities exposed from `expo-modules-autolinking/exports`
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isNativeModuleAsync = void 0;
|
|
5
|
+
var isNativeModule_1 = require("./isNativeModule");
|
|
6
|
+
Object.defineProperty(exports, "isNativeModuleAsync", { enumerable: true, get: function () { return isNativeModule_1.isNativeModuleAsync; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";AAAA,uGAAuG;;;AAEvG,mDAAuD;AAA9C,qHAAA,mBAAmB,OAAA","sourcesContent":["// NOTE: `./utilities` is meant as stable API utilities exposed from `expo-modules-autolinking/exports`\n\nexport { isNativeModuleAsync } from './isNativeModule';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNativeModuleAsync = isNativeModuleAsync;
|
|
4
|
+
const concurrency_1 = require("../concurrency");
|
|
5
|
+
const dependencies_1 = require("../dependencies");
|
|
6
|
+
/** Check if a path is potentially a native module */
|
|
7
|
+
async function isNativeModuleAsync(maybeModulePath) {
|
|
8
|
+
const resolution = await (0, dependencies_1.mockDependencyAtPath)(maybeModulePath);
|
|
9
|
+
const excludeNames = new Set();
|
|
10
|
+
const isNativeModules = await (0, concurrency_1.taskAll)(['android', 'apple'], (platform) => (0, dependencies_1.isNativeModuleAsync)(resolution, null, platform, excludeNames));
|
|
11
|
+
return isNativeModules.some((x) => !!x);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=isNativeModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNativeModule.js","sourceRoot":"","sources":["../../src/utilities/isNativeModule.ts"],"names":[],"mappings":";;AAQA,kDAOC;AAfD,gDAAyC;AACzC,kDAGyB;AAGzB,qDAAqD;AAC9C,KAAK,UAAU,mBAAmB,CAAC,eAAuB;IAC/D,MAAM,UAAU,GAAG,MAAM,IAAA,mCAAoB,EAAC,eAAe,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,MAAM,eAAe,GAAG,MAAM,IAAA,qBAAO,EAAC,CAAC,SAAS,EAAE,OAAO,CAAwB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAC9F,IAAA,kCAA6B,EAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CACxE,CAAC;IACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import { taskAll } from '../concurrency';\nimport {\n mockDependencyAtPath,\n isNativeModuleAsync as isDependencyNativeModuleAsync,\n} from '../dependencies';\nimport { SupportedPlatform } from '../types';\n\n/** Check if a path is potentially a native module */\nexport async function isNativeModuleAsync(maybeModulePath: string) {\n const resolution = await mockDependencyAtPath(maybeModulePath);\n const excludeNames = new Set<string>();\n const isNativeModules = await taskAll(['android', 'apple'] as SupportedPlatform[], (platform) =>\n isDependencyNativeModuleAsync(resolution, null, platform, excludeNames)\n );\n return isNativeModules.some((x) => !!x);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "55.0.
|
|
3
|
+
"version": "55.0.18",
|
|
4
4
|
"description": "Scripts that autolink Expo modules.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"chalk": "^4.1.0",
|
|
44
44
|
"commander": "^7.2.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "e37e614d97c3ca53f16b91609a787675d044c284"
|
|
47
47
|
}
|
|
@@ -129,6 +129,7 @@ module Expo
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
Expo::PrecompiledModules.register_external_pods(@podfile, @target_definition, project_directory)
|
|
132
|
+
Expo::PrecompiledModules.register_companion_pods(@podfile, @target_definition, project_directory, tests_only: tests_only)
|
|
132
133
|
|
|
133
134
|
self
|
|
134
135
|
end
|
|
@@ -336,6 +336,107 @@ module Expo
|
|
|
336
336
|
end
|
|
337
337
|
end
|
|
338
338
|
|
|
339
|
+
# Registers companion pods gated by a Podfile property.
|
|
340
|
+
# A product can declare `autolinkWhen` in its spm.config.json to opt into this flow.
|
|
341
|
+
# The pod is auto-registered when:
|
|
342
|
+
# 1. The podspec exists (source build) or prebuilt xcframework exists (precompiled)
|
|
343
|
+
# 2. The gating Podfile.properties.json value is not the disabled value
|
|
344
|
+
# 3. It's not already registered in the Podfile
|
|
345
|
+
# 4. All of its local dependencies (pods in the lookup map) are already registered
|
|
346
|
+
#
|
|
347
|
+
# Works for both precompiled and source builds. For precompiled builds, the
|
|
348
|
+
# podspec is patched to use the xcframework. For source builds, CocoaPods
|
|
349
|
+
# builds from source via :podspec.
|
|
350
|
+
#
|
|
351
|
+
# Companion pods are production-only code (they never declare test specs) and
|
|
352
|
+
# typically depend on their sibling main pod. When the Podfile calls
|
|
353
|
+
# `use_expo_modules_tests!` (tests_only), main pods without test specs are skipped,
|
|
354
|
+
# so registering a companion that depends on a skipped main pod would fail
|
|
355
|
+
# dependency resolution. Skip companions entirely in tests-only mode.
|
|
356
|
+
#
|
|
357
|
+
# Example spm.config.json:
|
|
358
|
+
# "autolinkWhen": {
|
|
359
|
+
# "podfileProperty": "expo.camera.barcode-scanner-enabled",
|
|
360
|
+
# "disabledValue": "false"
|
|
361
|
+
# }
|
|
362
|
+
def register_companion_pods(podfile, target_definition, project_directory, tests_only: false)
|
|
363
|
+
return if tests_only
|
|
364
|
+
|
|
365
|
+
properties = read_podfile_properties(project_directory)
|
|
366
|
+
|
|
367
|
+
pod_lookup_map.each do |pod_name, info|
|
|
368
|
+
condition = info[:autolink_when]
|
|
369
|
+
next unless condition
|
|
370
|
+
next if target_definition.dependencies.any? { |dep| dep.name == pod_name }
|
|
371
|
+
|
|
372
|
+
property = condition['podfileProperty']
|
|
373
|
+
disabled_value = condition['disabledValue']
|
|
374
|
+
next unless property
|
|
375
|
+
|
|
376
|
+
current_value = properties[property]
|
|
377
|
+
# Only skip if the property is explicitly set to the disabled value
|
|
378
|
+
next if current_value == disabled_value
|
|
379
|
+
|
|
380
|
+
podspec_file = File.join(info[:podspec_dir], "#{pod_name}.podspec")
|
|
381
|
+
unless File.exist?(podspec_file)
|
|
382
|
+
Pod::UI.warn "[Expo] Companion pod #{pod_name}: podspec not found at #{podspec_file}"
|
|
383
|
+
next
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
podspec_rel = Pathname.new(podspec_file).relative_path_from(project_directory).to_s
|
|
387
|
+
|
|
388
|
+
# Parse the companion podspec to inspect its dependencies.
|
|
389
|
+
begin
|
|
390
|
+
spec = Pod::Specification.from_file(podspec_file)
|
|
391
|
+
rescue => e
|
|
392
|
+
Pod::UI.warn "[Expo] Companion pod #{pod_name}: failed to parse podspec: #{e.message}"
|
|
393
|
+
next
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
# Skip companion pods whose local dependencies (sibling pods from the same
|
|
397
|
+
# monorepo / node_modules) aren't registered in the Podfile. For example,
|
|
398
|
+
# ExpoCameraBarcodeScanning depends on ExpoCamera — if expo-camera isn't
|
|
399
|
+
# installed in the project, ExpoCamera won't be in the Podfile and CocoaPods
|
|
400
|
+
# would fail with "Unable to find a specification for ExpoCamera".
|
|
401
|
+
registered_pod_names = target_definition.dependencies.map(&:name)
|
|
402
|
+
missing_local_dep = spec.all_dependencies.find do |dep|
|
|
403
|
+
root_spec_name = dep.name.partition('/').first
|
|
404
|
+
pod_lookup_map.key?(root_spec_name) && !registered_pod_names.include?(root_spec_name)
|
|
405
|
+
end
|
|
406
|
+
if missing_local_dep
|
|
407
|
+
Pod::UI.message "[Expo] Skipping companion pod #{pod_name}: dependency #{missing_local_dep.name} is not installed"
|
|
408
|
+
next
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
# Enable modular headers for the companion pod's transitive Objective-C dependencies so
|
|
412
|
+
# the Swift pod can `import` them. Mirrors the logic in autolinking_manager.rb's
|
|
413
|
+
# `use_modular_headers_for_dependencies`.
|
|
414
|
+
spec.all_dependencies.each do |dep|
|
|
415
|
+
root_spec_name = dep.name.partition('/').first
|
|
416
|
+
unless target_definition.build_pod_as_module?(root_spec_name)
|
|
417
|
+
target_definition.set_use_modular_headers_for_pod(root_spec_name, true)
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
if enabled? && has_prebuilt_xcframework?(pod_name)
|
|
422
|
+
Pod::UI.message "— #{pod_name.green} (prebuilt companion, gated by #{property})"
|
|
423
|
+
podfile.pod(pod_name, :podspec => podspec_rel)
|
|
424
|
+
else
|
|
425
|
+
Pod::UI.message "— #{pod_name.green} (companion, gated by #{property})"
|
|
426
|
+
podspec_dir_rel = Pathname.new(info[:podspec_dir]).relative_path_from(project_directory).to_s
|
|
427
|
+
podfile.pod(pod_name, :path => podspec_dir_rel)
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
# Reads Podfile.properties.json from the Podfile's directory (installation root).
|
|
433
|
+
# Returns an empty hash if the file doesn't exist or fails to parse.
|
|
434
|
+
def read_podfile_properties(_project_directory)
|
|
435
|
+
props_path = File.join(Pod::Config.instance.installation_root.to_s, 'Podfile.properties.json')
|
|
436
|
+
return {} unless File.exist?(props_path)
|
|
437
|
+
JSON.parse(File.read(props_path)) rescue {}
|
|
438
|
+
end
|
|
439
|
+
|
|
339
440
|
# ──────────────────────────────────────────────────────────────────────
|
|
340
441
|
# Spec patching (called from sandbox.rb / podspecs)
|
|
341
442
|
# ──────────────────────────────────────────────────────────────────────
|
|
@@ -1235,7 +1336,8 @@ module Expo
|
|
|
1235
1336
|
codegen_name: codegen_name,
|
|
1236
1337
|
product_name: product_name,
|
|
1237
1338
|
targets: targets,
|
|
1238
|
-
spm_dependency_frameworks: spm_dependency_frameworks
|
|
1339
|
+
spm_dependency_frameworks: spm_dependency_frameworks,
|
|
1340
|
+
autolink_when: product['autolinkWhen']
|
|
1239
1341
|
}
|
|
1240
1342
|
end
|
|
1241
1343
|
rescue JSON::ParserError, StandardError => e
|
|
@@ -1305,7 +1407,8 @@ module Expo
|
|
|
1305
1407
|
codegen_name: codegen_name,
|
|
1306
1408
|
product_name: product_name,
|
|
1307
1409
|
targets: targets,
|
|
1308
|
-
spm_dependency_frameworks: spm_dependency_frameworks
|
|
1410
|
+
spm_dependency_frameworks: spm_dependency_frameworks,
|
|
1411
|
+
autolink_when: product['autolinkWhen']
|
|
1309
1412
|
}
|
|
1310
1413
|
end
|
|
1311
1414
|
|
|
@@ -4,7 +4,7 @@ import { PackageRevision, SupportedPlatform } from '../types';
|
|
|
4
4
|
import { scanDependenciesRecursively } from './resolution';
|
|
5
5
|
import { scanDependenciesFromRNProjectConfig } from './rncliLocal';
|
|
6
6
|
import { scanDependenciesInSearchPath } from './scanning';
|
|
7
|
-
import { type ResolutionResult, DependencyResolutionSource } from './types';
|
|
7
|
+
import { type ResolutionResult, DependencyResolution, DependencyResolutionSource } from './types';
|
|
8
8
|
import { filterMapResolutionResult, mergeResolutionResults } from './utils';
|
|
9
9
|
import { resolveExpoModule } from '../autolinking/findModules';
|
|
10
10
|
import { AutolinkingOptions, createAutolinkingOptionsLoader } from '../commands/autolinkingOptions';
|
|
@@ -94,6 +94,19 @@ export function makeCachedDependenciesLinker(params: {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
export async function isNativeModuleAsync(
|
|
98
|
+
resolution: DependencyResolution,
|
|
99
|
+
reactNativeProjectConfig: RNConfigReactNativeProjectConfig | null,
|
|
100
|
+
platform: SupportedPlatform,
|
|
101
|
+
excludeNames: Set<string>
|
|
102
|
+
) {
|
|
103
|
+
const [reactNativeModule, expoModule] = await Promise.all([
|
|
104
|
+
resolveReactNativeModule(resolution, reactNativeProjectConfig, platform, excludeNames),
|
|
105
|
+
resolveExpoModule(resolution, platform, excludeNames),
|
|
106
|
+
]);
|
|
107
|
+
return !!reactNativeModule || !!expoModule;
|
|
108
|
+
}
|
|
109
|
+
|
|
97
110
|
export async function scanDependencyResolutionsForPlatform(
|
|
98
111
|
linker: CachedDependenciesLinker,
|
|
99
112
|
platform: SupportedPlatform,
|
|
@@ -131,16 +144,13 @@ export async function scanDependencyResolutionsForPlatform(
|
|
|
131
144
|
return null;
|
|
132
145
|
}
|
|
133
146
|
} else {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
resolveExpoModule(resolution, platform, opts.excludeNames),
|
|
142
|
-
]);
|
|
143
|
-
if (!reactNativeModule && !expoModule) {
|
|
147
|
+
const isNativeModule = await isNativeModuleAsync(
|
|
148
|
+
resolution,
|
|
149
|
+
reactNativeProjectConfig,
|
|
150
|
+
platform,
|
|
151
|
+
opts.excludeNames
|
|
152
|
+
);
|
|
153
|
+
if (!isNativeModule) {
|
|
144
154
|
return null;
|
|
145
155
|
}
|
|
146
156
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { scanDependenciesRecursively } from './resolution';
|
|
2
|
-
export { scanDependenciesInSearchPath } from './scanning';
|
|
2
|
+
export { scanDependenciesInSearchPath, mockDependencyAtPath } from './scanning';
|
|
3
3
|
export { scanDependenciesFromRNProjectConfig } from './rncliLocal';
|
|
4
4
|
export { filterMapResolutionResult, mergeResolutionResults } from './utils';
|
|
5
5
|
export * from './CachedDependenciesLinker';
|
|
@@ -45,6 +45,21 @@ async function resolveDependency(
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** Create a mock resolution for a local search path dependency at the given path */
|
|
49
|
+
export async function mockDependencyAtPath(originPath: string): Promise<DependencyResolution> {
|
|
50
|
+
const realPath = await maybeRealpath(originPath);
|
|
51
|
+
const packageJson = await loadPackageJson(fastJoin(realPath || originPath, 'package.json'));
|
|
52
|
+
return {
|
|
53
|
+
source: DependencyResolutionSource.SEARCH_PATH,
|
|
54
|
+
name: packageJson?.name || 'local-module', // NOTE: Mock name
|
|
55
|
+
version: packageJson?.version ?? '',
|
|
56
|
+
path: realPath ?? originPath,
|
|
57
|
+
originPath,
|
|
58
|
+
duplicates: null,
|
|
59
|
+
depth: 0,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
48
63
|
interface ResolutionOptions {
|
|
49
64
|
shouldIncludeDependency?(name: string): boolean;
|
|
50
65
|
}
|
package/src/exports.ts
CHANGED
|
@@ -27,6 +27,8 @@ export {
|
|
|
27
27
|
scanExpoModuleResolutionsForPlatform,
|
|
28
28
|
} from './dependencies';
|
|
29
29
|
|
|
30
|
+
export * from './utilities';
|
|
31
|
+
|
|
30
32
|
/** @deprecated */
|
|
31
33
|
export async function mergeLinkingOptionsAsync<Options extends Partial<AutolinkingCommonArguments>>(
|
|
32
34
|
argumentsOptions: Options
|
|
@@ -31,6 +31,25 @@ import {
|
|
|
31
31
|
} from '../dependencies';
|
|
32
32
|
import { checkDependencyWebAsync } from './webResolver';
|
|
33
33
|
|
|
34
|
+
const deepObjectMerge = (target: any, source: any): any => {
|
|
35
|
+
if (
|
|
36
|
+
source !== undefined &&
|
|
37
|
+
typeof target === 'object' &&
|
|
38
|
+
target != null &&
|
|
39
|
+
!Array.isArray(target) &&
|
|
40
|
+
(!target.constructor || target.constructor === Object) &&
|
|
41
|
+
typeof source === 'object' &&
|
|
42
|
+
!Array.isArray(source)
|
|
43
|
+
) {
|
|
44
|
+
target = { ...target };
|
|
45
|
+
for (const key in source) {
|
|
46
|
+
target[key] = deepObjectMerge(target[key], source[key]);
|
|
47
|
+
}
|
|
48
|
+
return target;
|
|
49
|
+
}
|
|
50
|
+
return source !== undefined ? source : target;
|
|
51
|
+
};
|
|
52
|
+
|
|
34
53
|
const isMissingFBReactNativeSpecCodegenOutput = async (reactNativePath: string) => {
|
|
35
54
|
const generatedDir = path.resolve(reactNativePath, 'React/FBReactNativeSpec');
|
|
36
55
|
try {
|
|
@@ -66,17 +85,18 @@ export async function resolveReactNativeModule(
|
|
|
66
85
|
const modulePath = shouldUseOriginPath ? resolution.originPath : resolution.path;
|
|
67
86
|
|
|
68
87
|
const libraryConfig = (await loadConfigAsync(modulePath)) as RNConfigReactNativeLibraryConfig;
|
|
69
|
-
const reactNativeConfig = {
|
|
70
|
-
...libraryConfig?.dependency,
|
|
71
|
-
...projectConfig?.dependencies?.[resolution.name],
|
|
72
|
-
};
|
|
73
|
-
|
|
74
88
|
if (Object.keys(libraryConfig?.platforms ?? {}).length > 0) {
|
|
75
89
|
// Package defines platforms would be a platform host package.
|
|
76
90
|
// The rnc-cli will skip this package.
|
|
77
91
|
return null;
|
|
78
92
|
}
|
|
79
93
|
|
|
94
|
+
let reactNativeConfig = libraryConfig?.dependency ?? {};
|
|
95
|
+
const projectDependencyOverride = projectConfig?.dependencies?.[resolution.name];
|
|
96
|
+
if (projectDependencyOverride != null) {
|
|
97
|
+
reactNativeConfig = deepObjectMerge(reactNativeConfig, projectDependencyOverride);
|
|
98
|
+
}
|
|
99
|
+
|
|
80
100
|
let maybeExpoModuleConfig: ExpoModuleConfig | null | undefined;
|
|
81
101
|
if (!libraryConfig) {
|
|
82
102
|
// NOTE(@kitten): If we don't have an explicit react-native.config.{js,ts} file,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { taskAll } from '../concurrency';
|
|
2
|
+
import {
|
|
3
|
+
mockDependencyAtPath,
|
|
4
|
+
isNativeModuleAsync as isDependencyNativeModuleAsync,
|
|
5
|
+
} from '../dependencies';
|
|
6
|
+
import { SupportedPlatform } from '../types';
|
|
7
|
+
|
|
8
|
+
/** Check if a path is potentially a native module */
|
|
9
|
+
export async function isNativeModuleAsync(maybeModulePath: string) {
|
|
10
|
+
const resolution = await mockDependencyAtPath(maybeModulePath);
|
|
11
|
+
const excludeNames = new Set<string>();
|
|
12
|
+
const isNativeModules = await taskAll(['android', 'apple'] as SupportedPlatform[], (platform) =>
|
|
13
|
+
isDependencyNativeModuleAsync(resolution, null, platform, excludeNames)
|
|
14
|
+
);
|
|
15
|
+
return isNativeModules.some((x) => !!x);
|
|
16
|
+
}
|