expo-modules-autolinking 3.0.10 → 3.0.11

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/android/expo-gradle-plugin/expo-autolinking-plugin/src/main/kotlin/expo/modules/plugin/KSPLookup.kt +2 -0
  3. package/build/ExpoModuleConfig.js +14 -2
  4. package/build/ExpoModuleConfig.js.map +1 -1
  5. package/build/dependencies/CachedDependenciesLinker.d.ts +1 -0
  6. package/build/dependencies/CachedDependenciesLinker.js +6 -1
  7. package/build/dependencies/CachedDependenciesLinker.js.map +1 -1
  8. package/build/dependencies/resolution.d.ts +1 -0
  9. package/build/dependencies/resolution.js +39 -0
  10. package/build/dependencies/resolution.js.map +1 -1
  11. package/build/dependencies/scanning.js +43 -33
  12. package/build/dependencies/scanning.js.map +1 -1
  13. package/build/platforms/index.d.ts +2 -0
  14. package/build/platforms/index.js +2 -0
  15. package/build/platforms/index.js.map +1 -1
  16. package/build/platforms/web.d.ts +3 -0
  17. package/build/platforms/web.js +14 -0
  18. package/build/platforms/web.js.map +1 -0
  19. package/build/reactNativeConfig/reactNativeConfig.js +4 -0
  20. package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
  21. package/build/reactNativeConfig/reactNativeConfig.types.d.ts +8 -2
  22. package/build/reactNativeConfig/reactNativeConfig.types.js.map +1 -1
  23. package/build/reactNativeConfig/webResolver.d.ts +6 -0
  24. package/build/reactNativeConfig/webResolver.js +37 -0
  25. package/build/reactNativeConfig/webResolver.js.map +1 -0
  26. package/build/types.d.ts +5 -1
  27. package/build/types.js.map +1 -1
  28. package/package.json +2 -2
  29. package/scripts/generateKSPLookup.js +12 -13
  30. package/src/ExpoModuleConfig.ts +13 -2
  31. package/src/dependencies/CachedDependenciesLinker.ts +17 -7
  32. package/src/dependencies/resolution.ts +45 -0
  33. package/src/dependencies/scanning.ts +49 -37
  34. package/src/platforms/index.ts +4 -0
  35. package/src/platforms/web.ts +17 -0
  36. package/src/reactNativeConfig/reactNativeConfig.ts +13 -1
  37. package/src/reactNativeConfig/reactNativeConfig.types.ts +9 -1
  38. package/src/reactNativeConfig/webResolver.ts +47 -0
  39. package/src/types.ts +7 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 3.0.11 — 2025-09-16
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Regression: Support search paths and `nativeModulesDir` pointing directly at module folder ([#39669](https://github.com/expo/expo/pull/39669) by [@kitten](https://github.com/kitten))
18
+ - Mark `ios|macos|tvos` as supported when an Expo Module marks `apple` as a supported platform ([#39700](https://github.com/expo/expo/pull/39700) by [@kitten](https://github.com/kitten))
19
+
20
+ ### 💡 Others
21
+
22
+ - Allow `expo-atlas` (devtool Expo Module) to be discovered in `devDependencies` ([#39688](https://github.com/expo/expo/pull/39688) by [@kitten](https://github.com/kitten))
23
+ - Allow resolving native modules via a `web` platform heuristic for autolinking module resolution in Expo CLI ([#39701](https://github.com/expo/expo/pull/39701) by [@kitten](https://github.com/kitten))
24
+
13
25
  ## 3.0.10 — 2025-09-10
14
26
 
15
27
  _This version does not introduce any user-facing changes._
@@ -3,6 +3,8 @@
3
3
  package expo.modules.plugin
4
4
 
5
5
  val KSPLookup = mapOf(
6
+ "2.2.20" to "2.2.20-2.0.3",
7
+ "2.2.10" to "2.2.10-2.0.2",
6
8
  "2.2.0" to "2.2.0-2.0.2",
7
9
  "2.1.21" to "2.1.21-2.0.2",
8
10
  "2.1.20" to "2.1.20-2.0.1",
@@ -49,13 +49,25 @@ class ExpoModuleConfig {
49
49
  */
50
50
  supportsPlatform(platform) {
51
51
  const supportedPlatforms = this.rawConfig.platforms ?? [];
52
- if (platform === 'apple') {
52
+ if (platform === 'web') {
53
+ // Web platform is implicitly supported for autolinking resolution but has no special behavior
54
+ return true;
55
+ }
56
+ else if (platform === 'apple') {
53
57
  // Apple platform is supported when any of iOS, macOS and tvOS is supported.
54
58
  return supportedPlatforms.some((supportedPlatform) => {
55
59
  return ['apple', 'ios', 'macos', 'tvos'].includes(supportedPlatform);
56
60
  });
57
61
  }
58
- return supportedPlatforms.includes(platform);
62
+ switch (platform) {
63
+ case 'ios':
64
+ case 'macos':
65
+ case 'tvos':
66
+ // ios|macos|tvos are supported when the module supports "apple" as a platform in general
67
+ return supportedPlatforms.includes(platform) || supportedPlatforms.includes('apple');
68
+ default:
69
+ return supportedPlatforms.includes(platform);
70
+ }
59
71
  }
60
72
  /**
61
73
  * Returns the generic config for all Apple platforms with a fallback to the legacy iOS config.
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;;;;AAmLA,sEAiBC;AApMD,4CAAoB;AACpB,gDAAwB;AAWxB,SAAS,QAAQ,CAAI,KAA0B;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED,MAAa,wBAAwB;IAE1B;IACA;IACA;IACA;IACA;IACA;IAIA;IAVT,YACS,IAAY,EACZ,IAAY,EACZ,OAAkB,EAClB,WAAgC,EAChC,iBAAuD,EACvD,8BAAuC;IAC9C;;OAEG;IACI,YAAqB,KAAK;QAT1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAW;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,sBAAiB,GAAjB,iBAAiB,CAAsC;QACvD,mCAA8B,GAA9B,8BAA8B,CAAS;QAIvC,cAAS,GAAT,SAAS,CAAiB;IAChC,CAAC;CACL;AAbD,4DAaC;AAED;;GAEG;AACH,MAAa,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AAiB,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAzID,4CAyIC;AAED,qEAAqE;AACrE,MAAM,4BAA4B,GAAG,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,CAAC;AAE5E,KAAK,UAAU,6BAA6B,CACjD,aAAqB;IAErB,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,4BAA4B,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QACnE,kDAAkD;QAClD,4DAA4D;QAC5D,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/E,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,oBAAoB;YACpB,SAAS;QACX,CAAC;QACD,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAwB,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport {\n AndroidGradleAarProjectDescriptor,\n AndroidGradlePluginDescriptor,\n AndroidPublication,\n RawExpoModuleConfig,\n RawModuleConfigApple,\n SupportedPlatform,\n} from './types';\n\nfunction arrayize<T>(value: T[] | T | undefined): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n return value != null ? [value] : [];\n}\n\nexport class ExpoAndroidProjectConfig {\n constructor(\n public name: string,\n public path: string,\n public modules?: string[],\n public publication?: AndroidPublication,\n public gradleAarProjects?: AndroidGradleAarProjectDescriptor[],\n public shouldUsePublicationScriptPath?: string,\n /**\n * Whether this project is the root one.\n */\n public isDefault: boolean = false\n ) {}\n}\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n const supportedPlatforms = this.rawConfig.platforms ?? [];\n\n if (platform === 'apple') {\n // Apple platform is supported when any of iOS, macOS and tvOS is supported.\n return supportedPlatforms.some((supportedPlatform) => {\n return ['apple', 'ios', 'macos', 'tvos'].includes(supportedPlatform);\n });\n }\n return supportedPlatforms.includes(platform);\n }\n\n /**\n * Returns the generic config for all Apple platforms with a fallback to the legacy iOS config.\n */\n getAppleConfig(): RawModuleConfigApple | null {\n return this.rawConfig.apple ?? this.rawConfig.ios ?? null;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n appleModules() {\n const appleConfig = this.getAppleConfig();\n return appleConfig?.modules ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n appleAppDelegateSubscribers(): string[] {\n return this.getAppleConfig()?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n appleReactDelegateHandlers(): string[] {\n return this.getAppleConfig()?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns podspec paths defined by the module author.\n */\n applePodspecPaths(): string[] {\n return arrayize(this.getAppleConfig()?.podspecPath);\n }\n\n /**\n * Returns the product module names, if defined by the module author.\n */\n appleSwiftModuleNames(): string[] {\n return arrayize(this.getAppleConfig()?.swiftModuleName);\n }\n\n /**\n * Returns whether this module will be added only to the debug configuration\n */\n appleDebugOnly(): boolean {\n return this.getAppleConfig()?.debugOnly ?? false;\n }\n\n /**\n * Returns information about Android projects defined by the module author.\n */\n androidProjects(defaultProjectName: string): ExpoAndroidProjectConfig[] {\n const androidProjects: ExpoAndroidProjectConfig[] = [];\n\n // Adding the \"root\" Android project - it might not be valide.\n androidProjects.push(\n new ExpoAndroidProjectConfig(\n this.rawConfig.android?.name ?? defaultProjectName,\n this.rawConfig.android?.path ?? 'android',\n this.rawConfig.android?.modules,\n this.rawConfig.android?.publication,\n this.rawConfig.android?.gradleAarProjects,\n this.rawConfig.android?.shouldUsePublicationScriptPath,\n !this.rawConfig.android?.path // it's default project because path is not defined\n )\n );\n\n this.rawConfig.android?.projects?.forEach((project) => {\n androidProjects.push(\n new ExpoAndroidProjectConfig(\n project.name,\n project.path,\n project.modules,\n project.publication,\n project.gradleAarProjects,\n project.shouldUsePublicationScriptPath\n )\n );\n });\n\n return androidProjects;\n }\n\n /**\n * Returns gradle plugins descriptors defined by the module author.\n */\n androidGradlePlugins(): AndroidGradlePluginDescriptor[] {\n return arrayize(this.rawConfig.android?.gradlePlugins ?? []);\n }\n\n /**\n * Returns gradle projects containing AAR files defined by the module author.\n */\n androidGradleAarProjects(): AndroidGradleAarProjectDescriptor[] {\n return arrayize(this.rawConfig.android?.gradleAarProjects ?? []);\n }\n\n /**\n * Returns the publication config for Android.\n */\n androidPublication(): AndroidPublication | undefined {\n return this.rawConfig.android?.publication;\n }\n\n /**\n * Returns core features required by the module author.\n */\n coreFeatures(): string[] {\n return arrayize(this.rawConfig.coreFeatures ?? []);\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/** Names of Expo Module config files (highest to lowest priority) */\nconst EXPO_MODULE_CONFIG_FILENAMES = ['expo-module.config.json', 'unimodule.json'];\n\nexport async function discoverExpoModuleConfigAsync(\n directoryPath: string\n): Promise<ExpoModuleConfig | null> {\n for (let idx = 0; idx < EXPO_MODULE_CONFIG_FILENAMES.length; idx++) {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n const targetPath = path.join(directoryPath, EXPO_MODULE_CONFIG_FILENAMES[idx]);\n let text: string;\n try {\n text = await fs.promises.readFile(targetPath, 'utf8');\n } catch {\n // try the next file\n continue;\n }\n return new ExpoModuleConfig(JSON.parse(text) as RawExpoModuleConfig);\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;;;;AA8LA,sEAiBC;AA/MD,4CAAoB;AACpB,gDAAwB;AAWxB,SAAS,QAAQ,CAAI,KAA0B;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED,MAAa,wBAAwB;IAE1B;IACA;IACA;IACA;IACA;IACA;IAIA;IAVT,YACS,IAAY,EACZ,IAAY,EACZ,OAAkB,EAClB,WAAgC,EAChC,iBAAuD,EACvD,8BAAuC;IAC9C;;OAEG;IACI,YAAqB,KAAK;QAT1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAW;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,sBAAiB,GAAjB,iBAAiB,CAAsC;QACvD,mCAA8B,GAA9B,8BAA8B,CAAS;QAIvC,cAAS,GAAT,SAAS,CAAiB;IAChC,CAAC;CACL;AAbD,4DAaC;AAED;;GAEG;AACH,MAAa,gBAAgB;IACN;IAArB,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CA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;AACd,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport {\n AndroidGradleAarProjectDescriptor,\n AndroidGradlePluginDescriptor,\n AndroidPublication,\n RawExpoModuleConfig,\n RawModuleConfigApple,\n SupportedPlatform,\n} from './types';\n\nfunction arrayize<T>(value: T[] | T | undefined): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n return value != null ? [value] : [];\n}\n\nexport class ExpoAndroidProjectConfig {\n constructor(\n public name: string,\n public path: string,\n public modules?: string[],\n public publication?: AndroidPublication,\n public gradleAarProjects?: AndroidGradleAarProjectDescriptor[],\n public shouldUsePublicationScriptPath?: string,\n /**\n * Whether this project is the root one.\n */\n public isDefault: boolean = false\n ) {}\n}\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n const supportedPlatforms = this.rawConfig.platforms ?? [];\n\n if (platform === 'web') {\n // Web platform is implicitly supported for autolinking resolution but has no special behavior\n return true;\n } else if (platform === 'apple') {\n // Apple platform is supported when any of iOS, macOS and tvOS is supported.\n return supportedPlatforms.some((supportedPlatform) => {\n return ['apple', 'ios', 'macos', 'tvos'].includes(supportedPlatform);\n });\n }\n switch (platform) {\n case 'ios':\n case 'macos':\n case 'tvos':\n // ios|macos|tvos are supported when the module supports \"apple\" as a platform in general\n return supportedPlatforms.includes(platform) || supportedPlatforms.includes('apple');\n default:\n return supportedPlatforms.includes(platform);\n }\n }\n\n /**\n * Returns the generic config for all Apple platforms with a fallback to the legacy iOS config.\n */\n getAppleConfig(): RawModuleConfigApple | null {\n return this.rawConfig.apple ?? this.rawConfig.ios ?? null;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n appleModules() {\n const appleConfig = this.getAppleConfig();\n return appleConfig?.modules ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n appleAppDelegateSubscribers(): string[] {\n return this.getAppleConfig()?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n appleReactDelegateHandlers(): string[] {\n return this.getAppleConfig()?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns podspec paths defined by the module author.\n */\n applePodspecPaths(): string[] {\n return arrayize(this.getAppleConfig()?.podspecPath);\n }\n\n /**\n * Returns the product module names, if defined by the module author.\n */\n appleSwiftModuleNames(): string[] {\n return arrayize(this.getAppleConfig()?.swiftModuleName);\n }\n\n /**\n * Returns whether this module will be added only to the debug configuration\n */\n appleDebugOnly(): boolean {\n return this.getAppleConfig()?.debugOnly ?? false;\n }\n\n /**\n * Returns information about Android projects defined by the module author.\n */\n androidProjects(defaultProjectName: string): ExpoAndroidProjectConfig[] {\n const androidProjects: ExpoAndroidProjectConfig[] = [];\n\n // Adding the \"root\" Android project - it might not be valide.\n androidProjects.push(\n new ExpoAndroidProjectConfig(\n this.rawConfig.android?.name ?? defaultProjectName,\n this.rawConfig.android?.path ?? 'android',\n this.rawConfig.android?.modules,\n this.rawConfig.android?.publication,\n this.rawConfig.android?.gradleAarProjects,\n this.rawConfig.android?.shouldUsePublicationScriptPath,\n !this.rawConfig.android?.path // it's default project because path is not defined\n )\n );\n\n this.rawConfig.android?.projects?.forEach((project) => {\n androidProjects.push(\n new ExpoAndroidProjectConfig(\n project.name,\n project.path,\n project.modules,\n project.publication,\n project.gradleAarProjects,\n project.shouldUsePublicationScriptPath\n )\n );\n });\n\n return androidProjects;\n }\n\n /**\n * Returns gradle plugins descriptors defined by the module author.\n */\n androidGradlePlugins(): AndroidGradlePluginDescriptor[] {\n return arrayize(this.rawConfig.android?.gradlePlugins ?? []);\n }\n\n /**\n * Returns gradle projects containing AAR files defined by the module author.\n */\n androidGradleAarProjects(): AndroidGradleAarProjectDescriptor[] {\n return arrayize(this.rawConfig.android?.gradleAarProjects ?? []);\n }\n\n /**\n * Returns the publication config for Android.\n */\n androidPublication(): AndroidPublication | undefined {\n return this.rawConfig.android?.publication;\n }\n\n /**\n * Returns core features required by the module author.\n */\n coreFeatures(): string[] {\n return arrayize(this.rawConfig.coreFeatures ?? []);\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/** Names of Expo Module config files (highest to lowest priority) */\nconst EXPO_MODULE_CONFIG_FILENAMES = ['expo-module.config.json', 'unimodule.json'];\n\nexport async function discoverExpoModuleConfigAsync(\n directoryPath: string\n): Promise<ExpoModuleConfig | null> {\n for (let idx = 0; idx < EXPO_MODULE_CONFIG_FILENAMES.length; idx++) {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n const targetPath = path.join(directoryPath, EXPO_MODULE_CONFIG_FILENAMES[idx]);\n let text: string;\n try {\n text = await fs.promises.readFile(targetPath, 'utf8');\n } catch {\n // try the next file\n continue;\n }\n return new ExpoModuleConfig(JSON.parse(text) as RawExpoModuleConfig);\n }\n return null;\n}\n"]}
@@ -10,6 +10,7 @@ export interface CachedDependenciesLinker {
10
10
  loadReactNativeProjectConfig(): Promise<RNConfigReactNativeProjectConfig | null>;
11
11
  scanDependenciesFromRNProjectConfig(): Promise<ResolutionResult>;
12
12
  scanDependenciesRecursively(): Promise<ResolutionResult>;
13
+ scanDevDependenciesShallowly(): Promise<ResolutionResult>;
13
14
  scanDependenciesInSearchPath(searchPath: string): Promise<ResolutionResult>;
14
15
  }
15
16
  export declare function makeCachedDependenciesLinker(params: {
@@ -25,6 +25,7 @@ function makeCachedDependenciesLinker(params) {
25
25
  let reactNativeProjectConfig;
26
26
  let reactNativeProjectConfigDependencies;
27
27
  let recursiveDependencies;
28
+ let devDependencies;
28
29
  return {
29
30
  async getOptionsForPlatform(platform) {
30
31
  const options = await autolinkingOptionsLoader.getPlatformOptions(platform);
@@ -45,6 +46,9 @@ function makeCachedDependenciesLinker(params) {
45
46
  return (recursiveDependencies ||
46
47
  (recursiveDependencies = (0, resolution_1.scanDependenciesRecursively)(await getAppRoot())));
47
48
  },
49
+ async scanDevDependenciesShallowly() {
50
+ return (devDependencies || (devDependencies = (0, resolution_1.scanDevDependenciesShallowly)(await getAppRoot())));
51
+ },
48
52
  async scanDependenciesInSearchPath(searchPath) {
49
53
  let result = dependenciesResultBySearchPath.get(searchPath);
50
54
  if (!result) {
@@ -99,8 +103,9 @@ async function scanExpoModuleResolutionsForPlatform(linker, platform) {
99
103
  ...searchPaths.map((searchPath) => {
100
104
  return linker.scanDependenciesInSearchPath(searchPath);
101
105
  }),
106
+ platform === 'devtools' ? linker.scanDevDependenciesShallowly() : null,
102
107
  linker.scanDependenciesRecursively(),
103
- ]));
108
+ ].filter((x) => x != null)));
104
109
  return await (0, utils_1.filterMapResolutionResult)(resolutions, async (resolution) => {
105
110
  return !excludeNames.has(resolution.name)
106
111
  ? await (0, findModules_1.resolveExpoModule)(resolution, platform, excludeNames)
@@ -1 +1 @@
1
- {"version":3,"file":"CachedDependenciesLinker.js","sourceRoot":"","sources":["../../src/dependencies/CachedDependenciesLinker.ts"],"names":[],"mappings":";;;;;AA0BA,oEAuDC;AAED,oFAiDC;AAED,oFAkBC;AAxJD,4CAAoB;AAGpB,6CAA2D;AAC3D,6CAAmE;AACnE,yCAA0D;AAE1D,mCAA4E;AAC5E,4DAA+D;AAC/D,uEAAoG;AACpG,4DAAkG;AAClG,wDAA8D;AAe9D,SAAgB,4BAA4B,CAAC,MAE5C;IACC,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,GA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U,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 { resolveReactNativeModule, RNConfigReactNativeProjectConfig } from '../reactNativeConfig';\nimport { loadConfigAsync } from '../reactNativeConfig/config';\n\nexport interface CachedDependenciesSearchOptions {\n excludeNames: Set<string>;\n searchPaths: string[];\n}\n\nexport interface CachedDependenciesLinker {\n getOptionsForPlatform(platform: SupportedPlatform): 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 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 async getOptionsForPlatform(platform) {\n const options = await autolinkingOptionsLoader.getPlatformOptions(platform);\n return makeCachedDependenciesSearchOptions(options);\n },\n async loadReactNativeProjectConfig() {\n if (reactNativeProjectConfig === undefined) {\n reactNativeProjectConfig = loadConfigAsync<RNConfigReactNativeProjectConfig>(\n await getAppRoot()\n );\n }\n return reactNativeProjectConfig;\n },\n async scanDependenciesFromRNProjectConfig() {\n const reactNativeProjectConfig = await this.loadReactNativeProjectConfig();\n return (\n reactNativeProjectConfigDependencies ||\n (reactNativeProjectConfigDependencies = scanDependenciesFromRNProjectConfig(\n await getAppRoot(),\n reactNativeProjectConfig\n ))\n );\n },\n async scanDependenciesRecursively() {\n return (\n recursiveDependencies ||\n (recursiveDependencies = scanDependenciesRecursively(await getAppRoot()))\n );\n },\n async scanDependenciesInSearchPath(searchPath: string) {\n let result = dependenciesResultBySearchPath.get(searchPath);\n if (!result) {\n dependenciesResultBySearchPath.set(\n searchPath,\n (result = scanDependenciesInSearchPath(searchPath))\n );\n }\n return result;\n },\n };\n}\n\nexport async function scanDependencyResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform,\n include?: string[]\n): Promise<ResolutionResult> {\n const { excludeNames, searchPaths } = await linker.getOptionsForPlatform(platform);\n const includeNames = new Set(include);\n const reactNativeProjectConfig = await linker.loadReactNativeProjectConfig();\n\n const resolutions = mergeResolutionResults(\n await Promise.all([\n linker.scanDependenciesFromRNProjectConfig(),\n ...searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n linker.scanDependenciesRecursively(),\n ])\n );\n\n const dependencies = await filterMapResolutionResult(resolutions, async (resolution) => {\n if (excludeNames.has(resolution.name)) {\n return null;\n } else if (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 excludeNames\n );\n if (!reactNativeModuleDesc) {\n return null;\n }\n } else {\n const [reactNativeModule, expoModule] = await Promise.all([\n resolveReactNativeModule(resolution, reactNativeProjectConfig, platform, excludeNames),\n resolveExpoModule(resolution, platform, excludeNames),\n ]);\n if (!reactNativeModule && !expoModule) {\n return null;\n }\n }\n return resolution;\n });\n\n return dependencies;\n}\n\nexport async function scanExpoModuleResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform\n): Promise<Record<string, PackageRevision>> {\n const { excludeNames, searchPaths } = await linker.getOptionsForPlatform(platform);\n const resolutions = mergeResolutionResults(\n await Promise.all([\n ...searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n linker.scanDependenciesRecursively(),\n ])\n );\n return await filterMapResolutionResult(resolutions, async (resolution) => {\n return !excludeNames.has(resolution.name)\n ? await resolveExpoModule(resolution, platform, excludeNames)\n : null;\n });\n}\n\nconst makeCachedDependenciesSearchOptions = (options: AutolinkingOptions) => ({\n excludeNames: new Set(options.exclude),\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":";;;;;AA2BA,oEA6DC;AAED,oFAiDC;AAED,oFAqBC;AAlKD,4CAAoB;AAGpB,6CAAyF;AACzF,6CAAmE;AACnE,yCAA0D;AAE1D,mCAA4E;AAC5E,4DAA+D;AAC/D,uEAAoG;AACpG,4DAAkG;AAClG,wDAA8D;AAgB9D,SAAgB,4BAA4B,CAAC,MAE5C;IACC,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;QAC9D,W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M,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAC3B,CACF,CAAC;IACF,OAAO,MAAM,IAAA,iCAAyB,EAAC,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;QACvE,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;YACvC,CAAC,CAAC,MAAM,IAAA,+BAAiB,EAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC;YAC7D,CAAC,CAAC,IAAI,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,mCAAmC,GAAG,CAAC,OAA2B,EAAE,EAAE,CAAC,CAAC;IAC5E,YAAY,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;IACtC,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, scanDevDependenciesShallowly } 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 { resolveReactNativeModule, RNConfigReactNativeProjectConfig } from '../reactNativeConfig';\nimport { loadConfigAsync } from '../reactNativeConfig/config';\n\nexport interface CachedDependenciesSearchOptions {\n excludeNames: Set<string>;\n searchPaths: string[];\n}\n\nexport interface CachedDependenciesLinker {\n getOptionsForPlatform(platform: SupportedPlatform): Promise<CachedDependenciesSearchOptions>;\n loadReactNativeProjectConfig(): Promise<RNConfigReactNativeProjectConfig | null>;\n scanDependenciesFromRNProjectConfig(): Promise<ResolutionResult>;\n scanDependenciesRecursively(): Promise<ResolutionResult>;\n scanDevDependenciesShallowly(): Promise<ResolutionResult>;\n scanDependenciesInSearchPath(searchPath: string): Promise<ResolutionResult>;\n}\n\nexport function makeCachedDependenciesLinker(params: {\n projectRoot: string;\n}): CachedDependenciesLinker {\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 let devDependencies: Promise<ResolutionResult> | undefined;\n\n return {\n async getOptionsForPlatform(platform) {\n const options = await autolinkingOptionsLoader.getPlatformOptions(platform);\n return makeCachedDependenciesSearchOptions(options);\n },\n async loadReactNativeProjectConfig() {\n if (reactNativeProjectConfig === undefined) {\n reactNativeProjectConfig = loadConfigAsync<RNConfigReactNativeProjectConfig>(\n await getAppRoot()\n );\n }\n return reactNativeProjectConfig;\n },\n async scanDependenciesFromRNProjectConfig() {\n const reactNativeProjectConfig = await this.loadReactNativeProjectConfig();\n return (\n reactNativeProjectConfigDependencies ||\n (reactNativeProjectConfigDependencies = scanDependenciesFromRNProjectConfig(\n await getAppRoot(),\n reactNativeProjectConfig\n ))\n );\n },\n async scanDependenciesRecursively() {\n return (\n recursiveDependencies ||\n (recursiveDependencies = scanDependenciesRecursively(await getAppRoot()))\n );\n },\n async scanDevDependenciesShallowly() {\n return (\n devDependencies || (devDependencies = scanDevDependenciesShallowly(await getAppRoot()))\n );\n },\n async scanDependenciesInSearchPath(searchPath: string) {\n let result = dependenciesResultBySearchPath.get(searchPath);\n if (!result) {\n dependenciesResultBySearchPath.set(\n searchPath,\n (result = scanDependenciesInSearchPath(searchPath))\n );\n }\n return result;\n },\n };\n}\n\nexport async function scanDependencyResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform,\n include?: string[]\n): Promise<ResolutionResult> {\n const { excludeNames, searchPaths } = await linker.getOptionsForPlatform(platform);\n const includeNames = new Set(include);\n const reactNativeProjectConfig = await linker.loadReactNativeProjectConfig();\n\n const resolutions = mergeResolutionResults(\n await Promise.all([\n linker.scanDependenciesFromRNProjectConfig(),\n ...searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n linker.scanDependenciesRecursively(),\n ])\n );\n\n const dependencies = await filterMapResolutionResult(resolutions, async (resolution) => {\n if (excludeNames.has(resolution.name)) {\n return null;\n } else if (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 excludeNames\n );\n if (!reactNativeModuleDesc) {\n return null;\n }\n } else {\n const [reactNativeModule, expoModule] = await Promise.all([\n resolveReactNativeModule(resolution, reactNativeProjectConfig, platform, excludeNames),\n resolveExpoModule(resolution, platform, excludeNames),\n ]);\n if (!reactNativeModule && !expoModule) {\n return null;\n }\n }\n return resolution;\n });\n\n return dependencies;\n}\n\nexport async function scanExpoModuleResolutionsForPlatform(\n linker: CachedDependenciesLinker,\n platform: SupportedPlatform\n): Promise<Record<string, PackageRevision>> {\n const { excludeNames, searchPaths } = await linker.getOptionsForPlatform(platform);\n const resolutions = mergeResolutionResults(\n await Promise.all(\n [\n ...searchPaths.map((searchPath) => {\n return linker.scanDependenciesInSearchPath(searchPath);\n }),\n platform === 'devtools' ? linker.scanDevDependenciesShallowly() : null,\n linker.scanDependenciesRecursively(),\n ].filter((x) => x != null)\n )\n );\n return await filterMapResolutionResult(resolutions, async (resolution) => {\n return !excludeNames.has(resolution.name)\n ? await resolveExpoModule(resolution, platform, excludeNames)\n : null;\n });\n}\n\nconst makeCachedDependenciesSearchOptions = (options: AutolinkingOptions) => ({\n excludeNames: new Set(options.exclude),\n searchPaths:\n options.nativeModulesDir && fs.existsSync(options.nativeModulesDir)\n ? [options.nativeModulesDir, ...(options.searchPaths ?? [])]\n : (options.searchPaths ?? []),\n});\n"]}
@@ -7,4 +7,5 @@ interface ResolutionOptions {
7
7
  limitDepth?: number;
8
8
  }
9
9
  export declare function scanDependenciesRecursively(rawPath: string, { shouldIncludeDependency, limitDepth }?: ResolutionOptions): Promise<ResolutionResult>;
10
+ export declare function scanDevDependenciesShallowly(rawPath: string, { shouldIncludeDependency }?: ResolutionOptions): Promise<ResolutionResult>;
10
11
  export {};
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.scanDependenciesRecursively = scanDependenciesRecursively;
7
+ exports.scanDevDependenciesShallowly = scanDevDependenciesShallowly;
7
8
  const node_module_1 = __importDefault(require("node:module"));
8
9
  const utils_1 = require("./utils");
9
10
  // NOTE(@kitten): There's no need to search very deep for modules
@@ -152,4 +153,42 @@ const isOptionalPeerDependencyMeta = (peerDependenciesMeta, packageName) => {
152
153
  'optional' in peerDependenciesMeta[packageName] &&
153
154
  !!peerDependenciesMeta[packageName].optional);
154
155
  };
156
+ async function scanDevDependenciesShallowly(rawPath, { shouldIncludeDependency = utils_1.defaultShouldIncludeDependency } = {}) {
157
+ const rootPath = await (0, utils_1.maybeRealpath)(rawPath);
158
+ if (!rootPath) {
159
+ return {};
160
+ }
161
+ const getNodeModulePaths = createNodeModulePathsCreator();
162
+ const searchResults = Object.create(null);
163
+ const nodeModulePaths = await getNodeModulePaths(rootPath);
164
+ const packageJson = await (0, utils_1.loadPackageJson)((0, utils_1.fastJoin)(rootPath, 'package.json'));
165
+ if (!packageJson) {
166
+ return searchResults;
167
+ }
168
+ const devDependencies = packageJson.devDependencies != null && typeof packageJson.devDependencies === 'object'
169
+ ? packageJson.devDependencies
170
+ : {};
171
+ for (const dependencyName in devDependencies) {
172
+ if (!shouldIncludeDependency(dependencyName)) {
173
+ continue;
174
+ }
175
+ for (let idx = 0; idx < nodeModulePaths.length; idx++) {
176
+ const originPath = (0, utils_1.fastJoin)(nodeModulePaths[idx], dependencyName);
177
+ const nodeModulePath = await (0, utils_1.maybeRealpath)(originPath);
178
+ if (nodeModulePath != null) {
179
+ searchResults[dependencyName] = {
180
+ source: 0 /* DependencyResolutionSource.RECURSIVE_RESOLUTION */,
181
+ name: dependencyName,
182
+ version: '',
183
+ path: nodeModulePath,
184
+ originPath,
185
+ duplicates: null,
186
+ depth: 0,
187
+ };
188
+ break;
189
+ }
190
+ }
191
+ }
192
+ return searchResults;
193
+ }
155
194
  //# sourceMappingURL=resolution.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/dependencies/resolution.ts"],"names":[],"mappings":";;;;;AAyHA,kEAmEC;AA5LD,8DAAiC;AAOjC,mCAOiB;AAMjB,iEAAiE;AACjE,iFAAiF;AACjF,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,MAAM,4BAA4B,GAAG,GAAG,EAAE;IACxC,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC9D,OAAO,KAAK,UAAU,kBAAkB,CAAC,WAAmB;QAC1D,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,MAAM,eAAe,GAAG,qBAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC7D,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,eAAe,CAA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G,IAAA,0BAAkB,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;gBAC7E,CAAC;qBAAM,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;oBAC7B,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;gBAC9C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,4BAA4B,GAAG,CACnC,oBAAyD,EACzD,WAAmB,EACnB,EAAE;IACF,OAAO,CACL,oBAAoB;QACpB,oBAAoB,CAAC,WAAW,CAAC,IAAI,IAAI;QACzC,OAAO,oBAAoB,CAAC,WAAW,CAAC,KAAK,QAAQ;QACrD,UAAU,IAAI,oBAAoB,CAAC,WAAW,CAAC;QAC/C,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,QAAQ,CAC7C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import Module from 'node:module';\n\nimport {\n type ResolutionResult,\n type DependencyResolution,\n DependencyResolutionSource,\n} from './types';\nimport {\n type PackageJson,\n defaultShouldIncludeDependency,\n mergeWithDuplicate,\n loadPackageJson,\n maybeRealpath,\n fastJoin,\n} from './utils';\n\ndeclare module 'node:module' {\n export function _nodeModulePaths(base: string): readonly string[];\n}\n\n// NOTE(@kitten): There's no need to search very deep for modules\n// We don't expect native modules to be excessively nested in the dependency tree\nconst MAX_DEPTH = 8;\n\nconst createNodeModulePathsCreator = () => {\n const _nodeModulePathCache = new Map<string, string | null>();\n return async function getNodeModulePaths(packagePath: string) {\n const outputPaths: string[] = [];\n const nodeModulePaths = Module._nodeModulePaths(packagePath);\n for (let idx = 0; idx < nodeModulePaths.length; idx++) {\n const nodeModulePath = nodeModulePaths[idx];\n let target = _nodeModulePathCache.get(nodeModulePath);\n if (target === undefined) {\n target = await maybeRealpath(nodeModulePath);\n if (idx !== 0) {\n _nodeModulePathCache.set(nodeModulePath, target);\n }\n }\n if (target != null) {\n outputPaths.push(target);\n }\n }\n return outputPaths;\n };\n};\n\nasync function resolveDependencies(\n packageJson: PackageJson,\n nodeModulePaths: readonly string[],\n depth: number,\n shouldIncludeDependency: (dependencyName: string) => boolean\n): Promise<DependencyResolution[]> {\n const modules: DependencyResolution[] = [];\n const dependencies =\n packageJson.dependencies != null && typeof packageJson.dependencies === 'object'\n ? packageJson.dependencies\n : {};\n for (const dependencyName in dependencies) {\n if (!shouldIncludeDependency(dependencyName)) {\n continue;\n }\n for (let idx = 0; idx < nodeModulePaths.length; idx++) {\n const originPath = fastJoin(nodeModulePaths[idx], dependencyName);\n const nodeModulePath = await maybeRealpath(originPath);\n if (nodeModulePath != null) {\n modules.push({\n source: DependencyResolutionSource.RECURSIVE_RESOLUTION,\n name: dependencyName,\n version: '',\n path: nodeModulePath,\n originPath,\n duplicates: null,\n depth,\n });\n break;\n }\n }\n }\n\n if (packageJson.peerDependencies != null && typeof packageJson.peerDependencies === 'object') {\n const peerDependenciesMeta =\n packageJson.peerDependenciesMeta != null &&\n typeof packageJson.peerDependenciesMeta === 'object'\n ? (packageJson.peerDependenciesMeta as Record<string, unknown>)\n : undefined;\n for (const dependencyName in packageJson.peerDependencies) {\n if (dependencyName in dependencies || !shouldIncludeDependency(dependencyName)) {\n continue;\n } else if (isOptionalPeerDependencyMeta(peerDependenciesMeta, dependencyName)) {\n // NOTE(@kitten): We only check peer dependencies because some package managers auto-install them\n // which would mean they'd have no reference in any dependencies. However, optional peer dependencies\n // don't auto-install and we can skip them\n continue;\n }\n for (let idx = 0; idx < nodeModulePaths.length; idx++) {\n const originPath = fastJoin(nodeModulePaths[idx], dependencyName);\n const nodeModulePath = await maybeRealpath(originPath);\n if (nodeModulePath != null) {\n modules.push({\n source: DependencyResolutionSource.RECURSIVE_RESOLUTION,\n name: dependencyName,\n version: '',\n path: nodeModulePath,\n originPath,\n duplicates: null,\n depth,\n });\n break;\n }\n }\n }\n }\n\n return modules;\n}\n\ninterface ResolutionOptions {\n shouldIncludeDependency?(name: string): boolean;\n limitDepth?: number;\n}\n\nexport async function scanDependenciesRecursively(\n rawPath: string,\n { shouldIncludeDependency = defaultShouldIncludeDependency, limitDepth }: ResolutionOptions = {}\n): Promise<ResolutionResult> {\n const rootPath = await maybeRealpath(rawPath);\n if (!rootPath) {\n return {};\n }\n\n const modulePathsQueue: DependencyResolution[] = [\n {\n source: DependencyResolutionSource.RECURSIVE_RESOLUTION,\n name: '',\n version: '',\n path: rootPath,\n originPath: rawPath,\n duplicates: null,\n depth: -1,\n },\n ];\n\n const _visitedPackagePaths = new Set();\n const getNodeModulePaths = createNodeModulePathsCreator();\n const searchResults: ResolutionResult = Object.create(null);\n const maxDepth = limitDepth != null ? limitDepth : MAX_DEPTH;\n for (let depth = 0; modulePathsQueue.length > 0 && depth < maxDepth; depth++) {\n const resolutions = await Promise.all(\n modulePathsQueue.map(async (resolution) => {\n const nodeModulePaths = await getNodeModulePaths(resolution.path);\n const packageJson = await loadPackageJson(fastJoin(resolution.path, 'package.json'));\n if (packageJson) {\n resolution.version = packageJson.version || '';\n return await resolveDependencies(\n packageJson,\n nodeModulePaths,\n depth,\n shouldIncludeDependency\n );\n } else {\n return [];\n }\n })\n );\n\n modulePathsQueue.length = 0;\n for (let resolutionIdx = 0; resolutionIdx < resolutions.length; resolutionIdx++) {\n const modules = resolutions[resolutionIdx];\n for (let moduleIdx = 0; moduleIdx < modules.length; moduleIdx++) {\n const resolution = modules[moduleIdx];\n if (_visitedPackagePaths.has(resolution.path)) {\n continue;\n }\n\n _visitedPackagePaths.add(resolution.path);\n modulePathsQueue.push(resolution);\n\n const prevEntry = searchResults[resolution.name];\n if (prevEntry != null && resolution.path !== prevEntry.path) {\n searchResults[resolution.name] = mergeWithDuplicate(prevEntry, resolution);\n } else if (prevEntry == null) {\n searchResults[resolution.name] = resolution;\n }\n }\n }\n }\n\n return searchResults;\n}\n\nconst isOptionalPeerDependencyMeta = (\n peerDependenciesMeta: Record<string, unknown> | undefined,\n packageName: string\n) => {\n return (\n peerDependenciesMeta &&\n peerDependenciesMeta[packageName] != null &&\n typeof peerDependenciesMeta[packageName] === 'object' &&\n 'optional' in peerDependenciesMeta[packageName] &&\n !!peerDependenciesMeta[packageName].optional\n );\n};\n"]}
1
+ {"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/dependencies/resolution.ts"],"names":[],"mappings":";;;;;AAyHA,kEAmEC;AAeD,oEA2CC;AAtPD,8DAAiC;AAOjC,mCAOiB;AAMjB,iEAAiE;AACjE,iFAAiF;AACjF,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,MAAM,4BAA4B,GAAG,GAAG,EAAE;IACxC,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC9D,OAAO,KAAK,UAAU,kBAAkB,CAAC,WAAmB;QAC1D,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,MAAM,eAAe,GAAG,qBAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC7D,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;YACtD,MAAM,cAAc,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YACtD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,cAAc,CAAC,CAAC;gBAC7C,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;oBACd,oBAAoB,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;YACD,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,KA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,yDAAiD;oBACvD,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,cAAc;oBACpB,UAAU;oBACV,UAAU,EAAE,IAAI;oBAChB,KAAK,EAAE,CAAC;iBACT,CAAC;gBACF,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import Module from 'node:module';\n\nimport {\n type ResolutionResult,\n type DependencyResolution,\n DependencyResolutionSource,\n} from './types';\nimport {\n type PackageJson,\n defaultShouldIncludeDependency,\n mergeWithDuplicate,\n loadPackageJson,\n maybeRealpath,\n fastJoin,\n} from './utils';\n\ndeclare module 'node:module' {\n export function _nodeModulePaths(base: string): readonly string[];\n}\n\n// NOTE(@kitten): There's no need to search very deep for modules\n// We don't expect native modules to be excessively nested in the dependency tree\nconst MAX_DEPTH = 8;\n\nconst createNodeModulePathsCreator = () => {\n const _nodeModulePathCache = new Map<string, string | null>();\n return async function getNodeModulePaths(packagePath: string) {\n const outputPaths: string[] = [];\n const nodeModulePaths = Module._nodeModulePaths(packagePath);\n for (let idx = 0; idx < nodeModulePaths.length; idx++) {\n const nodeModulePath = nodeModulePaths[idx];\n let target = _nodeModulePathCache.get(nodeModulePath);\n if (target === undefined) {\n target = await maybeRealpath(nodeModulePath);\n if (idx !== 0) {\n _nodeModulePathCache.set(nodeModulePath, target);\n }\n }\n if (target != null) {\n outputPaths.push(target);\n }\n }\n return outputPaths;\n };\n};\n\nasync function resolveDependencies(\n packageJson: PackageJson,\n nodeModulePaths: readonly string[],\n depth: number,\n shouldIncludeDependency: (dependencyName: string) => boolean\n): Promise<DependencyResolution[]> {\n const modules: DependencyResolution[] = [];\n const dependencies =\n packageJson.dependencies != null && typeof packageJson.dependencies === 'object'\n ? packageJson.dependencies\n : {};\n for (const dependencyName in dependencies) {\n if (!shouldIncludeDependency(dependencyName)) {\n continue;\n }\n for (let idx = 0; idx < nodeModulePaths.length; idx++) {\n const originPath = fastJoin(nodeModulePaths[idx], dependencyName);\n const nodeModulePath = await maybeRealpath(originPath);\n if (nodeModulePath != null) {\n modules.push({\n source: DependencyResolutionSource.RECURSIVE_RESOLUTION,\n name: dependencyName,\n version: '',\n path: nodeModulePath,\n originPath,\n duplicates: null,\n depth,\n });\n break;\n }\n }\n }\n\n if (packageJson.peerDependencies != null && typeof packageJson.peerDependencies === 'object') {\n const peerDependenciesMeta =\n packageJson.peerDependenciesMeta != null &&\n typeof packageJson.peerDependenciesMeta === 'object'\n ? (packageJson.peerDependenciesMeta as Record<string, unknown>)\n : undefined;\n for (const dependencyName in packageJson.peerDependencies) {\n if (dependencyName in dependencies || !shouldIncludeDependency(dependencyName)) {\n continue;\n } else if (isOptionalPeerDependencyMeta(peerDependenciesMeta, dependencyName)) {\n // NOTE(@kitten): We only check peer dependencies because some package managers auto-install them\n // which would mean they'd have no reference in any dependencies. However, optional peer dependencies\n // don't auto-install and we can skip them\n continue;\n }\n for (let idx = 0; idx < nodeModulePaths.length; idx++) {\n const originPath = fastJoin(nodeModulePaths[idx], dependencyName);\n const nodeModulePath = await maybeRealpath(originPath);\n if (nodeModulePath != null) {\n modules.push({\n source: DependencyResolutionSource.RECURSIVE_RESOLUTION,\n name: dependencyName,\n version: '',\n path: nodeModulePath,\n originPath,\n duplicates: null,\n depth,\n });\n break;\n }\n }\n }\n }\n\n return modules;\n}\n\ninterface ResolutionOptions {\n shouldIncludeDependency?(name: string): boolean;\n limitDepth?: number;\n}\n\nexport async function scanDependenciesRecursively(\n rawPath: string,\n { shouldIncludeDependency = defaultShouldIncludeDependency, limitDepth }: ResolutionOptions = {}\n): Promise<ResolutionResult> {\n const rootPath = await maybeRealpath(rawPath);\n if (!rootPath) {\n return {};\n }\n\n const modulePathsQueue: DependencyResolution[] = [\n {\n source: DependencyResolutionSource.RECURSIVE_RESOLUTION,\n name: '',\n version: '',\n path: rootPath,\n originPath: rawPath,\n duplicates: null,\n depth: -1,\n },\n ];\n\n const _visitedPackagePaths = new Set();\n const getNodeModulePaths = createNodeModulePathsCreator();\n const searchResults: ResolutionResult = Object.create(null);\n const maxDepth = limitDepth != null ? limitDepth : MAX_DEPTH;\n for (let depth = 0; modulePathsQueue.length > 0 && depth < maxDepth; depth++) {\n const resolutions = await Promise.all(\n modulePathsQueue.map(async (resolution) => {\n const nodeModulePaths = await getNodeModulePaths(resolution.path);\n const packageJson = await loadPackageJson(fastJoin(resolution.path, 'package.json'));\n if (packageJson) {\n resolution.version = packageJson.version || '';\n return await resolveDependencies(\n packageJson,\n nodeModulePaths,\n depth,\n shouldIncludeDependency\n );\n } else {\n return [];\n }\n })\n );\n\n modulePathsQueue.length = 0;\n for (let resolutionIdx = 0; resolutionIdx < resolutions.length; resolutionIdx++) {\n const modules = resolutions[resolutionIdx];\n for (let moduleIdx = 0; moduleIdx < modules.length; moduleIdx++) {\n const resolution = modules[moduleIdx];\n if (_visitedPackagePaths.has(resolution.path)) {\n continue;\n }\n\n _visitedPackagePaths.add(resolution.path);\n modulePathsQueue.push(resolution);\n\n const prevEntry = searchResults[resolution.name];\n if (prevEntry != null && resolution.path !== prevEntry.path) {\n searchResults[resolution.name] = mergeWithDuplicate(prevEntry, resolution);\n } else if (prevEntry == null) {\n searchResults[resolution.name] = resolution;\n }\n }\n }\n }\n\n return searchResults;\n}\n\nconst isOptionalPeerDependencyMeta = (\n peerDependenciesMeta: Record<string, unknown> | undefined,\n packageName: string\n) => {\n return (\n peerDependenciesMeta &&\n peerDependenciesMeta[packageName] != null &&\n typeof peerDependenciesMeta[packageName] === 'object' &&\n 'optional' in peerDependenciesMeta[packageName] &&\n !!peerDependenciesMeta[packageName].optional\n );\n};\n\nexport async function scanDevDependenciesShallowly(\n rawPath: string,\n { shouldIncludeDependency = defaultShouldIncludeDependency }: ResolutionOptions = {}\n): Promise<ResolutionResult> {\n const rootPath = await maybeRealpath(rawPath);\n if (!rootPath) {\n return {};\n }\n\n const getNodeModulePaths = createNodeModulePathsCreator();\n const searchResults: ResolutionResult = Object.create(null);\n const nodeModulePaths = await getNodeModulePaths(rootPath);\n const packageJson = await loadPackageJson(fastJoin(rootPath, 'package.json'));\n if (!packageJson) {\n return searchResults;\n }\n\n const devDependencies =\n packageJson.devDependencies != null && typeof packageJson.devDependencies === 'object'\n ? packageJson.devDependencies\n : {};\n for (const dependencyName in devDependencies) {\n if (!shouldIncludeDependency(dependencyName)) {\n continue;\n }\n for (let idx = 0; idx < nodeModulePaths.length; idx++) {\n const originPath = fastJoin(nodeModulePaths[idx], dependencyName);\n const nodeModulePath = await maybeRealpath(originPath);\n if (nodeModulePath != null) {\n searchResults[dependencyName] = {\n source: DependencyResolutionSource.RECURSIVE_RESOLUTION,\n name: dependencyName,\n version: '',\n path: nodeModulePath,\n originPath,\n duplicates: null,\n depth: 0,\n };\n break;\n }\n }\n }\n return searchResults;\n}\n"]}
@@ -7,10 +7,10 @@ exports.scanDependenciesInSearchPath = scanDependenciesInSearchPath;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const utils_1 = require("./utils");
9
9
  async function resolveDependency(basePath, dependencyName, shouldIncludeDependency) {
10
- if (!shouldIncludeDependency(dependencyName)) {
10
+ if (dependencyName && !shouldIncludeDependency(dependencyName)) {
11
11
  return null;
12
12
  }
13
- const originPath = (0, utils_1.fastJoin)(basePath, dependencyName);
13
+ const originPath = dependencyName ? (0, utils_1.fastJoin)(basePath, dependencyName) : basePath;
14
14
  const realPath = await (0, utils_1.maybeRealpath)(originPath);
15
15
  const packageJson = await (0, utils_1.loadPackageJson)((0, utils_1.fastJoin)(realPath || originPath, 'package.json'));
16
16
  if (packageJson) {
@@ -24,7 +24,7 @@ async function resolveDependency(basePath, dependencyName, shouldIncludeDependen
24
24
  depth: 0,
25
25
  };
26
26
  }
27
- else if (realPath) {
27
+ else if (dependencyName && realPath) {
28
28
  return {
29
29
  source: 1 /* DependencyResolutionSource.SEARCH_PATH */,
30
30
  name: dependencyName.toLowerCase(),
@@ -46,40 +46,50 @@ async function scanDependenciesInSearchPath(rawPath, { shouldIncludeDependency =
46
46
  return searchResults;
47
47
  }
48
48
  const resolvedDependencies = [];
49
- const dirents = await fs_1.default.promises.readdir(rootPath, { withFileTypes: true });
50
- await Promise.all(dirents.map(async (entry) => {
51
- if (entry.isSymbolicLink()) {
52
- const resolution = await resolveDependency(rootPath, entry.name, shouldIncludeDependency);
53
- if (resolution)
54
- resolvedDependencies.push(resolution);
55
- }
56
- else if (entry.isDirectory()) {
57
- if (entry.name === 'node_modules') {
58
- // Ignore nested node_modules folder
59
- }
60
- if (entry.name[0] === '.') {
61
- // Ignore hidden folders
62
- }
63
- else if (entry.name[0] === '@') {
64
- // NOTE: We don't expect @-scope folders to be symlinks
65
- const entryPath = (0, utils_1.fastJoin)(rootPath, entry.name);
66
- const childEntries = await fs_1.default.promises.readdir(entryPath, { withFileTypes: true });
67
- await Promise.all(childEntries.map(async (child) => {
68
- const dependencyName = `${entry.name}/${child.name}`;
69
- if (child.isDirectory() || child.isSymbolicLink()) {
70
- const resolution = await resolveDependency(rootPath, dependencyName, shouldIncludeDependency);
71
- if (resolution)
72
- resolvedDependencies.push(resolution);
73
- }
74
- }));
75
- }
76
- else {
49
+ const localModuleTarget = await (0, utils_1.maybeRealpath)((0, utils_1.fastJoin)(rootPath, 'package.json'));
50
+ if (localModuleTarget) {
51
+ // If we have a `package.json` file in the search path, we're already dealing with a node module
52
+ // and can skip the rest. This is a special case created by create-expo-module's `nativeModulesDir: ../`
53
+ const resolution = await resolveDependency(rootPath, null, shouldIncludeDependency);
54
+ if (resolution)
55
+ resolvedDependencies.push(resolution);
56
+ }
57
+ else {
58
+ const dirents = await fs_1.default.promises.readdir(rootPath, { withFileTypes: true });
59
+ await Promise.all(dirents.map(async (entry) => {
60
+ if (entry.isSymbolicLink()) {
77
61
  const resolution = await resolveDependency(rootPath, entry.name, shouldIncludeDependency);
78
62
  if (resolution)
79
63
  resolvedDependencies.push(resolution);
80
64
  }
81
- }
82
- }));
65
+ else if (entry.isDirectory()) {
66
+ if (entry.name === 'node_modules') {
67
+ // Ignore nested node_modules folder
68
+ }
69
+ if (entry.name[0] === '.') {
70
+ // Ignore hidden folders
71
+ }
72
+ else if (entry.name[0] === '@') {
73
+ // NOTE: We don't expect @-scope folders to be symlinks
74
+ const entryPath = (0, utils_1.fastJoin)(rootPath, entry.name);
75
+ const childEntries = await fs_1.default.promises.readdir(entryPath, { withFileTypes: true });
76
+ await Promise.all(childEntries.map(async (child) => {
77
+ const dependencyName = `${entry.name}/${child.name}`;
78
+ if (child.isDirectory() || child.isSymbolicLink()) {
79
+ const resolution = await resolveDependency(rootPath, dependencyName, shouldIncludeDependency);
80
+ if (resolution)
81
+ resolvedDependencies.push(resolution);
82
+ }
83
+ }));
84
+ }
85
+ else {
86
+ const resolution = await resolveDependency(rootPath, entry.name, shouldIncludeDependency);
87
+ if (resolution)
88
+ resolvedDependencies.push(resolution);
89
+ }
90
+ }
91
+ }));
92
+ }
83
93
  for (let idx = 0; idx < resolvedDependencies.length; idx++) {
84
94
  const resolution = resolvedDependencies[idx];
85
95
  const prevEntry = searchResults[resolution.name];
@@ -1 +1 @@
1
- {"version":3,"file":"scanning.js","sourceRoot":"","sources":["../../src/dependencies/scanning.ts"],"names":[],"mappings":";;;;;AAiDA,oEAiEC;AAlHD,4CAAoB;AAOpB,mCAAmG;AAEnG,KAAK,UAAU,iBAAiB,CAC9B,QAAgB,EAChB,cAAsB,EACtB,uBAA4D;IAE5D,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,IAAA,gBAAQ,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAe,EAAC,IAAA,gBAAQ,EAAC,QAAQ,IAAI,UAAU,EAAE,cAAc,CAAC,CAAC,CAA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BAC1F,IAAI,UAAU;oBAAE,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,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 { defaultShouldIncludeDependency, loadPackageJson, maybeRealpath, fastJoin } from './utils';\n\nasync function resolveDependency(\n basePath: string,\n dependencyName: string,\n shouldIncludeDependency: (dependencyName: string) => boolean\n): Promise<DependencyResolution | null> {\n if (!shouldIncludeDependency(dependencyName)) {\n return null;\n }\n const originPath = fastJoin(basePath, dependencyName);\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 (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\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 const dirents = await fs.promises.readdir(rootPath!, { withFileTypes: true });\n\n await Promise.all(\n dirents.map(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"]}
1
+ {"version":3,"file":"scanning.js","sourceRoot":"","sources":["../../src/dependencies/scanning.ts"],"names":[],"mappings":";;;;;AAiDA,oEA6EC;AA9HD,4CAAoB;AAOpB,mCAAmG;AAEnG,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,IAAA,gBAAQ,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClF,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAe,EAAC,IAAA,gBAAQ,EAAC,QAAQ,IAAI,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;IAC5F,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO;YACL,MAAM,gDAAwC;YAC9C,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,EAAE;YAClC,IAAI,EAAE,QAAQ,IAAI,UAAU;YAC5B,UAAU;YACV,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,CAAC;SACT,CAAC;IACJ,CAAC;SAAM,IAAI,cAAc,IAAI,QAAQ,EAAE,CAAC;QACtC,OAAO;YACL,MAAM,gDAAwC;YAC9C,IAAI,EAAE,cAAc,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oBACF,IAAI,UAAU;wBAAE,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACxD,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,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 { defaultShouldIncludeDependency, 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\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 Promise.all(\n dirents.map(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(\n rootPath,\n entry.name,\n shouldIncludeDependency\n );\n if (resolution) resolvedDependencies.push(resolution);\n }\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"]}
@@ -6,10 +6,12 @@ interface PlatformImplementations {
6
6
  apple: typeof import('./apple/apple');
7
7
  android: typeof import('./android/android');
8
8
  devtools: typeof import('./devtools');
9
+ web: typeof import('./web');
9
10
  }
10
11
  declare function getLinkingImplementationForPlatform<Platform extends keyof PlatformImplementations>(platform: Platform): PlatformImplementations[Platform];
11
12
  declare function getLinkingImplementationForPlatform(platform: 'ios' | 'macos' | 'tvos' | 'apple'): PlatformImplementations['apple'];
12
13
  declare function getLinkingImplementationForPlatform(platform: 'android'): PlatformImplementations['android'];
13
14
  declare function getLinkingImplementationForPlatform(platform: 'devtools'): PlatformImplementations['devtools'];
15
+ declare function getLinkingImplementationForPlatform(platform: 'web'): PlatformImplementations['web'];
14
16
  declare function getLinkingImplementationForPlatform(platform: SupportedPlatform): PlatformImplementations[keyof PlatformImplementations];
15
17
  export { getLinkingImplementationForPlatform };
@@ -15,6 +15,8 @@ function getLinkingImplementationForPlatform(platform) {
15
15
  return require('../platforms/android');
16
16
  case 'devtools':
17
17
  return require('../platforms/devtools');
18
+ case 'web':
19
+ return require('../platforms/web');
18
20
  default:
19
21
  throw new Error(`No linking implementation is available for platform "${platform}"`);
20
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platforms/index.ts"],"names":[],"mappings":";;AAgDS,kFAAmC;AArB5C,SAAS,mCAAmC,CAC1C,QAA2B;IAE3B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IACD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACvC,KAAK,SAAS;YACZ,OAAO,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACzC,KAAK,UAAU;YACb,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAC;QAC1C;YACE,MAAM,IAAI,KAAK,CAAC,wDAAwD,QAAQ,GAAG,CAAC,CAAC;IACzF,CAAC;AACH,CAAC","sourcesContent":["import { SupportedPlatform } from '../types';\n\ninterface PlatformImplementations {\n ios: typeof import('./apple/apple');\n macos: typeof import('./apple/apple');\n tvos: typeof import('./apple/apple');\n apple: typeof import('./apple/apple');\n android: typeof import('./android/android');\n devtools: typeof import('./devtools');\n}\n\nfunction getLinkingImplementationForPlatform<Platform extends keyof PlatformImplementations>(\n platform: Platform\n): PlatformImplementations[Platform];\nfunction getLinkingImplementationForPlatform(\n platform: 'ios' | 'macos' | 'tvos' | 'apple'\n): PlatformImplementations['apple'];\nfunction getLinkingImplementationForPlatform(\n platform: 'android'\n): PlatformImplementations['android'];\nfunction getLinkingImplementationForPlatform(\n platform: 'devtools'\n): PlatformImplementations['devtools'];\nfunction getLinkingImplementationForPlatform(\n platform: SupportedPlatform\n): PlatformImplementations[keyof PlatformImplementations];\n\nfunction getLinkingImplementationForPlatform(\n platform: SupportedPlatform\n): PlatformImplementations[keyof PlatformImplementations] {\n if (!platform) {\n throw new Error(`No platform was specified, but linking commands require a specific platform.`);\n }\n switch (platform) {\n case 'ios':\n case 'macos':\n case 'tvos':\n case 'apple':\n return require('../platforms/apple');\n case 'android':\n return require('../platforms/android');\n case 'devtools':\n return require('../platforms/devtools');\n default:\n throw new Error(`No linking implementation is available for platform \"${platform}\"`);\n }\n}\n\nexport { getLinkingImplementationForPlatform };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platforms/index.ts"],"names":[],"mappings":";;AAoDS,kFAAmC;AAvB5C,SAAS,mCAAmC,CAC1C,QAA2B;IAE3B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IACD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACvC,KAAK,SAAS;YACZ,OAAO,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACzC,KAAK,UAAU;YACb,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAC;QAC1C,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACrC;YACE,MAAM,IAAI,KAAK,CAAC,wDAAwD,QAAQ,GAAG,CAAC,CAAC;IACzF,CAAC;AACH,CAAC","sourcesContent":["import { SupportedPlatform } from '../types';\n\ninterface PlatformImplementations {\n ios: typeof import('./apple/apple');\n macos: typeof import('./apple/apple');\n tvos: typeof import('./apple/apple');\n apple: typeof import('./apple/apple');\n android: typeof import('./android/android');\n devtools: typeof import('./devtools');\n web: typeof import('./web');\n}\n\nfunction getLinkingImplementationForPlatform<Platform extends keyof PlatformImplementations>(\n platform: Platform\n): PlatformImplementations[Platform];\nfunction getLinkingImplementationForPlatform(\n platform: 'ios' | 'macos' | 'tvos' | 'apple'\n): PlatformImplementations['apple'];\nfunction getLinkingImplementationForPlatform(\n platform: 'android'\n): PlatformImplementations['android'];\nfunction getLinkingImplementationForPlatform(\n platform: 'devtools'\n): PlatformImplementations['devtools'];\nfunction getLinkingImplementationForPlatform(platform: 'web'): PlatformImplementations['web'];\nfunction getLinkingImplementationForPlatform(\n platform: SupportedPlatform\n): PlatformImplementations[keyof PlatformImplementations];\n\nfunction getLinkingImplementationForPlatform(\n platform: SupportedPlatform\n): PlatformImplementations[keyof PlatformImplementations] {\n if (!platform) {\n throw new Error(`No platform was specified, but linking commands require a specific platform.`);\n }\n switch (platform) {\n case 'ios':\n case 'macos':\n case 'tvos':\n case 'apple':\n return require('../platforms/apple');\n case 'android':\n return require('../platforms/android');\n case 'devtools':\n return require('../platforms/devtools');\n case 'web':\n return require('../platforms/web');\n default:\n throw new Error(`No linking implementation is available for platform \"${platform}\"`);\n }\n}\n\nexport { getLinkingImplementationForPlatform };\n"]}
@@ -0,0 +1,3 @@
1
+ import type { ExtraDependencies, ModuleDescriptorWeb, PackageRevision } from '../types';
2
+ export declare function resolveModuleAsync(packageName: string, revision: PackageRevision): Promise<ModuleDescriptorWeb | null>;
3
+ export declare function resolveExtraBuildDependenciesAsync(_projectNativeRoot: string): Promise<ExtraDependencies | null>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveModuleAsync = resolveModuleAsync;
4
+ exports.resolveExtraBuildDependenciesAsync = resolveExtraBuildDependenciesAsync;
5
+ async function resolveModuleAsync(packageName, revision) {
6
+ return {
7
+ packageName,
8
+ packageRoot: revision.path,
9
+ };
10
+ }
11
+ async function resolveExtraBuildDependenciesAsync(_projectNativeRoot) {
12
+ return null;
13
+ }
14
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/platforms/web.ts"],"names":[],"mappings":";;AAEA,gDAQC;AAED,gFAIC;AAdM,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,QAAyB;IAEzB,OAAO;QACL,WAAW;QACX,WAAW,EAAE,QAAQ,CAAC,IAAI;KAC3B,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,kCAAkC,CACtD,kBAA0B;IAE1B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { ExtraDependencies, ModuleDescriptorWeb, PackageRevision } from '../types';\n\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision\n): Promise<ModuleDescriptorWeb | null> {\n return {\n packageName,\n packageRoot: revision.path,\n };\n}\n\nexport async function resolveExtraBuildDependenciesAsync(\n _projectNativeRoot: string\n): Promise<ExtraDependencies | null> {\n return null;\n}\n"]}
@@ -13,6 +13,7 @@ const config_1 = require("./config");
13
13
  const iosResolver_1 = require("./iosResolver");
14
14
  const ExpoModuleConfig_1 = require("../ExpoModuleConfig");
15
15
  const dependencies_1 = require("../dependencies");
16
+ const webResolver_1 = require("./webResolver");
16
17
  const isMissingFBReactNativeSpecCodegenOutput = async (reactNativePath) => {
17
18
  const generatedDir = path_1.default.resolve(reactNativePath, 'React/FBReactNativeSpec');
18
19
  try {
@@ -64,6 +65,9 @@ async function resolveReactNativeModule(resolution, projectConfig, platform, exc
64
65
  else if (platform === 'ios') {
65
66
  platformData = await (0, iosResolver_1.resolveDependencyConfigImplIosAsync)(resolution, reactNativeConfig.platforms?.ios, maybeExpoModuleConfig);
66
67
  }
68
+ else if (platform === 'web') {
69
+ platformData = await (0, webResolver_1.checkDependencyWebAsync)(resolution, reactNativeConfig, maybeExpoModuleConfig);
70
+ }
67
71
  return (platformData && {
68
72
  root: resolution.path,
69
73
  name: resolution.name,