expo-modules-autolinking 3.0.6 → 3.0.8

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 CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 3.0.8 — 2025-09-08
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [Android] Fix `platformOptions` not being correctly assigned. ([#39445](https://github.com/expo/expo/pull/39445) by [@alanjhughes](https://github.com/alanjhughes))
18
+
19
+ ## 3.0.7 — 2025-09-04
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 3.0.6 — 2025-09-02
14
24
 
15
25
  _This version does not introduce any user-facing changes._
@@ -29,7 +29,7 @@ tasks.withType<KotlinCompile> {
29
29
  }
30
30
 
31
31
  group = "expo.modules"
32
- version "1.0"
32
+ version = "1.0"
33
33
 
34
34
  tasks.withType<Test>().configureEach {
35
35
  testLogging {
@@ -44,9 +44,10 @@ const parsePackageJsonOptions = (packageJson, appRoot, platform) => {
44
44
  const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;
45
45
  let platformOptions = null;
46
46
  if (platform) {
47
- autolinkingOptions && isJSONObject(autolinkingOptions[platform])
48
- ? autolinkingOptions[platform]
49
- : null;
47
+ platformOptions =
48
+ autolinkingOptions && isJSONObject(autolinkingOptions[platform])
49
+ ? autolinkingOptions[platform]
50
+ : null;
50
51
  if (!platformOptions && platform === 'apple') {
51
52
  // NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should
52
53
  // be the base option for other apple platforms, but changing this now is a breaking change
@@ -1 +1 @@
1
- {"version":3,"file":"autolinkingOptions.js","sourceRoot":"","sources":["../../src/commands/autolinkingOptions.ts"],"names":[],"mappings":";;;;;;AAwIA,oEAmBC;AAoDD,wEAyCC;AAvPD,sDAA6B;AAC7B,4CAAoB;AACpB,gDAAwB;AAmCxB,MAAM,YAAY,GAAG,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O,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;YACxF,CAAC;YAED,OAAO;gBACL,GAAG,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC;gBAChD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,2BAA2B,GAAG,CAClC,OAAoC,EACpC,OAAe,EACK,EAAE;IACtB,OAAO;QACL,gCAAgC,EAAE,OAAO,CAAC,gCAAgC,IAAI,KAAK;QACnF,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YACxC,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;YAC/D,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;QACpD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import commander from 'commander';\nimport findUp from 'find-up';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { SupportedPlatform } from '../types';\n\nexport interface AutolinkingOptions {\n /** Only scan direct \"dependencies\" of a project for React Native modules, rather than including transitive dependencies.\n * @remarks\n * Before SDK 54, React Native modules would only be linked if they were listed as dependencies\n * of a project. However, in SDK 54+ transitive React Native modules dependencies are also\n * auto-linked, unless this flag is enabled.\n * @defaultValue `false`\n */\n legacy_shallowReactNativeLinking: boolean;\n /** Extra modules directories to search for native modules.\n * @defaultValue `[]`\n */\n searchPaths: string[];\n /** Local native modules directory to add to autolinking.\n * @defaultValue `\"./modules\"`\n */\n nativeModulesDir: string | null;\n /** Native modules to exclude from autolinking by name.\n * @defaultValue `[]`\n */\n exclude: string[];\n /** A list of package names to opt out of prebuilt Expo modules (Android-only)\n * @defaultValue `[]`\n */\n buildFromSource?: string[];\n /** CocoaPods flags to pass to each autolinked pod (Apple/iOS-only)\n * @defaultValue `[]`\n */\n flags?: Record<string, any>;\n}\n\nconst isJSONObject = (x: unknown): x is Record<string, unknown> =>\n x != null && typeof x === 'object';\n\nconst resolvePathMaybe = (target: unknown, basePath: string): string | null => {\n if (typeof target !== 'string') {\n return null;\n }\n let resolved = path.resolve(basePath, target);\n if (fs.existsSync(resolved)) {\n return resolved;\n } else if ((resolved = path.resolve(target)) && fs.existsSync(target)) {\n // TODO(@kitten): This is here for legacy support. However, this *will* be inconsistent\n // This relies on the current working directory, and hence, can behave differently depending\n // on where the command was invoked.\n return target;\n } else {\n return null;\n }\n};\n\nexport const filterMapSearchPaths = (\n searchPaths: unknown,\n basePath: string\n): string[] | undefined => {\n if (Array.isArray(searchPaths)) {\n return searchPaths\n .map((searchPath) => resolvePathMaybe(searchPath, basePath))\n .filter((searchPath) => searchPath != null);\n } else {\n return undefined;\n }\n};\n\nconst parsePackageJsonOptions = (\n packageJson: Record<string, unknown>,\n appRoot: string,\n platform: SupportedPlatform | null | undefined\n): Partial<AutolinkingOptions> => {\n const expo = isJSONObject(packageJson.expo) ? packageJson.expo : null;\n const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;\n let platformOptions: Record<string, unknown> | null = null;\n if (platform) {\n autolinkingOptions && isJSONObject(autolinkingOptions[platform])\n ? autolinkingOptions[platform]\n : null;\n if (!platformOptions && platform === 'apple') {\n // NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should\n // be the base option for other apple platforms, but changing this now is a breaking change\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions.ios) ? autolinkingOptions.ios : null;\n }\n }\n const mergedOptions = { ...autolinkingOptions, ...platformOptions };\n const outputOptions: Partial<AutolinkingOptions> = {};\n // legacy_shallowReactNativeLinking\n if (mergedOptions.legacy_shallowReactNativeLinking != null) {\n outputOptions.legacy_shallowReactNativeLinking =\n !!mergedOptions.legacy_shallowReactNativeLinking;\n }\n // searchPaths\n if (typeof mergedOptions.searchPaths === 'string' || Array.isArray(mergedOptions.searchPaths)) {\n const rawSearchPaths =\n typeof mergedOptions.searchPaths === 'string'\n ? [mergedOptions.searchPaths]\n : mergedOptions.searchPaths;\n outputOptions.searchPaths = filterMapSearchPaths(rawSearchPaths, appRoot);\n }\n // nativeModulesDir\n if (typeof mergedOptions.nativeModulesDir === 'string') {\n outputOptions.nativeModulesDir = resolvePathMaybe(mergedOptions.nativeModulesDir, appRoot);\n }\n // exclude\n if (Array.isArray(mergedOptions.exclude)) {\n outputOptions.exclude = mergedOptions.exclude.filter((x) => typeof x === 'string');\n }\n // buildFromSource\n if (Array.isArray(mergedOptions.buildFromSource)) {\n outputOptions.buildFromSource = mergedOptions.buildFromSource.filter(\n (x) => typeof x === 'string'\n );\n }\n // flags\n if (isJSONObject(mergedOptions.flags)) {\n outputOptions.flags = { ...mergedOptions.flags };\n }\n return outputOptions;\n};\n\n/** Common commandline arguments for autolinking commands (Not to be confused with `AutolinkingOptions` */\nexport interface AutolinkingCommonArguments {\n projectRoot?: string | null;\n // NOTE(@kitten): These are added to other `searchPaths` entries\n searchPaths?: string[] | null;\n // NOTE(@kitten): These are added to other `exclude` entries\n exclude?: string[] | null;\n platform?: SupportedPlatform | null;\n}\n\nexport function registerAutolinkingArguments(command: commander.Command): commander.Command {\n return command\n .option<string[] | null>(\n '-e, --exclude <exclude...>',\n 'Package names to exclude when looking up for modules.',\n (value, previous) => (previous ?? []).concat(value)\n )\n .option(\n '-p, --platform [platform]',\n 'The platform that the resulting modules must support. Available options: \"apple\", \"android\"',\n 'apple'\n )\n .option(\n // NOTE(@kitten): For backwards-compatibility, this is still called `project-root`, but it\n // really is a replacement path for the current working directory. Henceforth called `commandRoot`\n '--project-root <projectRoot>',\n 'The path to the root of the project. Defaults to current working directory',\n process.cwd()\n );\n}\n\ninterface ArgumentsAutolinkingOptions {\n /** The root directory that will be considered the base path for all other target paths */\n commandRoot: string;\n /** The platform to autolink against. If not passed or unknown, no specific autolinking search logic will be applied */\n platform?: SupportedPlatform;\n /** Added search paths to search for native modules (Usually passed as CLI rest argument. */\n extraSearchPaths?: string[];\n /** Added native module names to exclude from autolined native modules (Usually passed as CLI argument) */\n extraExclude?: string[];\n}\n\nconst parseExtraArgumentsOptions = (\n args: AutolinkingCommonArguments\n): ArgumentsAutolinkingOptions => {\n const cwd = process.cwd();\n const platform = args.platform || undefined;\n const commandRoot = resolvePathMaybe(args.projectRoot, cwd) || cwd;\n const extraSearchPaths = filterMapSearchPaths(args.searchPaths, commandRoot);\n const extraExclude = args.exclude?.filter((name) => typeof name === 'string');\n return {\n platform,\n commandRoot,\n extraSearchPaths,\n extraExclude,\n };\n};\n\nconst findPackageJsonPathAsync = async (commandRoot: string | null): Promise<string> => {\n const cwd = process.cwd();\n const result = await findUp('package.json', { cwd: commandRoot || cwd });\n if (!result) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${commandRoot || cwd}\"`);\n }\n return result;\n};\n\nconst loadPackageJSONAsync = async (packageJsonPath: string): Promise<Record<string, unknown>> => {\n const packageJsonText = await fs.promises.readFile(packageJsonPath, 'utf8');\n return JSON.parse(packageJsonText);\n};\n\nexport interface LinkingOptionsLoader {\n getCommandRoot(): string;\n getAppRoot(): Promise<string>;\n getPlatformOptions<T extends SupportedPlatform | undefined>(\n platform: T\n ): Promise<AutolinkingOptions & { platform: T }>;\n getPlatformOptions(): Promise<AutolinkingOptions>;\n}\n\nexport function createAutolinkingOptionsLoader(\n argumentsOptions?: AutolinkingCommonArguments\n): LinkingOptionsLoader {\n const extraArgumentsOptions = parseExtraArgumentsOptions(argumentsOptions ?? {});\n const { commandRoot } = extraArgumentsOptions;\n\n let _packageJsonPath$: Promise<string> | undefined;\n const getPackageJsonPath = () => {\n return _packageJsonPath$ || (_packageJsonPath$ = findPackageJsonPathAsync(commandRoot));\n };\n\n let _packageJson$: Promise<Record<string, unknown>> | undefined;\n const getPackageJson = async () =>\n _packageJson$ || (_packageJson$ = loadPackageJSONAsync(await getPackageJsonPath()));\n\n const getAppRoot = async () => path.dirname(await getPackageJsonPath());\n\n return {\n getCommandRoot: () => commandRoot,\n getAppRoot,\n async getPlatformOptions(platform = extraArgumentsOptions.platform) {\n const packageJson = await getPackageJson();\n const appRoot = await getAppRoot();\n const options = parsePackageJsonOptions(packageJson, appRoot, platform);\n\n if (extraArgumentsOptions.extraSearchPaths) {\n options.searchPaths = [\n ...extraArgumentsOptions.extraSearchPaths,\n ...(options.searchPaths ?? []),\n ];\n }\n if (extraArgumentsOptions.extraExclude) {\n options.exclude = [...(options.exclude ?? []), ...extraArgumentsOptions.extraExclude];\n }\n\n return {\n ...normalizeAutolinkingOptions(options, appRoot),\n platform,\n };\n },\n };\n}\n\nconst normalizeAutolinkingOptions = (\n options: Partial<AutolinkingOptions>,\n appRoot: string\n): AutolinkingOptions => {\n return {\n legacy_shallowReactNativeLinking: options.legacy_shallowReactNativeLinking ?? false,\n searchPaths: options.searchPaths ?? [],\n nativeModulesDir: options.nativeModulesDir\n ? (resolvePathMaybe(options.nativeModulesDir, appRoot) ?? null)\n : (resolvePathMaybe('./modules', appRoot) ?? null),\n exclude: options.exclude ?? [],\n buildFromSource: options.buildFromSource,\n flags: options.flags,\n };\n};\n"]}
1
+ {"version":3,"file":"autolinkingOptions.js","sourceRoot":"","sources":["../../src/commands/autolinkingOptions.ts"],"names":[],"mappings":";;;;;;AAyIA,oEAmBC;AAoDD,wEAyCC;AAxPD,sDAA6B;AAC7B,4CAAoB;AACpB,gDAAwB;AAmCxB,MAAM,YAAY,GAAG,CAAC,CAAU,EAAgC,EAAE,CAChE,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAE,QAAgB,EAAiB,EAAE;IA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,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC;gBAChD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,2BAA2B,GAAG,CAClC,OAAoC,EACpC,OAAe,EACK,EAAE;IACtB,OAAO;QACL,gCAAgC,EAAE,OAAO,CAAC,gCAAgC,IAAI,KAAK;QACnF,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YACxC,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;YAC/D,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;QACpD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import commander from 'commander';\nimport findUp from 'find-up';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { SupportedPlatform } from '../types';\n\nexport interface AutolinkingOptions {\n /** Only scan direct \"dependencies\" of a project for React Native modules, rather than including transitive dependencies.\n * @remarks\n * Before SDK 54, React Native modules would only be linked if they were listed as dependencies\n * of a project. However, in SDK 54+ transitive React Native modules dependencies are also\n * auto-linked, unless this flag is enabled.\n * @defaultValue `false`\n */\n legacy_shallowReactNativeLinking: boolean;\n /** Extra modules directories to search for native modules.\n * @defaultValue `[]`\n */\n searchPaths: string[];\n /** Local native modules directory to add to autolinking.\n * @defaultValue `\"./modules\"`\n */\n nativeModulesDir: string | null;\n /** Native modules to exclude from autolinking by name.\n * @defaultValue `[]`\n */\n exclude: string[];\n /** A list of package names to opt out of prebuilt Expo modules (Android-only)\n * @defaultValue `[]`\n */\n buildFromSource?: string[];\n /** CocoaPods flags to pass to each autolinked pod (Apple/iOS-only)\n * @defaultValue `[]`\n */\n flags?: Record<string, any>;\n}\n\nconst isJSONObject = (x: unknown): x is Record<string, unknown> =>\n x != null && typeof x === 'object';\n\nconst resolvePathMaybe = (target: unknown, basePath: string): string | null => {\n if (typeof target !== 'string') {\n return null;\n }\n let resolved = path.resolve(basePath, target);\n if (fs.existsSync(resolved)) {\n return resolved;\n } else if ((resolved = path.resolve(target)) && fs.existsSync(target)) {\n // TODO(@kitten): This is here for legacy support. However, this *will* be inconsistent\n // This relies on the current working directory, and hence, can behave differently depending\n // on where the command was invoked.\n return target;\n } else {\n return null;\n }\n};\n\nexport const filterMapSearchPaths = (\n searchPaths: unknown,\n basePath: string\n): string[] | undefined => {\n if (Array.isArray(searchPaths)) {\n return searchPaths\n .map((searchPath) => resolvePathMaybe(searchPath, basePath))\n .filter((searchPath) => searchPath != null);\n } else {\n return undefined;\n }\n};\n\nconst parsePackageJsonOptions = (\n packageJson: Record<string, unknown>,\n appRoot: string,\n platform: SupportedPlatform | null | undefined\n): Partial<AutolinkingOptions> => {\n const expo = isJSONObject(packageJson.expo) ? packageJson.expo : null;\n const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;\n let platformOptions: Record<string, unknown> | null = null;\n if (platform) {\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions[platform])\n ? autolinkingOptions[platform]\n : null;\n if (!platformOptions && platform === 'apple') {\n // NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should\n // be the base option for other apple platforms, but changing this now is a breaking change\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions.ios) ? autolinkingOptions.ios : null;\n }\n }\n const mergedOptions = { ...autolinkingOptions, ...platformOptions };\n const outputOptions: Partial<AutolinkingOptions> = {};\n // legacy_shallowReactNativeLinking\n if (mergedOptions.legacy_shallowReactNativeLinking != null) {\n outputOptions.legacy_shallowReactNativeLinking =\n !!mergedOptions.legacy_shallowReactNativeLinking;\n }\n // searchPaths\n if (typeof mergedOptions.searchPaths === 'string' || Array.isArray(mergedOptions.searchPaths)) {\n const rawSearchPaths =\n typeof mergedOptions.searchPaths === 'string'\n ? [mergedOptions.searchPaths]\n : mergedOptions.searchPaths;\n outputOptions.searchPaths = filterMapSearchPaths(rawSearchPaths, appRoot);\n }\n // nativeModulesDir\n if (typeof mergedOptions.nativeModulesDir === 'string') {\n outputOptions.nativeModulesDir = resolvePathMaybe(mergedOptions.nativeModulesDir, appRoot);\n }\n // exclude\n if (Array.isArray(mergedOptions.exclude)) {\n outputOptions.exclude = mergedOptions.exclude.filter((x) => typeof x === 'string');\n }\n // buildFromSource\n if (Array.isArray(mergedOptions.buildFromSource)) {\n outputOptions.buildFromSource = mergedOptions.buildFromSource.filter(\n (x) => typeof x === 'string'\n );\n }\n // flags\n if (isJSONObject(mergedOptions.flags)) {\n outputOptions.flags = { ...mergedOptions.flags };\n }\n return outputOptions;\n};\n\n/** Common commandline arguments for autolinking commands (Not to be confused with `AutolinkingOptions` */\nexport interface AutolinkingCommonArguments {\n projectRoot?: string | null;\n // NOTE(@kitten): These are added to other `searchPaths` entries\n searchPaths?: string[] | null;\n // NOTE(@kitten): These are added to other `exclude` entries\n exclude?: string[] | null;\n platform?: SupportedPlatform | null;\n}\n\nexport function registerAutolinkingArguments(command: commander.Command): commander.Command {\n return command\n .option<string[] | null>(\n '-e, --exclude <exclude...>',\n 'Package names to exclude when looking up for modules.',\n (value, previous) => (previous ?? []).concat(value)\n )\n .option(\n '-p, --platform [platform]',\n 'The platform that the resulting modules must support. Available options: \"apple\", \"android\"',\n 'apple'\n )\n .option(\n // NOTE(@kitten): For backwards-compatibility, this is still called `project-root`, but it\n // really is a replacement path for the current working directory. Henceforth called `commandRoot`\n '--project-root <projectRoot>',\n 'The path to the root of the project. Defaults to current working directory',\n process.cwd()\n );\n}\n\ninterface ArgumentsAutolinkingOptions {\n /** The root directory that will be considered the base path for all other target paths */\n commandRoot: string;\n /** The platform to autolink against. If not passed or unknown, no specific autolinking search logic will be applied */\n platform?: SupportedPlatform;\n /** Added search paths to search for native modules (Usually passed as CLI rest argument. */\n extraSearchPaths?: string[];\n /** Added native module names to exclude from autolined native modules (Usually passed as CLI argument) */\n extraExclude?: string[];\n}\n\nconst parseExtraArgumentsOptions = (\n args: AutolinkingCommonArguments\n): ArgumentsAutolinkingOptions => {\n const cwd = process.cwd();\n const platform = args.platform || undefined;\n const commandRoot = resolvePathMaybe(args.projectRoot, cwd) || cwd;\n const extraSearchPaths = filterMapSearchPaths(args.searchPaths, commandRoot);\n const extraExclude = args.exclude?.filter((name) => typeof name === 'string');\n return {\n platform,\n commandRoot,\n extraSearchPaths,\n extraExclude,\n };\n};\n\nconst findPackageJsonPathAsync = async (commandRoot: string | null): Promise<string> => {\n const cwd = process.cwd();\n const result = await findUp('package.json', { cwd: commandRoot || cwd });\n if (!result) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${commandRoot || cwd}\"`);\n }\n return result;\n};\n\nconst loadPackageJSONAsync = async (packageJsonPath: string): Promise<Record<string, unknown>> => {\n const packageJsonText = await fs.promises.readFile(packageJsonPath, 'utf8');\n return JSON.parse(packageJsonText);\n};\n\nexport interface LinkingOptionsLoader {\n getCommandRoot(): string;\n getAppRoot(): Promise<string>;\n getPlatformOptions<T extends SupportedPlatform | undefined>(\n platform: T\n ): Promise<AutolinkingOptions & { platform: T }>;\n getPlatformOptions(): Promise<AutolinkingOptions>;\n}\n\nexport function createAutolinkingOptionsLoader(\n argumentsOptions?: AutolinkingCommonArguments\n): LinkingOptionsLoader {\n const extraArgumentsOptions = parseExtraArgumentsOptions(argumentsOptions ?? {});\n const { commandRoot } = extraArgumentsOptions;\n\n let _packageJsonPath$: Promise<string> | undefined;\n const getPackageJsonPath = () => {\n return _packageJsonPath$ || (_packageJsonPath$ = findPackageJsonPathAsync(commandRoot));\n };\n\n let _packageJson$: Promise<Record<string, unknown>> | undefined;\n const getPackageJson = async () =>\n _packageJson$ || (_packageJson$ = loadPackageJSONAsync(await getPackageJsonPath()));\n\n const getAppRoot = async () => path.dirname(await getPackageJsonPath());\n\n return {\n getCommandRoot: () => commandRoot,\n getAppRoot,\n async getPlatformOptions(platform = extraArgumentsOptions.platform) {\n const packageJson = await getPackageJson();\n const appRoot = await getAppRoot();\n const options = parsePackageJsonOptions(packageJson, appRoot, platform);\n\n if (extraArgumentsOptions.extraSearchPaths) {\n options.searchPaths = [\n ...extraArgumentsOptions.extraSearchPaths,\n ...(options.searchPaths ?? []),\n ];\n }\n if (extraArgumentsOptions.extraExclude) {\n options.exclude = [...(options.exclude ?? []), ...extraArgumentsOptions.extraExclude];\n }\n\n return {\n ...normalizeAutolinkingOptions(options, appRoot),\n platform,\n };\n },\n };\n}\n\nconst normalizeAutolinkingOptions = (\n options: Partial<AutolinkingOptions>,\n appRoot: string\n): AutolinkingOptions => {\n return {\n legacy_shallowReactNativeLinking: options.legacy_shallowReactNativeLinking ?? false,\n searchPaths: options.searchPaths ?? [],\n nativeModulesDir: options.nativeModulesDir\n ? (resolvePathMaybe(options.nativeModulesDir, appRoot) ?? null)\n : (resolvePathMaybe('./modules', appRoot) ?? null),\n exclude: options.exclude ?? [],\n buildFromSource: options.buildFromSource,\n flags: options.flags,\n };\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-autolinking",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "Scripts that autolink Expo modules.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "require-from-string": "^2.0.2",
48
48
  "resolve-from": "^5.0.0"
49
49
  },
50
- "gitHead": "d635404a12ea7996b987ce0fb7679a238ebcf31b"
50
+ "gitHead": "d087a2182086089f23bcee65e27434f21db50128"
51
51
  }
@@ -78,9 +78,10 @@ const parsePackageJsonOptions = (
78
78
  const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;
79
79
  let platformOptions: Record<string, unknown> | null = null;
80
80
  if (platform) {
81
- autolinkingOptions && isJSONObject(autolinkingOptions[platform])
82
- ? autolinkingOptions[platform]
83
- : null;
81
+ platformOptions =
82
+ autolinkingOptions && isJSONObject(autolinkingOptions[platform])
83
+ ? autolinkingOptions[platform]
84
+ : null;
84
85
  if (!platformOptions && platform === 'apple') {
85
86
  // NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should
86
87
  // be the base option for other apple platforms, but changing this now is a breaking change