@vxrn/vite-plugin-metro 1.27.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 (288) 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 +246 -271
  18. package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.cjs +295 -0
  19. package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.js +257 -281
  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 +230 -246
  145. package/dist/esm/metro-config/getMetroConfigFromViteConfig.mjs.map +1 -1
  146. package/dist/esm/metro-config/getMetroConfigFromViteConfig.native.js +241 -257
  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 +11 -18
  246. package/src/transformer/metroNativeWorker.test.ts +110 -49
  247. package/src/transformer/metroNativeWorker.ts +3 -11
  248. package/types/babel-plugins/import-meta-env-plugin.d.ts.map +1 -1
  249. package/types/metro-config/getMetroConfigFromViteConfig.d.ts.map +1 -1
  250. package/types/rn-commands/bundle/assetPathUtils.d.ts.map +1 -1
  251. package/types/rn-commands/bundle/filterPlatformAssetScales.d.ts.map +1 -1
  252. package/types/rn-commands/bundle/getAssetDestPathAndroid.d.ts.map +1 -1
  253. package/types/rn-commands/bundle/getAssetDestPathIOS.d.ts.map +1 -1
  254. package/types/rn-commands/bundle/saveAssets.d.ts.map +1 -1
  255. package/types/transformer/metroNativeWorker.d.ts.map +1 -1
  256. package/dist/cjs/transformer/metroNativeWorker.test.cjs +0 -1054
  257. package/dist/cjs/transformer/metroNativeWorker.test.native.js +0 -1170
  258. package/dist/cjs/transformer/metroNativeWorker.test.native.js.map +0 -1
  259. package/dist/cjs/transformer/transformSync.test.cjs +0 -36
  260. package/dist/cjs/transformer/transformSync.test.native.js +0 -49
  261. package/dist/cjs/transformer/transformSync.test.native.js.map +0 -1
  262. package/dist/esm/index.js.map +0 -1
  263. package/dist/esm/index.mjs.map +0 -1
  264. package/dist/esm/index.native.js.map +0 -1
  265. package/dist/esm/metro-config/types.mjs.map +0 -1
  266. package/dist/esm/metro-config/types.native.js.map +0 -1
  267. package/dist/esm/rn-commands/bundle/index.mjs.map +0 -1
  268. package/dist/esm/rn-commands/bundle/index.native.js.map +0 -1
  269. package/dist/esm/rn-commands/bundle/types.mjs.map +0 -1
  270. package/dist/esm/rn-commands/bundle/types.native.js.map +0 -1
  271. package/dist/esm/rn-commands/index.mjs.map +0 -1
  272. package/dist/esm/rn-commands/index.native.js.map +0 -1
  273. package/dist/esm/transformer/babel-core.mjs.map +0 -1
  274. package/dist/esm/transformer/babel-core.native.js.map +0 -1
  275. package/dist/esm/transformer/metroNativeWorker.test.mjs +0 -1010
  276. package/dist/esm/transformer/metroNativeWorker.test.mjs.map +0 -1
  277. package/dist/esm/transformer/metroNativeWorker.test.native.js +0 -1124
  278. package/dist/esm/transformer/metroNativeWorker.test.native.js.map +0 -1
  279. package/dist/esm/transformer/transformSync.test.mjs +0 -37
  280. package/dist/esm/transformer/transformSync.test.mjs.map +0 -1
  281. package/dist/esm/transformer/transformSync.test.native.js +0 -47
  282. package/dist/esm/transformer/transformSync.test.native.js.map +0 -1
  283. package/dist/esm/transformer/types.mjs.map +0 -1
  284. package/dist/esm/transformer/types.native.js.map +0 -1
  285. package/types/transformer/metroNativeWorker.test.d.ts +0 -2
  286. package/types/transformer/metroNativeWorker.test.d.ts.map +0 -1
  287. package/types/transformer/transformSync.test.d.ts +0 -2
  288. package/types/transformer/transformSync.test.d.ts.map +0 -1
@@ -7,36 +7,29 @@ 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");
@@ -47,275 +40,258 @@ var import_projectImport = require("../utils/projectImport.native.js");
47
40
  var import_getTerminalReporter = require("../utils/getTerminalReporter.native.js");
