expo-modules-autolinking 2.0.1 → 2.0.2
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 +6 -0
- package/build/reactNativeConfig/reactNativeConfig.d.ts +1 -1
- package/build/reactNativeConfig/reactNativeConfig.js +3 -3
- package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
- package/build/reactNativeConfig/reactNativeConfig.types.d.ts +1 -1
- package/build/reactNativeConfig/reactNativeConfig.types.js.map +1 -1
- package/package.json +2 -2
- package/src/reactNativeConfig/reactNativeConfig.ts +4 -4
- package/src/reactNativeConfig/reactNativeConfig.types.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 2.0.2 — 2024-11-13
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed autolinking when `react-native-config` doesn't specify local dependencies. ([#32841](https://github.com/expo/expo/pull/32841) by [@thespacemanatee](https://github.com/thespacemanatee))
|
|
18
|
+
|
|
13
19
|
## 2.0.1 — 2024-11-13
|
|
14
20
|
|
|
15
21
|
### 💡 Others
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RNConfigCommandOptions, RNConfigDependency, RNConfigReactNativeAppProjectConfig, RNConfigReactNativeProjectConfig, RNConfigResult } from './reactNativeConfig.types';
|
|
2
1
|
import type { SupportedPlatform } from '../types';
|
|
2
|
+
import type { RNConfigCommandOptions, RNConfigDependency, RNConfigReactNativeAppProjectConfig, RNConfigReactNativeProjectConfig, RNConfigResult } from './reactNativeConfig.types';
|
|
3
3
|
/**
|
|
4
4
|
* Create config for react-native core autolinking.
|
|
5
5
|
*/
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.resolveAppProjectConfigAsync = exports.resolveDependencyConfigAsync = exports.findDependencyRootsAsync = exports.createReactNativeConfigAsync = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const utils_1 = require("../autolinking/utils");
|
|
10
|
+
const fileUtils_1 = require("../fileUtils");
|
|
9
11
|
const androidResolver_1 = require("./androidResolver");
|
|
10
12
|
const config_1 = require("./config");
|
|
11
13
|
const iosResolver_1 = require("./iosResolver");
|
|
12
|
-
const utils_1 = require("../autolinking/utils");
|
|
13
|
-
const fileUtils_1 = require("../fileUtils");
|
|
14
14
|
/**
|
|
15
15
|
* Create config for react-native core autolinking.
|
|
16
16
|
*/
|
|
@@ -68,7 +68,7 @@ exports.findDependencyRootsAsync = findDependencyRootsAsync;
|
|
|
68
68
|
* Find local dependencies that specified in the `react-native.config.js` file.
|
|
69
69
|
*/
|
|
70
70
|
function findProjectLocalDependencyRoots(projectConfig) {
|
|
71
|
-
if (!projectConfig) {
|
|
71
|
+
if (!projectConfig?.dependencies) {
|
|
72
72
|
return {};
|
|
73
73
|
}
|
|
74
74
|
const results = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeConfig.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AAExB,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AASpE,gDAA8D;AAC9D,4CAA+C;AAG/C;;GAEG;AACI,KAAK,UAAU,4BAA4B,CAAC,EACjD,QAAQ,EACR,WAAW,EACX,WAAW,GACY;IACvB,MAAM,aAAa,GAAG,MAAM,IAAA,wBAAe,EAAmC,WAAW,CAAC,CAAC;IAC3F,MAAM,eAAe,GAAG;QACtB,GAAG,CAAC,MAAM,wBAAwB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC7D,GAAG,+BAA+B,CAAC,aAAa,CAAC;KAClD,CAAC;IACF,MAAM,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AAI,QAAQ,IAAI,IAAI,EAAE;YACtC,OAAO,EAAE,CAAC;SACX;QACD,MAAM,WAAW,GAAG,MAAM,IAAA,uCAAqB,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE9E,OAAO;YACL,OAAO,EAAE;gBACP,WAAW,EAAE,WAAW,IAAI,EAAE;gBAC9B,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;aAC7C;SACF,CAAC;KACH;IAED,IAAI,QAAQ,KAAK,KAAK,EAAE;QACtB,OAAO;YACL,GAAG,EAAE;gBACH,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;aACzC;SACF,CAAC;KACH;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,oEA6BC","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nimport {\n findGradleAndManifestAsync,\n parsePackageNameAsync,\n resolveDependencyConfigImplAndroidAsync,\n} from './androidResolver';\nimport { loadConfigAsync } from './config';\nimport { resolveDependencyConfigImplIosAsync } from './iosResolver';\nimport type {\n RNConfigCommandOptions,\n RNConfigDependency,\n RNConfigReactNativeAppProjectConfig,\n RNConfigReactNativeLibraryConfig,\n RNConfigReactNativeProjectConfig,\n RNConfigResult,\n} from './reactNativeConfig.types';\nimport { getIsolatedModulesPath } from '../autolinking/utils';\nimport { fileExistsAsync } from '../fileUtils';\nimport type { SupportedPlatform } from '../types';\n\n/**\n * Create config for react-native core autolinking.\n */\nexport async function createReactNativeConfigAsync({\n platform,\n projectRoot,\n searchPaths,\n}: RNConfigCommandOptions): Promise<RNConfigResult> {\n const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(projectRoot);\n const dependencyRoots = {\n ...(await findDependencyRootsAsync(projectRoot, searchPaths)),\n ...findProjectLocalDependencyRoots(projectConfig),\n };\n const reactNativePath = dependencyRoots['react-native'];\n\n const dependencyConfigs = await Promise.all(\n Object.entries(dependencyRoots).map(async ([name, packageRoot]) => {\n const config = await resolveDependencyConfigAsync(platform, name, packageRoot, projectConfig);\n return [name, config];\n })\n );\n const dependencyResults = Object.fromEntries<RNConfigDependency>(\n dependencyConfigs.filter(([, config]) => config != null) as Iterable<\n [string, RNConfigDependency]\n >\n );\n const projectData = await resolveAppProjectConfigAsync(projectRoot, platform);\n return {\n root: projectRoot,\n reactNativePath,\n dependencies: dependencyResults,\n project: projectData,\n };\n}\n\n/**\n * Find all dependencies and their directories from the project.\n */\nexport async function findDependencyRootsAsync(\n projectRoot: string,\n searchPaths: string[]\n): Promise<Record<string, string>> {\n const packageJson = JSON.parse(await fs.readFile(path.join(projectRoot, 'package.json'), 'utf8'));\n const dependencies = [\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.devDependencies ?? {}),\n ];\n\n const results: Record<string, string> = {};\n // `searchPathSet` can be mutated to discover all \"isolated modules groups\", when using isolated modules\n const searchPathSet = new Set(searchPaths);\n\n for (const name of dependencies) {\n for (const searchPath of searchPathSet) {\n const packageConfigPath = path.resolve(searchPath, name, 'package.json');\n if (await fileExistsAsync(packageConfigPath)) {\n const packageRoot = path.dirname(packageConfigPath);\n results[name] = packageRoot;\n\n const maybeIsolatedModulesPath = getIsolatedModulesPath(packageRoot, name);\n if (maybeIsolatedModulesPath) {\n searchPathSet.add(maybeIsolatedModulesPath);\n }\n break;\n }\n }\n }\n\n return results;\n}\n\n/**\n * Find local dependencies that specified in the `react-native.config.js` file.\n */\nfunction findProjectLocalDependencyRoots(\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Record<string, string> {\n if (!projectConfig) {\n return {};\n }\n const results: Record<string, string> = {};\n for (const [name, config] of Object.entries(projectConfig.dependencies)) {\n if (typeof config.root === 'string') {\n results[name] = config.root;\n }\n }\n return results;\n}\n\nexport async function resolveDependencyConfigAsync(\n platform: SupportedPlatform,\n name: string,\n packageRoot: string,\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Promise<RNConfigDependency | null> {\n const libraryConfig = await loadConfigAsync<RNConfigReactNativeLibraryConfig>(packageRoot);\n const reactNativeConfig = {\n ...libraryConfig?.dependency,\n ...projectConfig?.dependencies?.[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 if (name === 'react-native') {\n // Starting from version 0.76, the `react-native` package only defines platforms\n // when @react-native-community/cli-platform-android/ios is installed.\n // Therefore, we need to manually filter it out.\n return null;\n }\n\n let platformData = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n packageRoot,\n reactNativeConfig.platforms?.android\n );\n } else if (platform === 'ios') {\n platformData = await resolveDependencyConfigImplIosAsync(\n packageRoot,\n reactNativeConfig.platforms?.ios\n );\n }\n if (!platformData) {\n return null;\n }\n return {\n root: packageRoot,\n name,\n platforms: {\n [platform]: platformData,\n },\n };\n}\n\nexport async function resolveAppProjectConfigAsync(\n projectRoot: string,\n platform: SupportedPlatform\n): Promise<RNConfigReactNativeAppProjectConfig> {\n if (platform === 'android') {\n const androidDir = path.join(projectRoot, 'android');\n const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });\n if (gradle == null || manifest == null) {\n return {};\n }\n const packageName = await parsePackageNameAsync(androidDir, manifest, gradle);\n\n return {\n android: {\n packageName: packageName ?? '',\n sourceDir: path.join(projectRoot, 'android'),\n },\n };\n }\n\n if (platform === 'ios') {\n return {\n ios: {\n 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":";;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AAExB,gDAA8D;AAC9D,4CAA+C;AAE/C,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AAUpE;;GAEG;AACI,KAAK,UAAU,4BAA4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AA2B;IAE3B,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACrD,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;YACtC,OAAO,EAAE,CAAC;SACX;QACD,MAAM,WAAW,GAAG,MAAM,IAAA,uCAAqB,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE9E,OAAO;YACL,OAAO,EAAE;gBACP,WAAW,EAAE,WAAW,IAAI,EAAE;gBAC9B,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;aAC7C;SACF,CAAC;KACH;IAED,IAAI,QAAQ,KAAK,KAAK,EAAE;QACtB,OAAO;YACL,GAAG,EAAE;gBACH,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;aACzC;SACF,CAAC;KACH;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,oEA6BC","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nimport { getIsolatedModulesPath } from '../autolinking/utils';\nimport { fileExistsAsync } from '../fileUtils';\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 RNConfigCommandOptions,\n RNConfigDependency,\n RNConfigReactNativeAppProjectConfig,\n RNConfigReactNativeLibraryConfig,\n RNConfigReactNativeProjectConfig,\n RNConfigResult,\n} from './reactNativeConfig.types';\n\n/**\n * Create config for react-native core autolinking.\n */\nexport async function createReactNativeConfigAsync({\n platform,\n projectRoot,\n searchPaths,\n}: RNConfigCommandOptions): Promise<RNConfigResult> {\n const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(projectRoot);\n const dependencyRoots = {\n ...(await findDependencyRootsAsync(projectRoot, searchPaths)),\n ...findProjectLocalDependencyRoots(projectConfig),\n };\n const reactNativePath = dependencyRoots['react-native'];\n\n const dependencyConfigs = await Promise.all(\n Object.entries(dependencyRoots).map(async ([name, packageRoot]) => {\n const config = await resolveDependencyConfigAsync(platform, name, packageRoot, projectConfig);\n return [name, config];\n })\n );\n const dependencyResults = Object.fromEntries<RNConfigDependency>(\n dependencyConfigs.filter(([, config]) => config != null) as Iterable<\n [string, RNConfigDependency]\n >\n );\n const projectData = await resolveAppProjectConfigAsync(projectRoot, platform);\n return {\n root: projectRoot,\n reactNativePath,\n dependencies: dependencyResults,\n project: projectData,\n };\n}\n\n/**\n * Find all dependencies and their directories from the project.\n */\nexport async function findDependencyRootsAsync(\n projectRoot: string,\n searchPaths: string[]\n): Promise<Record<string, string>> {\n const packageJson = JSON.parse(await fs.readFile(path.join(projectRoot, 'package.json'), 'utf8'));\n const dependencies = [\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.devDependencies ?? {}),\n ];\n\n const results: Record<string, string> = {};\n // `searchPathSet` can be mutated to discover all \"isolated modules groups\", when using isolated modules\n const searchPathSet = new Set(searchPaths);\n\n for (const name of dependencies) {\n for (const searchPath of searchPathSet) {\n const packageConfigPath = path.resolve(searchPath, name, 'package.json');\n if (await fileExistsAsync(packageConfigPath)) {\n const packageRoot = path.dirname(packageConfigPath);\n results[name] = packageRoot;\n\n const maybeIsolatedModulesPath = getIsolatedModulesPath(packageRoot, name);\n if (maybeIsolatedModulesPath) {\n searchPathSet.add(maybeIsolatedModulesPath);\n }\n break;\n }\n }\n }\n\n return results;\n}\n\n/**\n * Find local dependencies that specified in the `react-native.config.js` file.\n */\nfunction findProjectLocalDependencyRoots(\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Record<string, string> {\n if (!projectConfig?.dependencies) {\n return {};\n }\n const results: Record<string, string> = {};\n for (const [name, config] of Object.entries(projectConfig.dependencies)) {\n if (typeof config.root === 'string') {\n results[name] = config.root;\n }\n }\n return results;\n}\n\nexport async function resolveDependencyConfigAsync(\n platform: SupportedPlatform,\n name: string,\n packageRoot: string,\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Promise<RNConfigDependency | null> {\n const libraryConfig = await loadConfigAsync<RNConfigReactNativeLibraryConfig>(packageRoot);\n const reactNativeConfig = {\n ...libraryConfig?.dependency,\n ...projectConfig?.dependencies?.[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 if (name === 'react-native') {\n // Starting from version 0.76, the `react-native` package only defines platforms\n // when @react-native-community/cli-platform-android/ios is installed.\n // Therefore, we need to manually filter it out.\n return null;\n }\n\n let platformData = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n packageRoot,\n reactNativeConfig.platforms?.android\n );\n } else if (platform === 'ios') {\n platformData = await resolveDependencyConfigImplIosAsync(\n packageRoot,\n reactNativeConfig.platforms?.ios\n );\n }\n if (!platformData) {\n return null;\n }\n return {\n root: packageRoot,\n name,\n platforms: {\n [platform]: platformData,\n },\n };\n}\n\nexport async function resolveAppProjectConfigAsync(\n projectRoot: string,\n platform: SupportedPlatform\n): Promise<RNConfigReactNativeAppProjectConfig> {\n if (platform === 'android') {\n const androidDir = path.join(projectRoot, 'android');\n const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });\n if (gradle == null || manifest == null) {\n return {};\n }\n const packageName = await parsePackageNameAsync(androidDir, manifest, gradle);\n\n return {\n android: {\n packageName: packageName ?? '',\n sourceDir: path.join(projectRoot, 'android'),\n },\n };\n }\n\n if (platform === 'ios') {\n return {\n ios: {\n sourceDir: path.join(projectRoot, 'ios'),\n },\n };\n }\n\n return {};\n}\n"]}
|
|
@@ -69,7 +69,7 @@ interface RNConfigReactNativePlatformsConfig {
|
|
|
69
69
|
* The `react-native.config.js` config from projectRoot.
|
|
70
70
|
*/
|
|
71
71
|
export interface RNConfigReactNativeProjectConfig {
|
|
72
|
-
dependencies
|
|
72
|
+
dependencies?: Record<string, RNConfigReactNativePlatformsConfig>;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* The `react-native.config.js` config from library packageRoot.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeConfig.types.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SupportedPlatform } from '../types';\n\n/**\n * Options for 'react-native-config' command.\n */\nexport interface RNConfigCommandOptions {\n platform: SupportedPlatform;\n projectRoot: string;\n searchPaths: string[];\n}\n\n/**\n * Dependency configuration for Android platform.\n */\nexport interface RNConfigDependencyAndroid {\n sourceDir: string;\n packageImportPath: string;\n packageInstance: string;\n dependencyConfiguration?: string;\n buildTypes: string[];\n libraryName?: string | null;\n componentDescriptors?: string[] | null;\n cmakeListsPath?: string | null;\n cxxModuleCMakeListsModuleName?: string | null;\n cxxModuleCMakeListsPath?: string | null;\n cxxModuleHeaderName?: string | null;\n}\n\n/**\n * Dependency configuration for iOS platform.\n */\nexport interface RNConfigDependencyIos {\n podspecPath: string;\n version: string;\n configurations: string[];\n scriptPhases: any[];\n}\n\n/**\n * Dependency configuration.\n */\nexport interface RNConfigDependency {\n root: string;\n name: string;\n platforms: {\n android?: RNConfigDependencyAndroid;\n ios?: RNConfigDependencyIos;\n };\n}\n\n/**\n * Result of 'react-native-config' command.\n */\nexport interface RNConfigResult {\n root: string;\n reactNativePath: string;\n dependencies: Record<string, RNConfigDependency>;\n project: {\n ios?: {\n sourceDir: string;\n };\n };\n}\n\nexport type RNConfigReactNativePlatformsConfigAndroid = any;\nexport type RNConfigReactNativePlatformsConfigIos = any;\n\ninterface RNConfigReactNativePlatformsConfig {\n root?: string;\n platforms?: {\n android?: RNConfigReactNativePlatformsConfigAndroid;\n ios?: RNConfigReactNativePlatformsConfigIos;\n };\n}\n\n/**\n * The `react-native.config.js` config from projectRoot.\n */\nexport interface RNConfigReactNativeProjectConfig {\n dependencies
|
|
1
|
+
{"version":3,"file":"reactNativeConfig.types.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SupportedPlatform } from '../types';\n\n/**\n * Options for 'react-native-config' command.\n */\nexport interface RNConfigCommandOptions {\n platform: SupportedPlatform;\n projectRoot: string;\n searchPaths: string[];\n}\n\n/**\n * Dependency configuration for Android platform.\n */\nexport interface RNConfigDependencyAndroid {\n sourceDir: string;\n packageImportPath: string;\n packageInstance: string;\n dependencyConfiguration?: string;\n buildTypes: string[];\n libraryName?: string | null;\n componentDescriptors?: string[] | null;\n cmakeListsPath?: string | null;\n cxxModuleCMakeListsModuleName?: string | null;\n cxxModuleCMakeListsPath?: string | null;\n cxxModuleHeaderName?: string | null;\n}\n\n/**\n * Dependency configuration for iOS platform.\n */\nexport interface RNConfigDependencyIos {\n podspecPath: string;\n version: string;\n configurations: string[];\n scriptPhases: any[];\n}\n\n/**\n * Dependency configuration.\n */\nexport interface RNConfigDependency {\n root: string;\n name: string;\n platforms: {\n android?: RNConfigDependencyAndroid;\n ios?: RNConfigDependencyIos;\n };\n}\n\n/**\n * Result of 'react-native-config' command.\n */\nexport interface RNConfigResult {\n root: string;\n reactNativePath: string;\n dependencies: Record<string, RNConfigDependency>;\n project: {\n ios?: {\n sourceDir: string;\n };\n };\n}\n\nexport type RNConfigReactNativePlatformsConfigAndroid = any;\nexport type RNConfigReactNativePlatformsConfigIos = any;\n\ninterface RNConfigReactNativePlatformsConfig {\n root?: string;\n platforms?: {\n android?: RNConfigReactNativePlatformsConfigAndroid;\n ios?: RNConfigReactNativePlatformsConfigIos;\n };\n}\n\n/**\n * The `react-native.config.js` config from projectRoot.\n */\nexport interface RNConfigReactNativeProjectConfig {\n dependencies?: Record<string, RNConfigReactNativePlatformsConfig>;\n}\n\n/**\n * The `react-native.config.js` config from library packageRoot.\n */\nexport interface RNConfigReactNativeLibraryConfig {\n dependency?: RNConfigReactNativePlatformsConfig;\n platforms?: any;\n}\n\nexport type RNConfigReactNativeConfig =\n | RNConfigReactNativeProjectConfig\n | RNConfigReactNativeLibraryConfig;\n\n/**\n * The `project` config represents the app project configuration.\n */\nexport interface RNConfigReactNativeAppProjectConfig {\n android?: {\n sourceDir: string;\n packageName: string;\n };\n ios?: {\n sourceDir: string;\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Scripts that autolink Expo modules.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"require-from-string": "^2.0.2",
|
|
49
49
|
"resolve-from": "^5.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "c4999f5aa407155a170830a0fa17e3e3ca1fcbee"
|
|
52
52
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
|
+
import { getIsolatedModulesPath } from '../autolinking/utils';
|
|
5
|
+
import { fileExistsAsync } from '../fileUtils';
|
|
6
|
+
import type { SupportedPlatform } from '../types';
|
|
4
7
|
import {
|
|
5
8
|
findGradleAndManifestAsync,
|
|
6
9
|
parsePackageNameAsync,
|
|
@@ -16,9 +19,6 @@ import type {
|
|
|
16
19
|
RNConfigReactNativeProjectConfig,
|
|
17
20
|
RNConfigResult,
|
|
18
21
|
} from './reactNativeConfig.types';
|
|
19
|
-
import { getIsolatedModulesPath } from '../autolinking/utils';
|
|
20
|
-
import { fileExistsAsync } from '../fileUtils';
|
|
21
|
-
import type { SupportedPlatform } from '../types';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Create config for react-native core autolinking.
|
|
@@ -97,7 +97,7 @@ export async function findDependencyRootsAsync(
|
|
|
97
97
|
function findProjectLocalDependencyRoots(
|
|
98
98
|
projectConfig: RNConfigReactNativeProjectConfig | null
|
|
99
99
|
): Record<string, string> {
|
|
100
|
-
if (!projectConfig) {
|
|
100
|
+
if (!projectConfig?.dependencies) {
|
|
101
101
|
return {};
|
|
102
102
|
}
|
|
103
103
|
const results: Record<string, string> = {};
|
|
@@ -77,7 +77,7 @@ interface RNConfigReactNativePlatformsConfig {
|
|
|
77
77
|
* The `react-native.config.js` config from projectRoot.
|
|
78
78
|
*/
|
|
79
79
|
export interface RNConfigReactNativeProjectConfig {
|
|
80
|
-
dependencies
|
|
80
|
+
dependencies?: Record<string, RNConfigReactNativePlatformsConfig>;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|