@vxrn/vite-plugin-metro 2.0.0-beta.33.1 → 2.0.0-beta.45.1

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 (290) hide show
  1. package/dist/cjs/babel-plugins/import-meta-env-plugin.cjs +84 -102
  2. package/dist/cjs/babel-plugins/import-meta-env-plugin.native.cjs +108 -0
  3. package/dist/cjs/babel-plugins/import-meta-env-plugin.native.js +90 -107
  4. package/dist/cjs/babel-plugins/import-meta-env-plugin.native.js.map +1 -1
  5. package/dist/cjs/env/platformEnv.cjs +55 -57
  6. package/dist/cjs/env/platformEnv.native.cjs +93 -0
  7. package/dist/cjs/env/platformEnv.native.js +72 -75
  8. package/dist/cjs/env/platformEnv.native.js.map +1 -1
  9. package/dist/cjs/index.cjs +22 -24
  10. package/dist/cjs/index.native.cjs +41 -0
  11. package/dist/cjs/index.native.js +22 -23
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.cjs +48 -51
  14. package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.cjs +101 -0
  15. package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.js +88 -94
  16. package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.js.map +1 -1
  17. package/dist/cjs/metro-config/getMetroConfigFromViteConfig.cjs +249 -256
  18. package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.cjs +295 -0
  19. package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.js +260 -266
  20. package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.js.map +1 -1
  21. package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.cjs +38 -44
  22. package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.cjs +53 -0
  23. package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js +39 -44
  24. package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js.map +1 -1
  25. package/dist/cjs/metro-config/types.cjs +9 -11
  26. package/dist/cjs/metro-config/types.native.cjs +18 -0
  27. package/dist/cjs/metro-config/types.native.js +9 -10
  28. package/dist/cjs/metro-config/types.native.js.map +1 -1
  29. package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.cjs +44 -56
  30. package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.cjs +62 -0
  31. package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js +45 -63
  32. package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
  33. package/dist/cjs/plugins/metroPlugin.cjs +210 -248
  34. package/dist/cjs/plugins/metroPlugin.native.cjs +242 -0
  35. package/dist/cjs/plugins/metroPlugin.native.js +216 -253
  36. package/dist/cjs/plugins/metroPlugin.native.js.map +1 -1
  37. package/dist/cjs/rn-commands/bundle/assetCatalogIOS.cjs +56 -65
  38. package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.cjs +121 -0
  39. package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.js +94 -106
  40. package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.js.map +1 -1
  41. package/dist/cjs/rn-commands/bundle/assetPathUtils.cjs +51 -55
  42. package/dist/cjs/rn-commands/bundle/assetPathUtils.native.cjs +72 -0
  43. package/dist/cjs/rn-commands/bundle/assetPathUtils.native.js +51 -54
  44. package/dist/cjs/rn-commands/bundle/assetPathUtils.native.js.map +1 -1
  45. package/dist/cjs/rn-commands/bundle/buildBundle.cjs +37 -46
  46. package/dist/cjs/rn-commands/bundle/buildBundle.native.cjs +57 -0
  47. package/dist/cjs/rn-commands/bundle/buildBundle.native.js +39 -47
  48. package/dist/cjs/rn-commands/bundle/buildBundle.native.js.map +1 -1
  49. package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.cjs +57 -68
  50. package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.cjs +81 -0
  51. package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.js +59 -70
  52. package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.js.map +1 -1
  53. package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.cjs +37 -39
  54. package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.cjs +70 -0
  55. package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.js +56 -59
  56. package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.js.map +1 -1
  57. package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.cjs +20 -29
  58. package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.cjs +39 -0
  59. package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.js +20 -28
  60. package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.js.map +1 -1
  61. package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.cjs +20 -33
  62. package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.cjs +38 -0
  63. package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.js +20 -32
  64. package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.js.map +1 -1
  65. package/dist/cjs/rn-commands/bundle/getBuildBundleFn.cjs +23 -32
  66. package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.cjs +38 -0
  67. package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.js +23 -31
  68. package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.js.map +1 -1
  69. package/dist/cjs/rn-commands/bundle/index.cjs +15 -17
  70. package/dist/cjs/rn-commands/bundle/index.native.cjs +30 -0
  71. package/dist/cjs/rn-commands/bundle/index.native.js +15 -16
  72. package/dist/cjs/rn-commands/bundle/index.native.js.map +1 -1
  73. package/dist/cjs/rn-commands/bundle/saveAssets.cjs +85 -96
  74. package/dist/cjs/rn-commands/bundle/saveAssets.native.cjs +129 -0
  75. package/dist/cjs/rn-commands/bundle/saveAssets.native.js +102 -114
  76. package/dist/cjs/rn-commands/bundle/saveAssets.native.js.map +1 -1
  77. package/dist/cjs/rn-commands/bundle/types.cjs +9 -11
  78. package/dist/cjs/rn-commands/bundle/types.native.cjs +18 -0
  79. package/dist/cjs/rn-commands/bundle/types.native.js +9 -10
  80. package/dist/cjs/rn-commands/bundle/types.native.js.map +1 -1
  81. package/dist/cjs/rn-commands/index.cjs +17 -26
  82. package/dist/cjs/rn-commands/index.native.cjs +32 -0
  83. package/dist/cjs/rn-commands/index.native.js +17 -25
  84. package/dist/cjs/rn-commands/index.native.js.map +1 -1
  85. package/dist/cjs/transformer/babel-core.cjs +16 -18
  86. package/dist/cjs/transformer/babel-core.native.cjs +30 -0
  87. package/dist/cjs/transformer/babel-core.native.js +16 -17
  88. package/dist/cjs/transformer/babel-core.native.js.map +1 -1
  89. package/dist/cjs/transformer/babel-transformer.cjs +101 -152
  90. package/dist/cjs/transformer/babel-transformer.native.cjs +131 -0
  91. package/dist/cjs/transformer/babel-transformer.native.js +106 -159
  92. package/dist/cjs/transformer/babel-transformer.native.js.map +1 -1
  93. package/dist/cjs/transformer/loadBabelConfig.cjs +44 -49
  94. package/dist/cjs/transformer/loadBabelConfig.native.cjs +64 -0
  95. package/dist/cjs/transformer/loadBabelConfig.native.js +48 -52
  96. package/dist/cjs/transformer/loadBabelConfig.native.js.map +1 -1
  97. package/dist/cjs/transformer/metroNativeWorker.cjs +1442 -1480
  98. package/dist/cjs/transformer/metroNativeWorker.native.cjs +2536 -0
  99. package/dist/cjs/transformer/metroNativeWorker.native.js +2416 -2552
  100. package/dist/cjs/transformer/metroNativeWorker.native.js.map +1 -1
  101. package/dist/cjs/transformer/transformSync.cjs +47 -63
  102. package/dist/cjs/transformer/transformSync.native.cjs +74 -0
  103. package/dist/cjs/transformer/transformSync.native.js +49 -64
  104. package/dist/cjs/transformer/transformSync.native.js.map +1 -1
  105. package/dist/cjs/transformer/types.cjs +9 -11
  106. package/dist/cjs/transformer/types.native.cjs +18 -0
  107. package/dist/cjs/transformer/types.native.js +9 -10
  108. package/dist/cjs/transformer/types.native.js.map +1 -1
  109. package/dist/cjs/utils/exit.cjs +141 -139
  110. package/dist/cjs/utils/exit.native.cjs +266 -0
  111. package/dist/cjs/utils/exit.native.js +228 -241
  112. package/dist/cjs/utils/exit.native.js.map +1 -1
  113. package/dist/cjs/utils/getTerminalReporter.cjs +35 -47
  114. package/dist/cjs/utils/getTerminalReporter.native.cjs +57 -0
  115. package/dist/cjs/utils/getTerminalReporter.native.js +38 -49
  116. package/dist/cjs/utils/getTerminalReporter.native.js.map +1 -1
  117. package/dist/cjs/utils/metroCacheManager.cjs +84 -99
  118. package/dist/cjs/utils/metroCacheManager.native.cjs +130 -0
  119. package/dist/cjs/utils/metroCacheManager.native.js +102 -118
  120. package/dist/cjs/utils/metroCacheManager.native.js.map +1 -1
  121. package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.cjs +24 -28
  122. package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.cjs +37 -0
  123. package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js +24 -27
  124. package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js.map +1 -1
  125. package/dist/cjs/utils/projectImport.cjs +40 -51
  126. package/dist/cjs/utils/projectImport.native.cjs +64 -0
  127. package/dist/cjs/utils/projectImport.native.js +41 -58
  128. package/dist/cjs/utils/projectImport.native.js.map +1 -1
  129. package/dist/esm/babel-plugins/import-meta-env-plugin.mjs +72 -86
  130. package/dist/esm/babel-plugins/import-meta-env-plugin.mjs.map +1 -1
  131. package/dist/esm/babel-plugins/import-meta-env-plugin.native.js +78 -92
  132. package/dist/esm/babel-plugins/import-meta-env-plugin.native.js.map +1 -1
  133. package/dist/esm/env/platformEnv.mjs +40 -39
  134. package/dist/esm/env/platformEnv.mjs.map +1 -1
  135. package/dist/esm/env/platformEnv.native.js +57 -58
  136. package/dist/esm/env/platformEnv.native.js.map +1 -1
  137. package/dist/esm/index.js +3 -3
  138. package/dist/esm/index.mjs +3 -3
  139. package/dist/esm/index.native.js +3 -3
  140. package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.mjs +35 -33
  141. package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.mjs.map +1 -1
  142. package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.native.js +75 -77
  143. package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.native.js.map +1 -1
  144. package/dist/esm/metro-config/getMetroConfigFromViteConfig.mjs +233 -231
  145. package/dist/esm/metro-config/getMetroConfigFromViteConfig.mjs.map +1 -1
  146. package/dist/esm/metro-config/getMetroConfigFromViteConfig.native.js +244 -242
  147. package/dist/esm/metro-config/getMetroConfigFromViteConfig.native.js.map +1 -1
  148. package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.mjs +26 -26
  149. package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.mjs.map +1 -1
  150. package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js +27 -27
  151. package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js.map +1 -1
  152. package/dist/esm/metro-config/types.mjs +0 -2
  153. package/dist/esm/metro-config/types.native.js +0 -2
  154. package/dist/esm/plugins/expoManifestRequestHandlerPlugin.mjs +32 -38
  155. package/dist/esm/plugins/expoManifestRequestHandlerPlugin.mjs.map +1 -1
  156. package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js +33 -46
  157. package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
  158. package/dist/esm/plugins/metroPlugin.mjs +195 -222
  159. package/dist/esm/plugins/metroPlugin.mjs.map +1 -1
  160. package/dist/esm/plugins/metroPlugin.native.js +201 -228
  161. package/dist/esm/plugins/metroPlugin.native.js.map +1 -1
  162. package/dist/esm/rn-commands/bundle/assetCatalogIOS.mjs +38 -38
  163. package/dist/esm/rn-commands/bundle/assetCatalogIOS.mjs.map +1 -1
  164. package/dist/esm/rn-commands/bundle/assetCatalogIOS.native.js +76 -80
  165. package/dist/esm/rn-commands/bundle/assetCatalogIOS.native.js.map +1 -1
  166. package/dist/esm/rn-commands/bundle/assetPathUtils.mjs +38 -37
  167. package/dist/esm/rn-commands/bundle/assetPathUtils.mjs.map +1 -1
  168. package/dist/esm/rn-commands/bundle/assetPathUtils.native.js +38 -37
  169. package/dist/esm/rn-commands/bundle/assetPathUtils.native.js.map +1 -1
  170. package/dist/esm/rn-commands/bundle/buildBundle.mjs +25 -28
  171. package/dist/esm/rn-commands/bundle/buildBundle.mjs.map +1 -1
  172. package/dist/esm/rn-commands/bundle/buildBundle.native.js +27 -30
  173. package/dist/esm/rn-commands/bundle/buildBundle.native.js.map +1 -1
  174. package/dist/esm/rn-commands/bundle/buildBundleWithConfig.mjs +43 -43
  175. package/dist/esm/rn-commands/bundle/buildBundleWithConfig.mjs.map +1 -1
  176. package/dist/esm/rn-commands/bundle/buildBundleWithConfig.native.js +45 -46
  177. package/dist/esm/rn-commands/bundle/buildBundleWithConfig.native.js.map +1 -1
  178. package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.mjs +24 -21
  179. package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.mjs.map +1 -1
  180. package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.native.js +43 -42
  181. package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.native.js.map +1 -1
  182. package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.mjs +5 -3
  183. package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.mjs.map +1 -1
  184. package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.native.js +5 -3
  185. package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.native.js.map +1 -1
  186. package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.mjs +5 -7
  187. package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.mjs.map +1 -1
  188. package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.native.js +5 -7
  189. package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.native.js.map +1 -1
  190. package/dist/esm/rn-commands/bundle/getBuildBundleFn.mjs +11 -14
  191. package/dist/esm/rn-commands/bundle/getBuildBundleFn.mjs.map +1 -1
  192. package/dist/esm/rn-commands/bundle/getBuildBundleFn.native.js +11 -14
  193. package/dist/esm/rn-commands/bundle/getBuildBundleFn.native.js.map +1 -1
  194. package/dist/esm/rn-commands/bundle/index.mjs +2 -2
  195. package/dist/esm/rn-commands/bundle/index.native.js +2 -2
  196. package/dist/esm/rn-commands/bundle/saveAssets.mjs +70 -70
  197. package/dist/esm/rn-commands/bundle/saveAssets.mjs.map +1 -1
  198. package/dist/esm/rn-commands/bundle/saveAssets.native.js +87 -89
  199. package/dist/esm/rn-commands/bundle/saveAssets.native.js.map +1 -1
  200. package/dist/esm/rn-commands/bundle/types.mjs +0 -2
  201. package/dist/esm/rn-commands/bundle/types.native.js +0 -2
  202. package/dist/esm/rn-commands/index.mjs +2 -2
  203. package/dist/esm/rn-commands/index.native.js +2 -2
  204. package/dist/esm/transformer/babel-core.mjs +2 -2
  205. package/dist/esm/transformer/babel-core.native.js +2 -2
  206. package/dist/esm/transformer/babel-transformer.mjs +108 -144
  207. package/dist/esm/transformer/babel-transformer.mjs.map +1 -1
  208. package/dist/esm/transformer/babel-transformer.native.js +114 -155
  209. package/dist/esm/transformer/babel-transformer.native.js.map +1 -1
  210. package/dist/esm/transformer/loadBabelConfig.mjs +29 -23
  211. package/dist/esm/transformer/loadBabelConfig.mjs.map +1 -1
  212. package/dist/esm/transformer/loadBabelConfig.native.js +33 -27
  213. package/dist/esm/transformer/loadBabelConfig.native.js.map +1 -1
  214. package/dist/esm/transformer/metroNativeWorker.mjs +1405 -1434
  215. package/dist/esm/transformer/metroNativeWorker.mjs.map +1 -1
  216. package/dist/esm/transformer/metroNativeWorker.native.js +2379 -2507
  217. package/dist/esm/transformer/metroNativeWorker.native.js.map +1 -1
  218. package/dist/esm/transformer/transformSync.mjs +32 -37
  219. package/dist/esm/transformer/transformSync.mjs.map +1 -1
  220. package/dist/esm/transformer/transformSync.native.js +34 -39
  221. package/dist/esm/transformer/transformSync.native.js.map +1 -1
  222. package/dist/esm/transformer/types.mjs +0 -2
  223. package/dist/esm/transformer/types.native.js +0 -2
  224. package/dist/esm/utils/exit.mjs +123 -112
  225. package/dist/esm/utils/exit.mjs.map +1 -1
  226. package/dist/esm/utils/exit.native.js +210 -215
  227. package/dist/esm/utils/exit.native.js.map +1 -1
  228. package/dist/esm/utils/getTerminalReporter.mjs +20 -21
  229. package/dist/esm/utils/getTerminalReporter.mjs.map +1 -1
  230. package/dist/esm/utils/getTerminalReporter.native.js +23 -24
  231. package/dist/esm/utils/getTerminalReporter.native.js.map +1 -1
  232. package/dist/esm/utils/metroCacheManager.mjs +73 -82
  233. package/dist/esm/utils/metroCacheManager.mjs.map +1 -1
  234. package/dist/esm/utils/metroCacheManager.native.js +91 -102
  235. package/dist/esm/utils/metroCacheManager.native.js.map +1 -1
  236. package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.mjs +11 -10
  237. package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.mjs.map +1 -1
  238. package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js +11 -10
  239. package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js.map +1 -1
  240. package/dist/esm/utils/projectImport.mjs +23 -25
  241. package/dist/esm/utils/projectImport.mjs.map +1 -1
  242. package/dist/esm/utils/projectImport.native.js +24 -33
  243. package/dist/esm/utils/projectImport.native.js.map +1 -1
  244. package/package.json +5 -6
  245. package/src/metro-config/getMetroConfigFromViteConfig.ts +46 -10
  246. package/src/transformer/loadBabelConfig.ts +2 -0
  247. package/src/transformer/metroNativeWorker.test.ts +267 -35
  248. package/src/transformer/metroNativeWorker.ts +3 -11
  249. package/types/babel-plugins/import-meta-env-plugin.d.ts.map +1 -1
  250. package/types/metro-config/getMetroConfigFromViteConfig.d.ts.map +1 -1
  251. package/types/rn-commands/bundle/assetPathUtils.d.ts.map +1 -1
  252. package/types/rn-commands/bundle/filterPlatformAssetScales.d.ts.map +1 -1
  253. package/types/rn-commands/bundle/getAssetDestPathAndroid.d.ts.map +1 -1
  254. package/types/rn-commands/bundle/getAssetDestPathIOS.d.ts.map +1 -1
  255. package/types/rn-commands/bundle/saveAssets.d.ts.map +1 -1
  256. package/types/transformer/loadBabelConfig.d.ts.map +1 -1
  257. package/types/transformer/metroNativeWorker.d.ts.map +1 -1
  258. package/dist/cjs/transformer/metroNativeWorker.test.cjs +0 -897
  259. package/dist/cjs/transformer/metroNativeWorker.test.native.js +0 -1010
  260. package/dist/cjs/transformer/metroNativeWorker.test.native.js.map +0 -1
  261. package/dist/cjs/transformer/transformSync.test.cjs +0 -36
  262. package/dist/cjs/transformer/transformSync.test.native.js +0 -49
  263. package/dist/cjs/transformer/transformSync.test.native.js.map +0 -1
  264. package/dist/esm/index.js.map +0 -1
  265. package/dist/esm/index.mjs.map +0 -1
  266. package/dist/esm/index.native.js.map +0 -1
  267. package/dist/esm/metro-config/types.mjs.map +0 -1
  268. package/dist/esm/metro-config/types.native.js.map +0 -1
  269. package/dist/esm/rn-commands/bundle/index.mjs.map +0 -1
  270. package/dist/esm/rn-commands/bundle/index.native.js.map +0 -1
  271. package/dist/esm/rn-commands/bundle/types.mjs.map +0 -1
  272. package/dist/esm/rn-commands/bundle/types.native.js.map +0 -1
  273. package/dist/esm/rn-commands/index.mjs.map +0 -1
  274. package/dist/esm/rn-commands/index.native.js.map +0 -1
  275. package/dist/esm/transformer/babel-core.mjs.map +0 -1
  276. package/dist/esm/transformer/babel-core.native.js.map +0 -1
  277. package/dist/esm/transformer/metroNativeWorker.test.mjs +0 -861
  278. package/dist/esm/transformer/metroNativeWorker.test.mjs.map +0 -1
  279. package/dist/esm/transformer/metroNativeWorker.test.native.js +0 -972
  280. package/dist/esm/transformer/metroNativeWorker.test.native.js.map +0 -1
  281. package/dist/esm/transformer/transformSync.test.mjs +0 -37
  282. package/dist/esm/transformer/transformSync.test.mjs.map +0 -1
  283. package/dist/esm/transformer/transformSync.test.native.js +0 -47
  284. package/dist/esm/transformer/transformSync.test.native.js.map +0 -1
  285. package/dist/esm/transformer/types.mjs.map +0 -1
  286. package/dist/esm/transformer/types.native.js.map +0 -1
  287. package/types/transformer/metroNativeWorker.test.d.ts +0 -2
  288. package/types/transformer/metroNativeWorker.test.d.ts.map +0 -1
  289. package/types/transformer/transformSync.test.d.ts +0 -2
  290. package/types/transformer/transformSync.test.d.ts.map +0 -1