48
41
  var import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName = require("../utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js");
49
42
  var WATCHMAN_PROBE_TIMEOUT_MS = 2e3;
50
- var watchmanResponsivePromises = /* @__PURE__ */new Map();
43
+ var watchmanResponsivePromises = /* @__PURE__ */ new Map();
51
44
  var didWarnAboutWatchmanFallback = false;
52
45
  var rootIndexBundleRequestPattern = /^(https?:\/\/[^/]+)?\/index\.bundle(?=$|[?#])/;
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;
96
92
  }
97
93
  function resolveNativeTransforms(projectRoot, metroPluginOptions) {
98
- var userBabelConfigPath = projectRoot ? (0, import_compiler.findUserBabelConfig)(projectRoot) : null;
99
- var hasUserBabelConfig = Boolean(userBabelConfigPath);
100
- 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;
101
- if (userBabelConfigPath && isNativeTransforms) {
102
- 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.`);
103
- }
104
- return {
105
- isNativeTransforms,
106
- userBabelConfigPath
107
- };
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
+ };
108
104
  }
109
105
  async function buildMetroConfigInputFromViteConfig(config, metroPluginOptions) {
110
- var _ref;
111
- var _metroPluginOptions_argv, _defaultConfig_resolver;
112
- var extraConfig = {};
113
- 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);
114
- var {
115
- mainModuleName,
116
- defaultConfigOverrides,
117
- watchman,
118
- excludeModules
119
- } = metroPluginOptions;
120
- var useWatchman = watchman !== null && watchman !== void 0 ? watchman : await isWatchmanResponsive(projectRoot);
121
- if (watchman === void 0 && !useWatchman && !didWarnAboutWatchmanFallback) {
122
- didWarnAboutWatchmanFallback = true;
123
- console.warn("[vxrn/metro] Watchman is unavailable or unresponsive; falling back to Node file watching.");
124
- }
125
- var {
126
- getDefaultConfig
127
- } = await (0, import_projectImport.projectImport)(projectRoot, "@expo/metro-config");
128
- var _defaultConfig = getDefaultConfig(projectRoot);
129
- if (mainModuleName) {
130
- var origRewriteRequestUrl = _defaultConfig.server.rewriteRequestUrl;
131
- var resolveMainModuleName = await async function () {
132
- var ExpoGoManifestHandlerMiddleware = (await (0, import_projectImport.projectImport)(projectRoot, "@expo/cli/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js")).default.ExpoGoManifestHandlerMiddleware;
133
- var manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(projectRoot, {});
134
- (0, import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName)(manifestHandlerMiddleware, mainModuleName);
135
- return function (p) {
136
- return manifestHandlerMiddleware.resolveMainModuleName({
137
- pkg: {
138
- main: mainModuleName
139
- },
140
- platform: p.platform
141
- });
142
- };
143
- }();
144
- extraConfig.getResolveMainModuleName = resolveMainModuleName;
145
- _defaultConfig.server.rewriteRequestUrl = function (url) {
146
- if (url.includes("/.expo/.virtual-metro-entry.bundle?") || rootIndexBundleRequestPattern.test(url)) {
147
- return rewriteMainModuleBundleUrl(url, resolveMainModuleName);
148
- }
149
- return origRewriteRequestUrl(url);
150
- };
151
- }
152
- var existingBlockList = _defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver = _defaultConfig.resolver) === null || _defaultConfig_resolver === void 0 ? void 0 : _defaultConfig_resolver.blockList;
153
- var buildOutputExclusions = [/[/\\]dist[/\\](?:static|server)(?:[/\\]|$)/, /[/\\]tests[/\\][^/\\]+[/\\]dist(?:[/\\]|$)/, /[/\\]\.docker(?:[/\\]|$)/, /[/\\]\.vite(?:[/\\]|$)/];
154
- var blockList = [...(existingBlockList ? Array.isArray(existingBlockList) ? existingBlockList : [existingBlockList] : []), ...buildOutputExclusions];
155
- var {
156
- isNativeTransforms
157
- } = resolveNativeTransforms(projectRoot, metroPluginOptions);
158
- var nativeWorkerPath;
159
- if (isNativeTransforms) {
160
- nativeWorkerPath = (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/transformer/metroNativeWorker");
161
- }
162
- var defaultConfig = {
163
- ..._defaultConfig,
164
- resolver: {
165
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.resolver),
166
- useWatchman,
167
- blockList,
168
- sourceExts: ["js", "jsx", "json", "ts", "tsx", "mjs", "cjs"],
169
- // `one` related packages are using `.mjs` extensions. This fixes `.native` files not being resolved correctly when `.mjs` files are present.
170
- resolveRequest: function (context, moduleName, platform) {
171
- var _defaultConfig_resolver2;
172
- 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;
173
- if (excludeModules && excludeModules.length > 0) {
174
- if (import_micromatch.default.isMatch(moduleName, excludeModules)) {
175
- return origResolveRequestFn(context, "@vxrn/vite-plugin-metro/empty", platform);
176
- }
177
- }
178
- if (moduleName.startsWith("@babel/runtime")) {
179
- var contextOverride = {
180
- ...context,
181
- unstable_conditionNames: context.unstable_conditionNames.filter(function (c) {
182
- return c !== "import";
183
- })
184
- };
185
- return origResolveRequestFn(contextOverride, moduleName, platform);
186
- }
187
- return origResolveRequestFn(context, moduleName, platform);
188
- }
189
- },
190
- transformer: {
191
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.transformer),
192
- babelTransformerPath: (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/babel-transformer")
193
- },
194
- // transformerPath is a TOP-LEVEL metro config key, not a transformer option.
195
- // nesting it under transformer silently leaves metro on its default worker.
196
- ...(nativeWorkerPath ? {
197
- transformerPath: nativeWorkerPath
198
- } : {}),
199
- reporter: await (0, import_getTerminalReporter.getTerminalReporter)(projectRoot)
200
- };
201
- var merged = {
202
- ...defaultConfig,
203
- ...(typeof defaultConfigOverrides === "function" ? defaultConfigOverrides(defaultConfig) : defaultConfigOverrides)
204
- };
205
- return {
206
- defaultConfig: merged,
207
- projectRoot,
208
- extraConfig
209
- };
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
+ };
210
197
  }
211
198
  async function getMetroConfigFromViteConfig(config, metroPluginOptions) {
212
- var _ref;
213
- var _metroPluginOptions_argv, _defaultConfig_resolver;
214
- var extraConfig = {};
215
- 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);
216
- var {
217
- mainModuleName,
218
- argv,
219
- defaultConfigOverrides,
220
- watchman,
221
- excludeModules
222
- } = metroPluginOptions;
223
- var useWatchman = watchman !== null && watchman !== void 0 ? watchman : await isWatchmanResponsive(projectRoot);
224
- if (watchman === void 0 && !useWatchman && !didWarnAboutWatchmanFallback) {
225
- didWarnAboutWatchmanFallback = true;
226
- console.warn("[vxrn/metro] Watchman is unavailable or unresponsive; falling back to Node file watching.");
227
- }
228
- var {
229
- loadConfig
230
- } = await (0, import_projectImport.projectImport)(projectRoot, "metro");
231
- var {
232
- getDefaultConfig
233
- } = await (0, import_projectImport.projectImport)(projectRoot, "@expo/metro-config");
234
- var _defaultConfig = getDefaultConfig(projectRoot);
235
- if (mainModuleName) {
236
- var origRewriteRequestUrl = _defaultConfig.server.rewriteRequestUrl;
237
- var resolveMainModuleName = await async function () {
238
- var ExpoGoManifestHandlerMiddleware = (await (0, import_projectImport.projectImport)(projectRoot, "@expo/cli/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js")).default.ExpoGoManifestHandlerMiddleware;
239
- var manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(projectRoot, {});
240
- (0, import_patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName)(manifestHandlerMiddleware, mainModuleName);
241
- return function (p) {
242
- return manifestHandlerMiddleware.resolveMainModuleName({
243
- pkg: {
244
- main: mainModuleName
245
- },
246
- platform: p.platform
247
- });
248
- };
249
- }();
250
- extraConfig.getResolveMainModuleName = resolveMainModuleName;
251
- _defaultConfig.server.rewriteRequestUrl = function (url) {
252
- if (url.includes("/.expo/.virtual-metro-entry.bundle?") || rootIndexBundleRequestPattern.test(url)) {
253
- return rewriteMainModuleBundleUrl(url, resolveMainModuleName);
254
- }
255
- return origRewriteRequestUrl(url);
256
- };
257
- }
258
- var existingBlockList = _defaultConfig === null || _defaultConfig === void 0 ? void 0 : (_defaultConfig_resolver = _defaultConfig.resolver) === null || _defaultConfig_resolver === void 0 ? void 0 : _defaultConfig_resolver.blockList;
259
- var buildOutputExclusions = [/[/\\]dist[/\\](?:static|server)(?:[/\\]|$)/, /[/\\]tests[/\\][^/\\]+[/\\]dist(?:[/\\]|$)/, /[/\\]\.docker(?:[/\\]|$)/, /[/\\]\.vite(?:[/\\]|$)/];
260
- var blockList = [...(existingBlockList ? Array.isArray(existingBlockList) ? existingBlockList : [existingBlockList] : []), ...buildOutputExclusions];
261
- var {
262
- isNativeTransforms
263
- } = resolveNativeTransforms(projectRoot, metroPluginOptions);
264
- var nativeWorkerPath;
265
- if (isNativeTransforms) {
266
- nativeWorkerPath = (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/transformer/metroNativeWorker");
267
- }
268
- var defaultConfig = {
269
- ..._defaultConfig,
270
- resolver: {
271
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.resolver),
272
- useWatchman,
273
- blockList,
274
- sourceExts: ["js", "jsx", "json", "ts", "tsx", "mjs", "cjs"],
275
- // `one` related packages are using `.mjs` extensions. This somehow fixes `.native` files not being resolved correctly when `.mjs` files are present.
276
- resolveRequest: function (context, moduleName, platform) {
277
- var _defaultConfig_resolver2;
278
- 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;
279
- if (excludeModules && excludeModules.length > 0) {
280
- if (import_micromatch.default.isMatch(moduleName, excludeModules)) {
281
- return origResolveRequestFn(context, "@vxrn/vite-plugin-metro/empty", platform);
282
- }
283
- }
284
- if (moduleName.startsWith("@babel/runtime")) {
285
- var contextOverride = {
286
- ...context,
287
- unstable_conditionNames: context.unstable_conditionNames.filter(function (c) {
288
- return c !== "import";
289
- })
290
- };
291
- return origResolveRequestFn(contextOverride, moduleName, platform);
292
- }
293
- return origResolveRequestFn(context, moduleName, platform);
294
- }
295
- },
296
- transformer: {
297
- ...(_defaultConfig === null || _defaultConfig === void 0 ? void 0 : _defaultConfig.transformer),
298
- babelTransformerPath: (0, import_projectImport.projectResolve)(projectRoot, "@vxrn/vite-plugin-metro/babel-transformer")
299
- },
300
- // transformerPath is a TOP-LEVEL metro config key, not a transformer option.
301
- // nesting it under transformer silently leaves metro on its default worker.
302
- ...(nativeWorkerPath ? {
303
- transformerPath: nativeWorkerPath
304
- } : {}),
305
- reporter: await (0, import_getTerminalReporter.getTerminalReporter)(projectRoot)
306
- };
307
- var metroConfig = await loadConfig({
308
- cwd: projectRoot,
309
- projectRoot,
310
- "reset-cache": !!process.env.METRO_RESET_CACHE,
311
- ...argv
312
- }, {
313
- ...defaultConfig,
314
- ...(typeof defaultConfigOverrides === "function" ? defaultConfigOverrides(defaultConfig) : defaultConfigOverrides)
315
- });
316
- return {
317
- ...metroConfig,
318
- ...extraConfig
319
- };
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
+ };
320
295
  }
296
+
321
297
  //# sourceMappingURL=getMetroConfigFromViteConfig.native.js.map