UNPKG

expo-modules-autolinking

Version:
51 lines 2.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveExpoModule = resolveExpoModule; exports.findModulesAsync = findModulesAsync; const ExpoModuleConfig_1 = require("../ExpoModuleConfig"); const dependencies_1 = require("../dependencies"); const memoize_1 = require("../memoize"); async function resolveExpoModule(resolution, platform, excludeNames) { if (excludeNames.has(resolution.name)) { return null; } // Workaround for Android Gradle/Prefab issue with special characters in paths. // pnpm creates virtual store paths with '=' characters (e.g., _patch_hash=abc123), // which cause build failures on Android due to Prefab not properly escaping them. // See: https://github.com/google/prefab/issues/187 const shouldUseOriginPath = platform === 'android' && resolution.path.includes('=') && resolution.path.includes('.pnpm'); const modulePath = shouldUseOriginPath ? resolution.originPath : resolution.path; const expoModuleConfig = await (0, ExpoModuleConfig_1.discoverExpoModuleConfigAsync)(modulePath); if (expoModuleConfig && expoModuleConfig.supportsPlatform(platform)) { return { name: resolution.name, path: modulePath, version: resolution.version, config: expoModuleConfig, duplicates: resolution.duplicates?.map((duplicate) => ({ name: duplicate.name, path: duplicate.path, version: duplicate.version, })) ?? [], }; } else { return null; } } /** Searches for modules to link based on given config. */ async function findModulesAsync({ appRoot, autolinkingOptions, }) { const memoizer = (0, memoize_1.createMemoizer)(); const excludeNames = new Set(autolinkingOptions.exclude); // custom native modules should be resolved first so that they can override other modules const searchPaths = autolinkingOptions.nativeModulesDir ? [autolinkingOptions.nativeModulesDir, ...autolinkingOptions.searchPaths] : autolinkingOptions.searchPaths; return memoizer.withMemoizer(async () => { return (0, dependencies_1.filterMapResolutionResult)((0, dependencies_1.mergeResolutionResults)(await Promise.all([ ...searchPaths.map((searchPath) => (0, dependencies_1.scanDependenciesInSearchPath)(searchPath)), (0, dependencies_1.scanDependenciesRecursively)(appRoot), ])), (resolution) => resolveExpoModule(resolution, autolinkingOptions.platform, excludeNames)); }); } //# sourceMappingURL=findModules.js.map