@@ -7,297 +7,291 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
14
  };
15
15
  var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
23
  };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
32
27
  }) : target, mod));
33
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
- value: true
35
- }), mod);
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
29
  var getMetroConfigFromViteConfig_exports = {};
37
30
  __export(getMetroConfigFromViteConfig_exports, {
38
- buildMetroConfigInputFromViteConfig: () => buildMetroConfigInputFromViteConfig,
39
- getMetroConfigFromViteConfig: () => getMetroConfigFromViteConfig
31
+ buildMetroConfigInputFromViteConfig: () => buildMetroConfigInputFromViteConfig,
32
+ getMetroConfigFromViteConfig: () => getMetroConfigFromViteConfig
40
33
  });
41
34
  module.exports = __toCommonJS(getMetroConfigFromViteConfig_exports);
42
35
  var import_child_process = require("child_process");
43
36
  var import_path = require("path");
44
37
  var import_micromatch = __toESM(require("micromatch"), 1);
38
+ var import_compiler = require("@vxrn/compiler");
45
39
  var import_projectImport = require("../utils/projectImport.native.js");
46
40
  var import_getTerminalReporter = require("../utils/getTerminalReporter.native.js");
47
41
  var import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName = require("../utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js");
48
42
  var WATCHMAN_PROBE_TIMEOUT_MS = 2e3;
49
- var watchmanResponsivePromises = /* @__PURE__ */new Map();
43
+ var watchmanResponsivePromises = /* @__PURE__ */ new Map();
50
44
  var didWarnAboutWatchmanFallback = false;
51
45
  var rootIndexBundleRequestPattern = /^(https?:\/\/[^/]+)?\/index\.bundle(?=$|[?#])/;
52
- var metroWatchExclusions = [/[/\\]dist[/\\](?:static|server)(?:[/\\]|$)/, /[/\\]tests[/\\][^/\\]+[/\\]dist(?:[/\\]|$)/, /[/\\]\.docker(?:[/\\]|$)/, /[/\\]\.vite(?:[/\\]|$)/, /[/\\]node_modules[/\\]\.vxrn(?:[/\\]|$)/];
46
+ var metroWatchExclusions = [
47
+ /[/\\]dist[/\\](?:static|server)(?:[/\\]|$)/,
48
+ /[/\\]tests[/\\][^/\\]+[/\\]dist(?:[/\\]|$)/,
49
+ /[/\\]\.docker(?:[/\\]|$)/,
50
+ /[/\\]\.vite(?:[/\\]|$)/,
51
+ /[/\\]node_modules[/\\]\.vxrn(?:[/\\]|$)/
52
+ ];
53
53
  function getPlatformFromBundleUrl(url) {
54
- var _url_match;
55
- var platform = (_url_match = url.match(/[?&]platform=(ios|android)(?:&|$)/)) === null || _url_match === void 0 ? void 0 : _url_match[1];
56
- return platform === "android" ? "android" : "ios";
54
+ var _url_match;
55
+ var platform = (_url_match = url.match(/[?&]platform=(ios|android)(?:&|$)/)) === null || _url_match === void 0 ? void 0 : _url_match[1];
56
+ return platform === "android" ? "android" : "ios";
57
57
  }
58
58
  function rewriteMainModuleBundleUrl(url, resolveMainModuleName) {
59
- var resolvedMainModulePath = resolveMainModuleName({
60
- platform: getPlatformFromBundleUrl(url)
61
- });
62
- if (url.includes("/.expo/.virtual-metro-entry.bundle?")) {
63
- return url.replace(".expo/.virtual-metro-entry", resolvedMainModulePath);
64
- }
65
- return url.replace(rootIndexBundleRequestPattern, `$1/${resolvedMainModulePath}.bundle`);
59
+ var resolvedMainModulePath = resolveMainModuleName({ platform: getPlatformFromBundleUrl(url) });
60
+ if (url.includes("/.expo/.virtual-metro-entry.bundle?")) {
61
+ return url.replace(".expo/.virtual-metro-entry", resolvedMainModulePath);
62
+ }
63
+ return url.replace(rootIndexBundleRequestPattern, `$1/${resolvedMainModulePath}.bundle`);
66
64
  }
67
65
  async function isWatchmanResponsive(projectRoot) {
68
- var probe = watchmanResponsivePromises.get(projectRoot);
69
- if (probe) {
70
- return probe;
71
- }
72
- probe = new Promise(function (resolve2) {
73
- var settled = false;
74
- var finish = function (value) {
75
- if (settled) return;
76
- settled = true;
77
- clearTimeout(timeout);
78
- resolve2(value);
79
- };
80
- var child = (0, import_child_process.spawn)("watchman", ["watch-project", projectRoot], {
81
- stdio: "ignore"
82
- });
83
- var timeout = setTimeout(function () {
84
- child.kill();
85
- finish(false);
86
- }, WATCHMAN_PROBE_TIMEOUT_MS);
87
- child.once("error", function () {
88
- finish(false);
89
- });
90
- child.once("exit", function (code) {
91
- finish(code === 0);
92
- });
93
- });
94
- watchmanResponsivePromises.set(projectRoot, probe);
95
- return probe;
66
+ var probe = watchmanResponsivePromises.get(projectRoot);
67
+ if (probe) {
68
+ return probe;
69
+ }
70
+ probe = new Promise(function(resolve2) {
71
+ var settled = false;
72
+ var finish = function(value) {
73
+ if (settled) return;
74
+ settled = true;
75
+ clearTimeout(timeout);
76
+ resolve2(value);
77
+ };
78
+ var child = (0, import_child_process.spawn)("watchman", ["watch-project", projectRoot], { stdio: "ignore" });
79
+ var timeout = setTimeout(function() {
80
+ child.kill();
81
+ finish(false);
82
+ }, WATCHMAN_PROBE_TIMEOUT_MS);
83
+ child.once("error", function() {
84
+ finish(false);
85
+ });
86
+ child.once("exit", function(code) {
87
+ finish(code === 0);
88
+ });
89
+ });
90
+ watchmanResponsivePromises.set(projectRoot, probe);
91
+ return probe;
92
+ }
93
+ function resolveNativeTransforms(projectRoot, metroPluginOptions) {
94
+ var userBabelConfigPath = projectRoot ? (0, import_compiler.findUserBabelConfig)(projectRoot) : null;
95
+ var hasUserBabelConfig = Boolean(userBabelConfigPath);
96
+ var isNativeTransforms = process.env.ONE_METRO_NATIVE_TRANSFORMS === "0" ? false : process.env.ONE_METRO_NATIVE_TRANSFORMS === "1" ? true : metroPluginOptions.nativeTransforms === false ? false : metroPluginOptions.nativeTransforms === true ? true : hasUserBabelConfig ? false : true;
97
+ if (userBabelConfigPath && isNativeTransforms) {
98
+ console.warn(`[vxrn/metro] Ignoring user babel config at ${userBabelConfigPath} because native transforms are explicitly enabled (nativeTransforms: true or ONE_METRO_NATIVE_TRANSFORMS=1). Port its plugins to nativeTransformModules, or set nativeTransforms: false (or ONE_METRO_NATIVE_TRANSFORMS=0) to use the babel transformer.`);
99
+ }
100
+ return {
101
+ isNativeTransforms,
102
+ userBabelConfigPath
103
+ };
96
104
  }
97
105
  async function buildMetroConfigInputFromViteConfig(config, metroPluginOptions) {
98
- var _ref;
99
- var _metroPluginOptions_argv, _defaultConfig_resolver;
100
- var extraConfig = {};
101
- var projectRoot = (0, import_path.resolve)((_ref = (_metroPluginOptions_argv = metroPluginOptions.argv) === null || _metroPluginOptions_argv === void 0 ? void 0 : _metroPluginOptions_argv.projectRoot) !== null && _ref !== void 0 ? _ref : config.root);
102
- var {
103
- mainModuleName,
104
- defaultConfigOverrides,
105
- watchman,
106
- excludeModules
107
- } = metroPluginOptions;
108
- var useWatchman = watchman !== null && watchman !== void 0 ? watchman : await isWatchmanResponsive(projectRoot);
109
- if (watchman === void 0 && !useWatchman && !didWarnAboutWatchmanFallback) {
110
- didWarnAboutWatchmanFallback = true;
111
- console.warn("[vxrn/metro] Watchman is unavailable or unresponsive; falling back to Node file watching.");
112
- }
113
- var {
114
- getDefaultConfig
115
- } = await (0, import_projectImport.projectImport)(projectRoot, "@expo/metro-config");
116
- var _defaultConfig = getDefaultConfig(projectRoot);
117
- if (mainModuleName) {
118
- var origRewriteRequestUrl = _defaultConfig.server.rewriteRequestUrl;
119
- var resolveMainModuleName = await async function () {
120
- var ExpoGoManifestHandlerMiddleware = (await (0, import_projectImport.projectImport)(projectRoot, "@expo/cli/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js")).default.ExpoGoManifestHandlerMiddleware;
121
- var manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(projectRoot, {});
122
- (0, import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName)(manifestHandlerMiddleware, mainModuleName);
123
- return function (p) {
124
- return manifestHandlerMiddleware.resolveMainModuleName({
125
- pkg: {
126
- main: mainModuleName
127
- },
128
- platform: p.platform
129
- });
130
- };
131
- }();
132
- extraConfig.getResolveMainModuleName = resolveMainModuleName;
133
- _defaultConfig.server.rewriteRequestUrl = function (url) {
134
- if (url.includes("/.expo/.virtual-metro-entry.bundle?") || rootIndexBundleRequestPattern.test(url)) {
135
- return rewriteMainModuleBundleUrl(url, resolveMainModuleName);
136
- }
137
- return origRewriteRequestUrl(url);
138
- };
139
- }
140
- var existingBlockList = _defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver = _defaultConfig.resolver) === null || _defaultConfig_resolver === void 0 ? void 0 : _defaultConfig_resolver.blockList;
141
- var blockList = [...(existingBlockList ? Array.isArray(existingBlockList) ? existingBlockList : [existingBlockList] : []), ...metroWatchExclusions];
142
- var isNativeTransforms = process.env.ONE_METRO_NATIVE_TRANSFORMS === "0" ? false : process.env.ONE_METRO_NATIVE_TRANSFORMS === "1" || metroPluginOptions.nativeTransforms !== false;
143
- var nativeWorkerPath;
144
- if (isNativeTransforms) {
145
- nativeWorkerPath = (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/transformer/metroNativeWorker");
146
- }
147
- var defaultConfig = {
148
- ..._defaultConfig,
149
- resolver: {
150
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.resolver),
151
- useWatchman,
152
- blockList,
153
- sourceExts: ["js", "jsx", "json", "ts", "tsx", "mjs", "cjs"],
154
- // `one` related packages are using `.mjs` extensions. This fixes `.native` files not being resolved correctly when `.mjs` files are present.
155
- resolveRequest: function (context, moduleName, platform) {
156
- var _defaultConfig_resolver2;
157
- var origResolveRequestFn = (_defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver2 = _defaultConfig.resolver) === null || _defaultConfig_resolver2 === void 0 ? void 0 : _defaultConfig_resolver2.resolveRequest) || context.resolveRequest;
158
- if (excludeModules && excludeModules.length > 0) {
159
- if (import_micromatch.default.isMatch(moduleName, excludeModules)) {
160
- return origResolveRequestFn(context, "@vxrn/vite-plugin-metro/empty", platform);
161
- }
162
- }
163
- if (moduleName.startsWith("@babel/runtime")) {
164
- var contextOverride = {
165
- ...context,
166
- unstable_conditionNames: context.unstable_conditionNames.filter(function (c) {
167
- return c !== "import";
168
- })
169
- };
170
- return origResolveRequestFn(contextOverride, moduleName, platform);
171
- }
172
- return origResolveRequestFn(context, moduleName, platform);
173
- }
174
- },
175
- transformer: {
176
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.transformer),
177
- babelTransformerPath: (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/babel-transformer")
178
- },
179
- // transformerPath is a TOP-LEVEL metro config key, not a transformer option.
180
- // nesting it under transformer silently leaves metro on its default worker.
181
- ...(nativeWorkerPath ? {
182
- transformerPath: nativeWorkerPath
183
- } : {}),
184
- reporter: await (0, import_getTerminalReporter.getTerminalReporter)(projectRoot)
185
- };
186
- var merged = {
187
- ...defaultConfig,
188
- ...(typeof defaultConfigOverrides === "function" ? defaultConfigOverrides(defaultConfig) : defaultConfigOverrides)
189
- };
190
- return {
191
- defaultConfig: merged,
192
- projectRoot,
193
- extraConfig
194
- };
106
+ var _ref;
107
+ var _metroPluginOptions_argv, _defaultConfig_resolver;
108
+ var extraConfig = {};
109
+ var projectRoot = (0, import_path.resolve)((_ref = (_metroPluginOptions_argv = metroPluginOptions.argv) === null || _metroPluginOptions_argv === void 0 ? void 0 : _metroPluginOptions_argv.projectRoot) !== null && _ref !== void 0 ? _ref : config.root);
110
+ var { mainModuleName, defaultConfigOverrides, watchman, excludeModules } = metroPluginOptions;
111
+ var useWatchman = watchman !== null && watchman !== void 0 ? watchman : await isWatchmanResponsive(projectRoot);
112
+ if (watchman === void 0 && !useWatchman && !didWarnAboutWatchmanFallback) {
113
+ didWarnAboutWatchmanFallback = true;
114
+ console.warn("[vxrn/metro] Watchman is unavailable or unresponsive; falling back to Node file watching.");
115
+ }
116
+ var { getDefaultConfig } = await (0, import_projectImport.projectImport)(projectRoot, "@expo/metro-config");
117
+ var _defaultConfig = getDefaultConfig(projectRoot);
118
+ if (mainModuleName) {
119
+ var origRewriteRequestUrl = _defaultConfig.server.rewriteRequestUrl;
120
+ var resolveMainModuleName = await (async function() {
121
+ var ExpoGoManifestHandlerMiddleware = (await (0, import_projectImport.projectImport)(projectRoot, "@expo/cli/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js")).default.ExpoGoManifestHandlerMiddleware;
122
+ var manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(projectRoot, {});
123
+ (0, import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName)(manifestHandlerMiddleware, mainModuleName);
124
+ return function(p) {
125
+ return manifestHandlerMiddleware.resolveMainModuleName({
126
+ pkg: { main: mainModuleName },
127
+ platform: p.platform
128
+ });
129
+ };
130
+ })();
131
+ extraConfig.getResolveMainModuleName = resolveMainModuleName;
132
+ _defaultConfig.server.rewriteRequestUrl = function(url) {
133
+ if (url.includes("/.expo/.virtual-metro-entry.bundle?") || rootIndexBundleRequestPattern.test(url)) {
134
+ return rewriteMainModuleBundleUrl(url, resolveMainModuleName);
135
+ }
136
+ return origRewriteRequestUrl(url);
137
+ };
138
+ }
139
+ var existingBlockList = _defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver = _defaultConfig.resolver) === null || _defaultConfig_resolver === void 0 ? void 0 : _defaultConfig_resolver.blockList;
140
+ var blockList = [...existingBlockList ? Array.isArray(existingBlockList) ? existingBlockList : [existingBlockList] : [], ...metroWatchExclusions];
141
+ var { isNativeTransforms } = resolveNativeTransforms(projectRoot, metroPluginOptions);
142
+ var nativeWorkerPath;
143
+ if (isNativeTransforms) {
144
+ nativeWorkerPath = (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/transformer/metroNativeWorker");
145
+ }
146
+ var defaultConfig = {
147
+ ..._defaultConfig,
148
+ resolver: {
149
+ ..._defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.resolver,
150
+ useWatchman,
151
+ blockList,
152
+ sourceExts: [
153
+ "js",
154
+ "jsx",
155
+ "json",
156
+ "ts",
157
+ "tsx",
158
+ "mjs",
159
+ "cjs"
160
+ ],
161
+ resolveRequest: function(context, moduleName, platform) {
162
+ var _defaultConfig_resolver2;
163
+ var origResolveRequestFn = (_defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver2 = _defaultConfig.resolver) === null || _defaultConfig_resolver2 === void 0 ? void 0 : _defaultConfig_resolver2.resolveRequest) || context.resolveRequest;
164
+ if (excludeModules && excludeModules.length > 0) {
165
+ if (import_micromatch.default.isMatch(moduleName, excludeModules)) {
166
+ return origResolveRequestFn(context, "@vxrn/vite-plugin-metro/empty", platform);
167
+ }
168
+ }
169
+ if (moduleName.startsWith("@babel/runtime")) {
170
+ var contextOverride = {
171
+ ...context,
172
+ unstable_conditionNames: context.unstable_conditionNames.filter(function(c) {
173
+ return c !== "import";
174
+ })
175
+ };
176
+ return origResolveRequestFn(contextOverride, moduleName, platform);
177
+ }
178
+ return origResolveRequestFn(context, moduleName, platform);
179
+ }
180
+ },
181
+ transformer: {
182
+ ..._defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.transformer,
183
+ babelTransformerPath: (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/babel-transformer")
184
+ },
185
+ ...nativeWorkerPath ? { transformerPath: nativeWorkerPath } : {},
186
+ reporter: await (0, import_getTerminalReporter.getTerminalReporter)(projectRoot)
187
+ };
188
+ var merged = {
189
+ ...defaultConfig,
190
+ ...typeof defaultConfigOverrides === "function" ? defaultConfigOverrides(defaultConfig) : defaultConfigOverrides
191
+ };
192
+ return {
193
+ defaultConfig: merged,
194
+ projectRoot,
195
+ extraConfig
196
+ };
195
197
  }
196
198
  async function getMetroConfigFromViteConfig(config, metroPluginOptions) {
197
- var _ref;
198
- var _metroPluginOptions_argv, _defaultConfig_resolver;
199
- var extraConfig = {};
200
- var projectRoot = (0, import_path.resolve)((_ref = (_metroPluginOptions_argv = metroPluginOptions.argv) === null || _metroPluginOptions_argv === void 0 ? void 0 : _metroPluginOptions_argv.projectRoot) !== null && _ref !== void 0 ? _ref : config.root);
201
- var {
202
- mainModuleName,
203
- argv,
204
- defaultConfigOverrides,
205
- watchman,
206
- excludeModules
207
- } = metroPluginOptions;
208
- var useWatchman = watchman !== null && watchman !== void 0 ? watchman : await isWatchmanResponsive(projectRoot);
209
- if (watchman === void 0 && !useWatchman && !didWarnAboutWatchmanFallback) {
210
- didWarnAboutWatchmanFallback = true;
211
- console.warn("[vxrn/metro] Watchman is unavailable or unresponsive; falling back to Node file watching.");
212
- }
213
- var {
214
- loadConfig
215
- } = await (0, import_projectImport.projectImport)(projectRoot, "metro");
216
- var {
217
- getDefaultConfig
218
- } = await (0, import_projectImport.projectImport)(projectRoot, "@expo/metro-config");
219
- var _defaultConfig = getDefaultConfig(projectRoot);
220
- if (mainModuleName) {
221
- var origRewriteRequestUrl = _defaultConfig.server.rewriteRequestUrl;
222
- var resolveMainModuleName = await async function () {
223
- var ExpoGoManifestHandlerMiddleware = (await (0, import_projectImport.projectImport)(projectRoot, "@expo/cli/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js")).default.ExpoGoManifestHandlerMiddleware;
224
- var manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(projectRoot, {});
225
- (0, import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName)(manifestHandlerMiddleware, mainModuleName);
226
- return function (p) {
227
- return manifestHandlerMiddleware.resolveMainModuleName({
228
- pkg: {
229
- main: mainModuleName
230
- },
231
- platform: p.platform
232
- });
233
- };
234
- }();
235
- extraConfig.getResolveMainModuleName = resolveMainModuleName;
236
- _defaultConfig.server.rewriteRequestUrl = function (url) {
237
- if (url.includes("/.expo/.virtual-metro-entry.bundle?") || rootIndexBundleRequestPattern.test(url)) {
238
- return rewriteMainModuleBundleUrl(url, resolveMainModuleName);
239
- }
240
- return origRewriteRequestUrl(url);
241
- };
242
- }
243
- var existingBlockList = _defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver = _defaultConfig.resolver) === null || _defaultConfig_resolver === void 0 ? void 0 : _defaultConfig_resolver.blockList;
244
- var blockList = [...(existingBlockList ? Array.isArray(existingBlockList) ? existingBlockList : [existingBlockList] : []), ...metroWatchExclusions];
245
- var isNativeTransforms = process.env.ONE_METRO_NATIVE_TRANSFORMS === "0" ? false : process.env.ONE_METRO_NATIVE_TRANSFORMS === "1" || metroPluginOptions.nativeTransforms !== false;
246
- var nativeWorkerPath;
247
- if (isNativeTransforms) {
248
- nativeWorkerPath = (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/transformer/metroNativeWorker");
249
- }
250
- var defaultConfig = {
251
- ..._defaultConfig,
252
- resolver: {
253
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.resolver),
254
- useWatchman,
255
- blockList,
256
- sourceExts: ["js", "jsx", "json", "ts", "tsx", "mjs", "cjs"],
257
- // `one` related packages are using `.mjs` extensions. This somehow fixes `.native` files not being resolved correctly when `.mjs` files are present.
258
- resolveRequest: function (context, moduleName, platform) {
259
- var _defaultConfig_resolver2;
260
- var origResolveRequestFn = (_defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver2 = _defaultConfig.resolver) === null || _defaultConfig_resolver2 === void 0 ? void 0 : _defaultConfig_resolver2.resolveRequest) || context.resolveRequest;
261
- if (excludeModules && excludeModules.length > 0) {
262
- if (import_micromatch.default.isMatch(moduleName, excludeModules)) {
263
- return origResolveRequestFn(context, "@vxrn/vite-plugin-metro/empty", platform);
264
- }
265
- }
266
- if (moduleName.startsWith("@babel/runtime")) {
267
- var contextOverride = {
268
- ...context,
269
- unstable_conditionNames: context.unstable_conditionNames.filter(function (c) {
270
- return c !== "import";
271
- })
272
- };
273
- return origResolveRequestFn(contextOverride, moduleName, platform);
274
- }
275
- return origResolveRequestFn(context, moduleName, platform);
276
- }
277
- },
278
- transformer: {
279
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.transformer),
280
- babelTransformerPath: (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/babel-transformer")
281
- },
282
- // transformerPath is a TOP-LEVEL metro config key, not a transformer option.
283
- // nesting it under transformer silently leaves metro on its default worker.
284
- ...(nativeWorkerPath ? {
285
- transformerPath: nativeWorkerPath
286
- } : {}),
287
- reporter: await (0, import_getTerminalReporter.getTerminalReporter)(projectRoot)
288
- };
289
- var metroConfig = await loadConfig({
290
- cwd: projectRoot,
291
- projectRoot,
292
- "reset-cache": !!process.env.METRO_RESET_CACHE,
293
- ...argv
294
- }, {
295
- ...defaultConfig,
296
- ...(typeof defaultConfigOverrides === "function" ? defaultConfigOverrides(defaultConfig) : defaultConfigOverrides)
297
- });
298
- return {
299
- ...metroConfig,
300
- ...extraConfig
301
- };
199
+ var _ref;
200
+ var _metroPluginOptions_argv, _defaultConfig_resolver;
201
+ var extraConfig = {};
202
+ var projectRoot = (0, import_path.resolve)((_ref = (_metroPluginOptions_argv = metroPluginOptions.argv) === null || _metroPluginOptions_argv === void 0 ? void 0 : _metroPluginOptions_argv.projectRoot) !== null && _ref !== void 0 ? _ref : config.root);
203
+ var { mainModuleName, argv, defaultConfigOverrides, watchman, excludeModules } = metroPluginOptions;
204
+ var useWatchman = watchman !== null && watchman !== void 0 ? watchman : await isWatchmanResponsive(projectRoot);
205
+ if (watchman === void 0 && !useWatchman && !didWarnAboutWatchmanFallback) {
206
+ didWarnAboutWatchmanFallback = true;
207
+ console.warn("[vxrn/metro] Watchman is unavailable or unresponsive; falling back to Node file watching.");
208
+ }
209
+ var { loadConfig } = await (0, import_projectImport.projectImport)(projectRoot, "metro");
210
+ var { getDefaultConfig } = await (0, import_projectImport.projectImport)(projectRoot, "@expo/metro-config");
211
+ var _defaultConfig = getDefaultConfig(projectRoot);
212
+ if (mainModuleName) {
213
+ var origRewriteRequestUrl = _defaultConfig.server.rewriteRequestUrl;
214
+ var resolveMainModuleName = await (async function() {
215
+ var ExpoGoManifestHandlerMiddleware = (await (0, import_projectImport.projectImport)(projectRoot, "@expo/cli/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js")).default.ExpoGoManifestHandlerMiddleware;
216
+ var manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(projectRoot, {});
217
+ (0, import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName)(manifestHandlerMiddleware, mainModuleName);
218
+ return function(p) {
219
+ return manifestHandlerMiddleware.resolveMainModuleName({
220
+ pkg: { main: mainModuleName },
221
+ platform: p.platform
222
+ });
223
+ };
224
+ })();
225
+ extraConfig.getResolveMainModuleName = resolveMainModuleName;
226
+ _defaultConfig.server.rewriteRequestUrl = function(url) {
227
+ if (url.includes("/.expo/.virtual-metro-entry.bundle?") || rootIndexBundleRequestPattern.test(url)) {
228
+ return rewriteMainModuleBundleUrl(url, resolveMainModuleName);
229
+ }
230
+ return origRewriteRequestUrl(url);
231
+ };
232
+ }
233
+ var existingBlockList = _defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver = _defaultConfig.resolver) === null || _defaultConfig_resolver === void 0 ? void 0 : _defaultConfig_resolver.blockList;
234
+ var blockList = [...existingBlockList ? Array.isArray(existingBlockList) ? existingBlockList : [existingBlockList] : [], ...metroWatchExclusions];
235
+ var { isNativeTransforms } = resolveNativeTransforms(projectRoot, metroPluginOptions);
236
+ var nativeWorkerPath;
237
+ if (isNativeTransforms) {
238
+ nativeWorkerPath = (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/transformer/metroNativeWorker");
239
+ }
240
+ var defaultConfig = {
241
+ ..._defaultConfig,
242
+ resolver: {
243
+ ..._defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.resolver,
244
+ useWatchman,
245
+ blockList,
246
+ sourceExts: [
247
+ "js",
248
+ "jsx",
249
+ "json",
250
+ "ts",
251
+ "tsx",
252
+ "mjs",
253
+ "cjs"
254
+ ],
255
+ resolveRequest: function(context, moduleName, platform) {
256
+ var _defaultConfig_resolver2;
257
+ var origResolveRequestFn = (_defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver2 = _defaultConfig.resolver) === null || _defaultConfig_resolver2 === void 0 ? void 0 : _defaultConfig_resolver2.resolveRequest) || context.resolveRequest;
258
+ if (excludeModules && excludeModules.length > 0) {
259
+ if (import_micromatch.default.isMatch(moduleName, excludeModules)) {
260
+ return origResolveRequestFn(context, "@vxrn/vite-plugin-metro/empty", platform);
261
+ }
262
+ }
263
+ if (moduleName.startsWith("@babel/runtime")) {
264
+ var contextOverride = {
265
+ ...context,
266
+ unstable_conditionNames: context.unstable_conditionNames.filter(function(c) {
267
+ return c !== "import";
268
+ })
269
+ };
270
+ return origResolveRequestFn(contextOverride, moduleName, platform);
271
+ }
272
+ return origResolveRequestFn(context, moduleName, platform);
273
+ }
274
+ },
275
+ transformer: {
276
+ ..._defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.transformer,
277
+ babelTransformerPath: (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/babel-transformer")
278
+ },
279
+ ...nativeWorkerPath ? { transformerPath: nativeWorkerPath } : {},
280
+ reporter: await (0, import_getTerminalReporter.getTerminalReporter)(projectRoot)
281
+ };
282
+ var metroConfig = await loadConfig({
283
+ cwd: projectRoot,
284
+ projectRoot,
285
+ "reset-cache": !!process.env.METRO_RESET_CACHE,
286
+ ...argv
287
+ }, {
288
+ ...defaultConfig,
289
+ ...typeof defaultConfigOverrides === "function" ? defaultConfigOverrides(defaultConfig) : defaultConfigOverrides
290
+ });
291
+ return {
292
+ ...metroConfig,
293
+ ...extraConfig
294
+ };
302
295
  }
296
+
303
297
  //# sourceMappingURL=getMetroConfigFromViteConfig.native.js.map