@tellahq/rescript 10.1.0-alpha.2 → 10.1.4-republish-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (668) hide show
  1. package/CHANGELOG.md +204 -2
  2. package/README.md +1 -1
  3. package/darwinarm64/bsb_helper.exe +0 -0
  4. package/darwinarm64/bsc.exe +0 -0
  5. package/darwinarm64/ninja.exe +0 -0
  6. package/darwinarm64/rescript.exe +0 -0
  7. package/docs/docson/build-schema.json +497 -516
  8. package/lib/4.06.1/bsb_helper.ml +6 -1
  9. package/lib/4.06.1/rescript.ml +1414 -1191
  10. package/lib/4.06.1/whole_compiler.ml +69844 -69069
  11. package/lib/es6/belt_internalBuckets.js +13 -13
  12. package/lib/es6/caml_float.js +5 -5
  13. package/lib/es6/caml_format.js +1 -1
  14. package/lib/es6/caml_int64.js +1 -1
  15. package/lib/es6/caml_obj.js +26 -6
  16. package/lib/es6/complex.js +4 -4
  17. package/lib/es6/js.js +3 -0
  18. package/lib/es6/js_promise2.js +16 -0
  19. package/lib/es6/jsxPPXReactSupport.js +26 -0
  20. package/lib/js/belt_internalBuckets.js +13 -13
  21. package/lib/js/caml_float.js +5 -5
  22. package/lib/js/caml_format.js +1 -1
  23. package/lib/js/caml_int64.js +1 -1
  24. package/lib/js/caml_obj.js +26 -6
  25. package/lib/js/complex.js +4 -4
  26. package/lib/js/js.js +3 -0
  27. package/lib/js/js_promise2.js +14 -0
  28. package/lib/js/jsxPPXReactSupport.js +24 -0
  29. package/package.json +2 -1
  30. package/scripts/buildNinjaBinary.js +29 -0
  31. package/scripts/install.js +7 -3
  32. package/scripts/installUtils.js +9 -1
  33. package/scripts/rescript_arg.js +2 -4
  34. package/scripts/rescript_format.js +73 -39
  35. package/win32/refmt.exe +0 -0
  36. package/darwin/bsb_helper.exe +0 -0
  37. package/darwin/bsc.exe +0 -0
  38. package/darwin/ninja.COPYING +0 -202
  39. package/darwin/ninja.exe +0 -0
  40. package/darwin/rescript.exe +0 -0
  41. package/darwinarm64/ninja.COPYING +0 -202
  42. package/freebsd/ninja.COPYING +0 -202
  43. package/lib/ocaml/arg.cmi +0 -0
  44. package/lib/ocaml/arg.cmt +0 -0
  45. package/lib/ocaml/arg.cmti +0 -0
  46. package/lib/ocaml/arg.ml +0 -359
  47. package/lib/ocaml/arg.mli +0 -185
  48. package/lib/ocaml/array.cmi +0 -0
  49. package/lib/ocaml/array.cmt +0 -0
  50. package/lib/ocaml/array.cmti +0 -0
  51. package/lib/ocaml/array.ml +0 -307
  52. package/lib/ocaml/array.mli +0 -275
  53. package/lib/ocaml/arrayLabels.cmi +0 -0
  54. package/lib/ocaml/arrayLabels.cmt +0 -0
  55. package/lib/ocaml/arrayLabels.cmti +0 -0
  56. package/lib/ocaml/arrayLabels.ml +0 -307
  57. package/lib/ocaml/arrayLabels.mli +0 -276
  58. package/lib/ocaml/belt.cmi +0 -0
  59. package/lib/ocaml/belt.cmt +0 -0
  60. package/lib/ocaml/belt.ml +0 -352
  61. package/lib/ocaml/belt_Array.cmi +0 -0
  62. package/lib/ocaml/belt_Array.cmt +0 -0
  63. package/lib/ocaml/belt_Array.cmti +0 -0
  64. package/lib/ocaml/belt_Array.ml +0 -525
  65. package/lib/ocaml/belt_Array.mli +0 -707
  66. package/lib/ocaml/belt_Float.cmi +0 -0
  67. package/lib/ocaml/belt_Float.cmt +0 -0
  68. package/lib/ocaml/belt_Float.cmti +0 -0
  69. package/lib/ocaml/belt_Float.ml +0 -50
  70. package/lib/ocaml/belt_Float.mli +0 -106
  71. package/lib/ocaml/belt_HashMap.cmi +0 -0
  72. package/lib/ocaml/belt_HashMap.cmt +0 -0
  73. package/lib/ocaml/belt_HashMap.cmti +0 -0
  74. package/lib/ocaml/belt_HashMap.ml +0 -226
  75. package/lib/ocaml/belt_HashMap.mli +0 -436
  76. package/lib/ocaml/belt_HashMapInt.cmi +0 -0
  77. package/lib/ocaml/belt_HashMapInt.cmt +0 -0
  78. package/lib/ocaml/belt_HashMapInt.cmti +0 -0
  79. package/lib/ocaml/belt_HashMapInt.ml +0 -206
  80. package/lib/ocaml/belt_HashMapInt.mli +0 -50
  81. package/lib/ocaml/belt_HashMapString.cmi +0 -0
  82. package/lib/ocaml/belt_HashMapString.cmt +0 -0
  83. package/lib/ocaml/belt_HashMapString.cmti +0 -0
  84. package/lib/ocaml/belt_HashMapString.ml +0 -206
  85. package/lib/ocaml/belt_HashMapString.mli +0 -50
  86. package/lib/ocaml/belt_HashSet.cmi +0 -0
  87. package/lib/ocaml/belt_HashSet.cmt +0 -0
  88. package/lib/ocaml/belt_HashSet.cmti +0 -0
  89. package/lib/ocaml/belt_HashSet.ml +0 -196
  90. package/lib/ocaml/belt_HashSet.mli +0 -125
  91. package/lib/ocaml/belt_HashSetInt.cmi +0 -0
  92. package/lib/ocaml/belt_HashSetInt.cmt +0 -0
  93. package/lib/ocaml/belt_HashSetInt.cmti +0 -0
  94. package/lib/ocaml/belt_HashSetInt.ml +0 -155
  95. package/lib/ocaml/belt_HashSetInt.mli +0 -74
  96. package/lib/ocaml/belt_HashSetString.cmi +0 -0
  97. package/lib/ocaml/belt_HashSetString.cmt +0 -0
  98. package/lib/ocaml/belt_HashSetString.cmti +0 -0
  99. package/lib/ocaml/belt_HashSetString.ml +0 -156
  100. package/lib/ocaml/belt_HashSetString.mli +0 -74
  101. package/lib/ocaml/belt_Id.cmi +0 -0
  102. package/lib/ocaml/belt_Id.cmt +0 -0
  103. package/lib/ocaml/belt_Id.cmti +0 -0
  104. package/lib/ocaml/belt_Id.ml +0 -133
  105. package/lib/ocaml/belt_Id.mli +0 -171
  106. package/lib/ocaml/belt_Int.cmi +0 -0
  107. package/lib/ocaml/belt_Int.cmt +0 -0
  108. package/lib/ocaml/belt_Int.cmti +0 -0
  109. package/lib/ocaml/belt_Int.ml +0 -50
  110. package/lib/ocaml/belt_Int.mli +0 -103
  111. package/lib/ocaml/belt_List.cmi +0 -0
  112. package/lib/ocaml/belt_List.cmt +0 -0
  113. package/lib/ocaml/belt_List.cmti +0 -0
  114. package/lib/ocaml/belt_List.ml +0 -803
  115. package/lib/ocaml/belt_List.mli +0 -844
  116. package/lib/ocaml/belt_Map.cmi +0 -0
  117. package/lib/ocaml/belt_Map.cmt +0 -0
  118. package/lib/ocaml/belt_Map.cmti +0 -0
  119. package/lib/ocaml/belt_Map.ml +0 -170
  120. package/lib/ocaml/belt_Map.mli +0 -496
  121. package/lib/ocaml/belt_MapDict.cmi +0 -0
  122. package/lib/ocaml/belt_MapDict.cmt +0 -0
  123. package/lib/ocaml/belt_MapDict.cmti +0 -0
  124. package/lib/ocaml/belt_MapDict.ml +0 -278
  125. package/lib/ocaml/belt_MapDict.mli +0 -268
  126. package/lib/ocaml/belt_MapInt.cmi +0 -0
  127. package/lib/ocaml/belt_MapInt.cmt +0 -0
  128. package/lib/ocaml/belt_MapInt.cmti +0 -0
  129. package/lib/ocaml/belt_MapInt.ml +0 -169
  130. package/lib/ocaml/belt_MapInt.mli +0 -187
  131. package/lib/ocaml/belt_MapString.cmi +0 -0
  132. package/lib/ocaml/belt_MapString.cmt +0 -0
  133. package/lib/ocaml/belt_MapString.cmti +0 -0
  134. package/lib/ocaml/belt_MapString.ml +0 -169
  135. package/lib/ocaml/belt_MapString.mli +0 -187
  136. package/lib/ocaml/belt_MutableMap.cmi +0 -0
  137. package/lib/ocaml/belt_MutableMap.cmt +0 -0
  138. package/lib/ocaml/belt_MutableMap.cmti +0 -0
  139. package/lib/ocaml/belt_MutableMap.ml +0 -241
  140. package/lib/ocaml/belt_MutableMap.mli +0 -145
  141. package/lib/ocaml/belt_MutableMapInt.cmi +0 -0
  142. package/lib/ocaml/belt_MutableMapInt.cmt +0 -0
  143. package/lib/ocaml/belt_MutableMapInt.cmti +0 -0
  144. package/lib/ocaml/belt_MutableMapInt.ml +0 -172
  145. package/lib/ocaml/belt_MutableMapInt.mli +0 -135
  146. package/lib/ocaml/belt_MutableMapString.cmi +0 -0
  147. package/lib/ocaml/belt_MutableMapString.cmt +0 -0
  148. package/lib/ocaml/belt_MutableMapString.cmti +0 -0
  149. package/lib/ocaml/belt_MutableMapString.ml +0 -172
  150. package/lib/ocaml/belt_MutableMapString.mli +0 -135
  151. package/lib/ocaml/belt_MutableQueue.cmi +0 -0
  152. package/lib/ocaml/belt_MutableQueue.cmt +0 -0
  153. package/lib/ocaml/belt_MutableQueue.cmti +0 -0
  154. package/lib/ocaml/belt_MutableQueue.ml +0 -222
  155. package/lib/ocaml/belt_MutableQueue.mli +0 -116
  156. package/lib/ocaml/belt_MutableSet.cmi +0 -0
  157. package/lib/ocaml/belt_MutableSet.cmt +0 -0
  158. package/lib/ocaml/belt_MutableSet.cmti +0 -0
  159. package/lib/ocaml/belt_MutableSet.ml +0 -371
  160. package/lib/ocaml/belt_MutableSet.mli +0 -617
  161. package/lib/ocaml/belt_MutableSetInt.cmi +0 -0
  162. package/lib/ocaml/belt_MutableSetInt.cmt +0 -0
  163. package/lib/ocaml/belt_MutableSetInt.cmti +0 -0
  164. package/lib/ocaml/belt_MutableSetInt.ml +0 -342
  165. package/lib/ocaml/belt_MutableSetInt.mli +0 -124
  166. package/lib/ocaml/belt_MutableSetString.cmi +0 -0
  167. package/lib/ocaml/belt_MutableSetString.cmt +0 -0
  168. package/lib/ocaml/belt_MutableSetString.cmti +0 -0
  169. package/lib/ocaml/belt_MutableSetString.ml +0 -342
  170. package/lib/ocaml/belt_MutableSetString.mli +0 -124
  171. package/lib/ocaml/belt_MutableStack.cmi +0 -0
  172. package/lib/ocaml/belt_MutableStack.cmt +0 -0
  173. package/lib/ocaml/belt_MutableStack.cmti +0 -0
  174. package/lib/ocaml/belt_MutableStack.ml +0 -106
  175. package/lib/ocaml/belt_MutableStack.mli +0 -63
  176. package/lib/ocaml/belt_Option.cmi +0 -0
  177. package/lib/ocaml/belt_Option.cmt +0 -0
  178. package/lib/ocaml/belt_Option.cmti +0 -0
  179. package/lib/ocaml/belt_Option.ml +0 -93
  180. package/lib/ocaml/belt_Option.mli +0 -270
  181. package/lib/ocaml/belt_Range.cmi +0 -0
  182. package/lib/ocaml/belt_Range.cmt +0 -0
  183. package/lib/ocaml/belt_Range.cmti +0 -0
  184. package/lib/ocaml/belt_Range.ml +0 -76
  185. package/lib/ocaml/belt_Range.mli +0 -114
  186. package/lib/ocaml/belt_Result.cmi +0 -0
  187. package/lib/ocaml/belt_Result.cmt +0 -0
  188. package/lib/ocaml/belt_Result.cmti +0 -0
  189. package/lib/ocaml/belt_Result.ml +0 -75
  190. package/lib/ocaml/belt_Result.mli +0 -205
  191. package/lib/ocaml/belt_Set.cmi +0 -0
  192. package/lib/ocaml/belt_Set.cmt +0 -0
  193. package/lib/ocaml/belt_Set.cmti +0 -0
  194. package/lib/ocaml/belt_Set.cppo.ml +0 -205
  195. package/lib/ocaml/belt_Set.cppo.mli +0 -153
  196. package/lib/ocaml/belt_Set.ml +0 -164
  197. package/lib/ocaml/belt_Set.mli +0 -523
  198. package/lib/ocaml/belt_SetDict.cmi +0 -0
  199. package/lib/ocaml/belt_SetDict.cmt +0 -0
  200. package/lib/ocaml/belt_SetDict.cmti +0 -0
  201. package/lib/ocaml/belt_SetDict.ml +0 -237
  202. package/lib/ocaml/belt_SetDict.mli +0 -567
  203. package/lib/ocaml/belt_SetInt.cmi +0 -0
  204. package/lib/ocaml/belt_SetInt.cmt +0 -0
  205. package/lib/ocaml/belt_SetInt.cmti +0 -0
  206. package/lib/ocaml/belt_SetInt.ml +0 -201
  207. package/lib/ocaml/belt_SetInt.mli +0 -151
  208. package/lib/ocaml/belt_SetString.cmi +0 -0
  209. package/lib/ocaml/belt_SetString.cmt +0 -0
  210. package/lib/ocaml/belt_SetString.cmti +0 -0
  211. package/lib/ocaml/belt_SetString.ml +0 -201
  212. package/lib/ocaml/belt_SetString.mli +0 -151
  213. package/lib/ocaml/belt_SortArray.cmi +0 -0
  214. package/lib/ocaml/belt_SortArray.cmt +0 -0
  215. package/lib/ocaml/belt_SortArray.cmti +0 -0
  216. package/lib/ocaml/belt_SortArray.ml +0 -322
  217. package/lib/ocaml/belt_SortArray.mli +0 -146
  218. package/lib/ocaml/belt_SortArrayInt.cmi +0 -0
  219. package/lib/ocaml/belt_SortArrayInt.cmt +0 -0
  220. package/lib/ocaml/belt_SortArrayInt.cmti +0 -0
  221. package/lib/ocaml/belt_SortArrayInt.ml +0 -263
  222. package/lib/ocaml/belt_SortArrayInt.mli +0 -93
  223. package/lib/ocaml/belt_SortArrayString.cmi +0 -0
  224. package/lib/ocaml/belt_SortArrayString.cmt +0 -0
  225. package/lib/ocaml/belt_SortArrayString.cmti +0 -0
  226. package/lib/ocaml/belt_SortArrayString.ml +0 -263
  227. package/lib/ocaml/belt_SortArrayString.mli +0 -93
  228. package/lib/ocaml/belt_internalAVLset.cmt +0 -0
  229. package/lib/ocaml/belt_internalAVLset.cmti +0 -0
  230. package/lib/ocaml/belt_internalAVLset.ml +0 -665
  231. package/lib/ocaml/belt_internalAVLset.mli +0 -124
  232. package/lib/ocaml/belt_internalAVLtree.cmt +0 -0
  233. package/lib/ocaml/belt_internalAVLtree.cmti +0 -0
  234. package/lib/ocaml/belt_internalAVLtree.ml +0 -762
  235. package/lib/ocaml/belt_internalAVLtree.mli +0 -215
  236. package/lib/ocaml/belt_internalBuckets.cmt +0 -0
  237. package/lib/ocaml/belt_internalBuckets.cmti +0 -0
  238. package/lib/ocaml/belt_internalBuckets.ml +0 -218
  239. package/lib/ocaml/belt_internalBuckets.mli +0 -57
  240. package/lib/ocaml/belt_internalBucketsType.cmt +0 -0
  241. package/lib/ocaml/belt_internalBucketsType.cmti +0 -0
  242. package/lib/ocaml/belt_internalBucketsType.ml +0 -59
  243. package/lib/ocaml/belt_internalBucketsType.mli +0 -46
  244. package/lib/ocaml/belt_internalMapInt.cmt +0 -0
  245. package/lib/ocaml/belt_internalMapInt.ml +0 -227
  246. package/lib/ocaml/belt_internalMapString.cmt +0 -0
  247. package/lib/ocaml/belt_internalMapString.ml +0 -227
  248. package/lib/ocaml/belt_internalSetBuckets.cmt +0 -0
  249. package/lib/ocaml/belt_internalSetBuckets.cmti +0 -0
  250. package/lib/ocaml/belt_internalSetBuckets.ml +0 -157
  251. package/lib/ocaml/belt_internalSetBuckets.mli +0 -47
  252. package/lib/ocaml/belt_internalSetInt.cmt +0 -0
  253. package/lib/ocaml/belt_internalSetInt.ml +0 -129
  254. package/lib/ocaml/belt_internalSetString.cmt +0 -0
  255. package/lib/ocaml/belt_internalSetString.ml +0 -129
  256. package/lib/ocaml/belt_internals.cmti +0 -0
  257. package/lib/ocaml/belt_internals.mli +0 -79
  258. package/lib/ocaml/buffer.cmi +0 -0
  259. package/lib/ocaml/buffer.cmt +0 -0
  260. package/lib/ocaml/buffer.cmti +0 -0
  261. package/lib/ocaml/buffer.ml +0 -250
  262. package/lib/ocaml/buffer.mli +0 -149
  263. package/lib/ocaml/bytes.cmi +0 -0
  264. package/lib/ocaml/bytes.cmt +0 -0
  265. package/lib/ocaml/bytes.cmti +0 -0
  266. package/lib/ocaml/bytes.ml +0 -431
  267. package/lib/ocaml/bytes.mli +0 -430
  268. package/lib/ocaml/bytesLabels.cmi +0 -0
  269. package/lib/ocaml/bytesLabels.cmt +0 -0
  270. package/lib/ocaml/bytesLabels.cmti +0 -0
  271. package/lib/ocaml/bytesLabels.ml +0 -428
  272. package/lib/ocaml/bytesLabels.mli +0 -276
  273. package/lib/ocaml/callback.cmi +0 -0
  274. package/lib/ocaml/callback.cmt +0 -0
  275. package/lib/ocaml/callback.cmti +0 -0
  276. package/lib/ocaml/callback.ml +0 -20
  277. package/lib/ocaml/callback.mli +0 -34
  278. package/lib/ocaml/camlinternalLazy.cmi +0 -0
  279. package/lib/ocaml/camlinternalLazy.cmt +0 -0
  280. package/lib/ocaml/camlinternalLazy.cmti +0 -0
  281. package/lib/ocaml/camlinternalLazy.ml +0 -89
  282. package/lib/ocaml/camlinternalLazy.mli +0 -27
  283. package/lib/ocaml/camlinternalMod.cmi +0 -0
  284. package/lib/ocaml/camlinternalMod.cmt +0 -0
  285. package/lib/ocaml/camlinternalMod.cmti +0 -0
  286. package/lib/ocaml/camlinternalMod.ml +0 -21
  287. package/lib/ocaml/camlinternalMod.mli +0 -25
  288. package/lib/ocaml/char.cmi +0 -0
  289. package/lib/ocaml/char.cmt +0 -0
  290. package/lib/ocaml/char.cmti +0 -0
  291. package/lib/ocaml/char.ml +0 -76
  292. package/lib/ocaml/char.mli +0 -72
  293. package/lib/ocaml/complex.cmi +0 -0
  294. package/lib/ocaml/complex.cmt +0 -0
  295. package/lib/ocaml/complex.cmti +0 -0
  296. package/lib/ocaml/complex.ml +0 -87
  297. package/lib/ocaml/complex.mli +0 -86
  298. package/lib/ocaml/digest.cmi +0 -0
  299. package/lib/ocaml/digest.cmt +0 -0
  300. package/lib/ocaml/digest.cmti +0 -0
  301. package/lib/ocaml/digest.ml +0 -66
  302. package/lib/ocaml/digest.mli +0 -68
  303. package/lib/ocaml/dom.cmi +0 -0
  304. package/lib/ocaml/dom.cmt +0 -0
  305. package/lib/ocaml/dom.ml +0 -296
  306. package/lib/ocaml/dom_storage.cmi +0 -0
  307. package/lib/ocaml/dom_storage.cmt +0 -0
  308. package/lib/ocaml/dom_storage.ml +0 -22
  309. package/lib/ocaml/dom_storage2.cmi +0 -0
  310. package/lib/ocaml/dom_storage2.cmt +0 -0
  311. package/lib/ocaml/dom_storage2.ml +0 -11
  312. package/lib/ocaml/filename.cmi +0 -0
  313. package/lib/ocaml/filename.cmt +0 -0
  314. package/lib/ocaml/filename.cmti +0 -0
  315. package/lib/ocaml/filename.ml +0 -233
  316. package/lib/ocaml/filename.mli +0 -134
  317. package/lib/ocaml/genlex.cmi +0 -0
  318. package/lib/ocaml/genlex.cmt +0 -0
  319. package/lib/ocaml/genlex.cmti +0 -0
  320. package/lib/ocaml/genlex.ml +0 -201
  321. package/lib/ocaml/genlex.mli +0 -73
  322. package/lib/ocaml/hashmap.cppo.ml +0 -214
  323. package/lib/ocaml/hashmap.cppo.mli +0 -54
  324. package/lib/ocaml/hashset.cppo.ml +0 -165
  325. package/lib/ocaml/hashset.cppo.mli +0 -77
  326. package/lib/ocaml/hashtbl.cmi +0 -0
  327. package/lib/ocaml/hashtbl.cmt +0 -0
  328. package/lib/ocaml/hashtbl.cmti +0 -0
  329. package/lib/ocaml/hashtbl.ml +0 -541
  330. package/lib/ocaml/hashtbl.mli +0 -411
  331. package/lib/ocaml/hashtblLabels.cmi +0 -0
  332. package/lib/ocaml/hashtblLabels.cmt +0 -0
  333. package/lib/ocaml/hashtblLabels.ml +0 -130
  334. package/lib/ocaml/int32.cmi +0 -0
  335. package/lib/ocaml/int32.cmt +0 -0
  336. package/lib/ocaml/int32.cmti +0 -0
  337. package/lib/ocaml/int32.ml +0 -64
  338. package/lib/ocaml/int32.mli +0 -186
  339. package/lib/ocaml/int64.cmi +0 -0
  340. package/lib/ocaml/int64.cmt +0 -0
  341. package/lib/ocaml/int64.cmti +0 -0
  342. package/lib/ocaml/int64.ml +0 -72
  343. package/lib/ocaml/int64.mli +0 -197
  344. package/lib/ocaml/internal_map.cppo.ml +0 -230
  345. package/lib/ocaml/internal_set.cppo.ml +0 -134
  346. package/lib/ocaml/js.cmi +0 -0
  347. package/lib/ocaml/js.cmt +0 -0
  348. package/lib/ocaml/js.ml +0 -313
  349. package/lib/ocaml/js_OO.cmi +0 -0
  350. package/lib/ocaml/js_OO.cmt +0 -0
  351. package/lib/ocaml/js_OO.ml +0 -180
  352. package/lib/ocaml/js_array.cmi +0 -0
  353. package/lib/ocaml/js_array.cmt +0 -0
  354. package/lib/ocaml/js_array.ml +0 -970
  355. package/lib/ocaml/js_array2.cmi +0 -0
  356. package/lib/ocaml/js_array2.cmt +0 -0
  357. package/lib/ocaml/js_array2.ml +0 -1065
  358. package/lib/ocaml/js_bigint.cmi +0 -0
  359. package/lib/ocaml/js_bigint.cmt +0 -0
  360. package/lib/ocaml/js_bigint.ml +0 -3
  361. package/lib/ocaml/js_cast.cmi +0 -0
  362. package/lib/ocaml/js_cast.cmt +0 -0
  363. package/lib/ocaml/js_cast.cmti +0 -0
  364. package/lib/ocaml/js_cast.ml +0 -29
  365. package/lib/ocaml/js_cast.mli +0 -45
  366. package/lib/ocaml/js_console.cmi +0 -0
  367. package/lib/ocaml/js_console.cmt +0 -0
  368. package/lib/ocaml/js_console.ml +0 -51
  369. package/lib/ocaml/js_date.cmi +0 -0
  370. package/lib/ocaml/js_date.cmt +0 -0
  371. package/lib/ocaml/js_date.ml +0 -1263
  372. package/lib/ocaml/js_dict.cmi +0 -0
  373. package/lib/ocaml/js_dict.cmt +0 -0
  374. package/lib/ocaml/js_dict.cmti +0 -0
  375. package/lib/ocaml/js_dict.ml +0 -114
  376. package/lib/ocaml/js_dict.mli +0 -152
  377. package/lib/ocaml/js_exn.cmi +0 -0
  378. package/lib/ocaml/js_exn.cmt +0 -0
  379. package/lib/ocaml/js_exn.cmti +0 -0
  380. package/lib/ocaml/js_exn.ml +0 -102
  381. package/lib/ocaml/js_exn.mli +0 -79
  382. package/lib/ocaml/js_float.cmi +0 -0
  383. package/lib/ocaml/js_float.cmt +0 -0
  384. package/lib/ocaml/js_float.ml +0 -294
  385. package/lib/ocaml/js_global.cmi +0 -0
  386. package/lib/ocaml/js_global.cmt +0 -0
  387. package/lib/ocaml/js_global.ml +0 -185
  388. package/lib/ocaml/js_int.cmi +0 -0
  389. package/lib/ocaml/js_int.cmt +0 -0
  390. package/lib/ocaml/js_int.ml +0 -158
  391. package/lib/ocaml/js_json.cmi +0 -0
  392. package/lib/ocaml/js_json.cmt +0 -0
  393. package/lib/ocaml/js_json.cmti +0 -0
  394. package/lib/ocaml/js_json.ml +0 -195
  395. package/lib/ocaml/js_json.mli +0 -244
  396. package/lib/ocaml/js_list.cmi +0 -0
  397. package/lib/ocaml/js_list.cmt +0 -0
  398. package/lib/ocaml/js_list.cmti +0 -0
  399. package/lib/ocaml/js_list.ml +0 -174
  400. package/lib/ocaml/js_list.mli +0 -72
  401. package/lib/ocaml/js_map.cmi +0 -0
  402. package/lib/ocaml/js_map.cmt +0 -0
  403. package/lib/ocaml/js_map.ml +0 -3
  404. package/lib/ocaml/js_mapperRt.cmi +0 -0
  405. package/lib/ocaml/js_mapperRt.cmt +0 -0
  406. package/lib/ocaml/js_mapperRt.cmti +0 -0
  407. package/lib/ocaml/js_mapperRt.ml +0 -50
  408. package/lib/ocaml/js_mapperRt.mli +0 -44
  409. package/lib/ocaml/js_math.cmi +0 -0
  410. package/lib/ocaml/js_math.cmt +0 -0
  411. package/lib/ocaml/js_math.ml +0 -626
  412. package/lib/ocaml/js_null.cmi +0 -0
  413. package/lib/ocaml/js_null.cmt +0 -0
  414. package/lib/ocaml/js_null.cmti +0 -0
  415. package/lib/ocaml/js_null.ml +0 -57
  416. package/lib/ocaml/js_null.mli +0 -87
  417. package/lib/ocaml/js_null_undefined.cmi +0 -0
  418. package/lib/ocaml/js_null_undefined.cmt +0 -0
  419. package/lib/ocaml/js_null_undefined.cmti +0 -0
  420. package/lib/ocaml/js_null_undefined.ml +0 -50
  421. package/lib/ocaml/js_null_undefined.mli +0 -85
  422. package/lib/ocaml/js_obj.cmi +0 -0
  423. package/lib/ocaml/js_obj.cmt +0 -0
  424. package/lib/ocaml/js_obj.ml +0 -100
  425. package/lib/ocaml/js_option.cmi +0 -0
  426. package/lib/ocaml/js_option.cmt +0 -0
  427. package/lib/ocaml/js_option.cmti +0 -0
  428. package/lib/ocaml/js_option.ml +0 -203
  429. package/lib/ocaml/js_option.mli +0 -52
  430. package/lib/ocaml/js_promise.cmi +0 -0
  431. package/lib/ocaml/js_promise.cmt +0 -0
  432. package/lib/ocaml/js_promise.ml +0 -100
  433. package/lib/ocaml/js_re.cmi +0 -0
  434. package/lib/ocaml/js_re.cmt +0 -0
  435. package/lib/ocaml/js_re.ml +0 -184
  436. package/lib/ocaml/js_result.cmi +0 -0
  437. package/lib/ocaml/js_result.cmt +0 -0
  438. package/lib/ocaml/js_result.cmti +0 -0
  439. package/lib/ocaml/js_result.ml +0 -28
  440. package/lib/ocaml/js_result.mli +0 -28
  441. package/lib/ocaml/js_set.cmi +0 -0
  442. package/lib/ocaml/js_set.cmt +0 -0
  443. package/lib/ocaml/js_set.ml +0 -3
  444. package/lib/ocaml/js_string.cmi +0 -0
  445. package/lib/ocaml/js_string.cmt +0 -0
  446. package/lib/ocaml/js_string.ml +0 -914
  447. package/lib/ocaml/js_string2.cmi +0 -0
  448. package/lib/ocaml/js_string2.cmt +0 -0
  449. package/lib/ocaml/js_string2.ml +0 -912
  450. package/lib/ocaml/js_typed_array.cmi +0 -0
  451. package/lib/ocaml/js_typed_array.cmt +0 -0
  452. package/lib/ocaml/js_typed_array.cppo.ml +0 -429
  453. package/lib/ocaml/js_typed_array.ml +0 -1405
  454. package/lib/ocaml/js_typed_array2.cmi +0 -0
  455. package/lib/ocaml/js_typed_array2.cmt +0 -0
  456. package/lib/ocaml/js_typed_array2.cppo.ml +0 -296
  457. package/lib/ocaml/js_typed_array2.ml +0 -1269
  458. package/lib/ocaml/js_types.cmi +0 -0
  459. package/lib/ocaml/js_types.cmt +0 -0
  460. package/lib/ocaml/js_types.cmti +0 -0
  461. package/lib/ocaml/js_types.ml +0 -118
  462. package/lib/ocaml/js_types.mli +0 -78
  463. package/lib/ocaml/js_undefined.cmi +0 -0
  464. package/lib/ocaml/js_undefined.cmt +0 -0
  465. package/lib/ocaml/js_undefined.cmti +0 -0
  466. package/lib/ocaml/js_undefined.ml +0 -59
  467. package/lib/ocaml/js_undefined.mli +0 -92
  468. package/lib/ocaml/js_vector.cmi +0 -0
  469. package/lib/ocaml/js_vector.cmt +0 -0
  470. package/lib/ocaml/js_vector.cmti +0 -0
  471. package/lib/ocaml/js_vector.ml +0 -143
  472. package/lib/ocaml/js_vector.mli +0 -92
  473. package/lib/ocaml/js_weakmap.cmi +0 -0
  474. package/lib/ocaml/js_weakmap.cmt +0 -0
  475. package/lib/ocaml/js_weakmap.ml +0 -3
  476. package/lib/ocaml/js_weakset.cmi +0 -0
  477. package/lib/ocaml/js_weakset.cmt +0 -0
  478. package/lib/ocaml/js_weakset.ml +0 -3
  479. package/lib/ocaml/jsx.cmi +0 -0
  480. package/lib/ocaml/jsx.cmt +0 -0
  481. package/lib/ocaml/jsx.ml +0 -39
  482. package/lib/ocaml/jsxDOM.cmi +0 -0
  483. package/lib/ocaml/jsxDOM.cmt +0 -0
  484. package/lib/ocaml/jsxDOM.ml +0 -2087
  485. package/lib/ocaml/jsxDOMStyle.cmi +0 -0
  486. package/lib/ocaml/jsxDOMStyle.cmt +0 -0
  487. package/lib/ocaml/jsxDOMStyle.ml +0 -777
  488. package/lib/ocaml/jsxEvent.cmi +0 -0
  489. package/lib/ocaml/jsxEvent.cmt +0 -0
  490. package/lib/ocaml/jsxEvent.ml +0 -358
  491. package/lib/ocaml/lazy.cmi +0 -0
  492. package/lib/ocaml/lazy.cmt +0 -0
  493. package/lib/ocaml/lazy.cmti +0 -0
  494. package/lib/ocaml/lazy.ml +0 -70
  495. package/lib/ocaml/lazy.mli +0 -95
  496. package/lib/ocaml/lexing.cmi +0 -0
  497. package/lib/ocaml/lexing.cmt +0 -0
  498. package/lib/ocaml/lexing.cmti +0 -0
  499. package/lib/ocaml/lexing.ml +0 -230
  500. package/lib/ocaml/lexing.mli +0 -172
  501. package/lib/ocaml/list.cmi +0 -0
  502. package/lib/ocaml/list.cmt +0 -0
  503. package/lib/ocaml/list.cmti +0 -0
  504. package/lib/ocaml/list.ml +0 -485
  505. package/lib/ocaml/list.mli +0 -347
  506. package/lib/ocaml/listLabels.cmi +0 -0
  507. package/lib/ocaml/listLabels.cmt +0 -0
  508. package/lib/ocaml/listLabels.cmti +0 -0
  509. package/lib/ocaml/listLabels.ml +0 -485
  510. package/lib/ocaml/listLabels.mli +0 -353
  511. package/lib/ocaml/map.cmi +0 -0
  512. package/lib/ocaml/map.cmt +0 -0
  513. package/lib/ocaml/map.cmti +0 -0
  514. package/lib/ocaml/map.cppo.ml +0 -174
  515. package/lib/ocaml/map.cppo.mli +0 -191
  516. package/lib/ocaml/map.ml +0 -480
  517. package/lib/ocaml/map.mli +0 -315
  518. package/lib/ocaml/mapLabels.cmi +0 -0
  519. package/lib/ocaml/mapLabels.cmt +0 -0
  520. package/lib/ocaml/mapLabels.ml +0 -480
  521. package/lib/ocaml/mapm.cppo.ml +0 -177
  522. package/lib/ocaml/mapm.cppo.mli +0 -138
  523. package/lib/ocaml/moreLabels.cmi +0 -0
  524. package/lib/ocaml/moreLabels.cmt +0 -0
  525. package/lib/ocaml/moreLabels.cmti +0 -0
  526. package/lib/ocaml/moreLabels.ml +0 -22
  527. package/lib/ocaml/moreLabels.mli +0 -198
  528. package/lib/ocaml/node.cmi +0 -0
  529. package/lib/ocaml/node.cmt +0 -0
  530. package/lib/ocaml/node.ml +0 -84
  531. package/lib/ocaml/node_buffer.cmi +0 -0
  532. package/lib/ocaml/node_buffer.cmt +0 -0
  533. package/lib/ocaml/node_buffer.ml +0 -47
  534. package/lib/ocaml/node_child_process.cmi +0 -0
  535. package/lib/ocaml/node_child_process.cmt +0 -0
  536. package/lib/ocaml/node_child_process.ml +0 -50
  537. package/lib/ocaml/node_fs.cmi +0 -0
  538. package/lib/ocaml/node_fs.cmt +0 -0
  539. package/lib/ocaml/node_fs.ml +0 -153
  540. package/lib/ocaml/node_module.cmi +0 -0
  541. package/lib/ocaml/node_module.cmt +0 -0
  542. package/lib/ocaml/node_module.ml +0 -29
  543. package/lib/ocaml/node_path.cmi +0 -0
  544. package/lib/ocaml/node_path.cmt +0 -0
  545. package/lib/ocaml/node_path.ml +0 -71
  546. package/lib/ocaml/node_process.cmi +0 -0
  547. package/lib/ocaml/node_process.cmt +0 -0
  548. package/lib/ocaml/node_process.cmti +0 -0
  549. package/lib/ocaml/node_process.ml +0 -59
  550. package/lib/ocaml/node_process.mli +0 -48
  551. package/lib/ocaml/obj.cmi +0 -0
  552. package/lib/ocaml/obj.cmt +0 -0
  553. package/lib/ocaml/obj.cmti +0 -0
  554. package/lib/ocaml/obj.ml +0 -29
  555. package/lib/ocaml/obj.mli +0 -62
  556. package/lib/ocaml/parsing.cmi +0 -0
  557. package/lib/ocaml/parsing.cmt +0 -0
  558. package/lib/ocaml/parsing.cmti +0 -0
  559. package/lib/ocaml/parsing.ml +0 -212
  560. package/lib/ocaml/parsing.mli +0 -105
  561. package/lib/ocaml/pervasives.cmi +0 -0
  562. package/lib/ocaml/pervasives.cmt +0 -0
  563. package/lib/ocaml/pervasives.cmti +0 -0
  564. package/lib/ocaml/pervasives.ml +0 -297
  565. package/lib/ocaml/pervasives.mli +0 -771
  566. package/lib/ocaml/printexc.cmi +0 -0
  567. package/lib/ocaml/printexc.cmt +0 -0
  568. package/lib/ocaml/printexc.cmti +0 -0
  569. package/lib/ocaml/printexc.ml +0 -79
  570. package/lib/ocaml/printexc.mli +0 -57
  571. package/lib/ocaml/queue.cmi +0 -0
  572. package/lib/ocaml/queue.cmt +0 -0
  573. package/lib/ocaml/queue.cmti +0 -0
  574. package/lib/ocaml/queue.ml +0 -132
  575. package/lib/ocaml/queue.mli +0 -82
  576. package/lib/ocaml/random.cmi +0 -0
  577. package/lib/ocaml/random.cmt +0 -0
  578. package/lib/ocaml/random.cmti +0 -0
  579. package/lib/ocaml/random.ml +0 -273
  580. package/lib/ocaml/random.mli +0 -102
  581. package/lib/ocaml/set.cmi +0 -0
  582. package/lib/ocaml/set.cmt +0 -0
  583. package/lib/ocaml/set.cmti +0 -0
  584. package/lib/ocaml/set.ml +0 -526
  585. package/lib/ocaml/set.mli +0 -266
  586. package/lib/ocaml/setLabels.cmi +0 -0
  587. package/lib/ocaml/setLabels.cmt +0 -0
  588. package/lib/ocaml/setLabels.ml +0 -526
  589. package/lib/ocaml/setm.cppo.ml +0 -346
  590. package/lib/ocaml/setm.cppo.mli +0 -126
  591. package/lib/ocaml/sort.cmi +0 -0
  592. package/lib/ocaml/sort.cmt +0 -0
  593. package/lib/ocaml/sort.cmti +0 -0
  594. package/lib/ocaml/sort.cppo.ml +0 -267
  595. package/lib/ocaml/sort.cppo.mli +0 -96
  596. package/lib/ocaml/sort.ml +0 -99
  597. package/lib/ocaml/sort.mli +0 -44
  598. package/lib/ocaml/stack.cmi +0 -0
  599. package/lib/ocaml/stack.cmt +0 -0
  600. package/lib/ocaml/stack.cmti +0 -0
  601. package/lib/ocaml/stack.ml +0 -44
  602. package/lib/ocaml/stack.mli +0 -63
  603. package/lib/ocaml/stdLabels.cmi +0 -0
  604. package/lib/ocaml/stdLabels.cmt +0 -0
  605. package/lib/ocaml/stdLabels.cmti +0 -0
  606. package/lib/ocaml/stdLabels.ml +0 -24
  607. package/lib/ocaml/stdLabels.mli +0 -29
  608. package/lib/ocaml/stream.cmi +0 -0
  609. package/lib/ocaml/stream.cmt +0 -0
  610. package/lib/ocaml/stream.cmti +0 -0
  611. package/lib/ocaml/stream.ml +0 -213
  612. package/lib/ocaml/stream.mli +0 -108
  613. package/lib/ocaml/string.cmi +0 -0
  614. package/lib/ocaml/string.cmt +0 -0
  615. package/lib/ocaml/string.cmti +0 -0
  616. package/lib/ocaml/string.ml +0 -190
  617. package/lib/ocaml/string.mli +0 -286
  618. package/lib/ocaml/stringLabels.cmi +0 -0
  619. package/lib/ocaml/stringLabels.cmt +0 -0
  620. package/lib/ocaml/stringLabels.cmti +0 -0
  621. package/lib/ocaml/stringLabels.ml +0 -190
  622. package/lib/ocaml/stringLabels.mli +0 -241
  623. package/lib/ocaml/sys.cmi +0 -0
  624. package/lib/ocaml/sys.cmt +0 -0
  625. package/lib/ocaml/sys.cmti +0 -0
  626. package/lib/ocaml/sys.ml +0 -135
  627. package/lib/ocaml/sys.mli +0 -333
  628. package/lib/ocaml/uchar.cmi +0 -0
  629. package/lib/ocaml/uchar.cmt +0 -0
  630. package/lib/ocaml/uchar.cmti +0 -0
  631. package/lib/ocaml/uchar.ml +0 -58
  632. package/lib/ocaml/uchar.mli +0 -98
  633. package/linux/bsb_helper.exe +0 -0
  634. package/linux/bsc.exe +0 -0
  635. package/linux/ninja.COPYING +0 -202
  636. package/linux/ninja.exe +0 -0
  637. package/linux/rescript.exe +0 -0
  638. package/openbsd/.keep +0 -0
  639. package/scripts/LICENSE.ml +0 -27
  640. package/scripts/buckle_lto.js +0 -55
  641. package/scripts/build_sorted.ml +0 -233
  642. package/scripts/caml_oo_curry_gen.ml +0 -71
  643. package/scripts/checkUnused.js +0 -63
  644. package/scripts/ciTest.js +0 -172
  645. package/scripts/cover.sh +0 -3
  646. package/scripts/curry_gen.ml +0 -167
  647. package/scripts/dbg +0 -13
  648. package/scripts/dedupe.js +0 -44
  649. package/scripts/doc_gen.js +0 -117
  650. package/scripts/js_internal_gen.js +0 -135
  651. package/scripts/jsconfig.json +0 -12
  652. package/scripts/littlecase.js +0 -21
  653. package/scripts/ninja.js +0 -1980
  654. package/scripts/pack.js +0 -107
  655. package/scripts/prebuilt.js +0 -99
  656. package/scripts/release.js +0 -41
  657. package/scripts/repl.js +0 -151
  658. package/scripts/shake.js +0 -138
  659. package/scripts/tasks.js +0 -149
  660. package/scripts/test.sh +0 -3
  661. package/scripts/tmp.js +0 -98
  662. package/scripts/validate.js +0 -41
  663. package/vendor/ninja.tar.gz +0 -0
  664. package/win32/bsb_helper.exe +0 -0
  665. package/win32/bsc.exe +0 -0
  666. package/win32/ninja.COPYING +0 -202
  667. package/win32/ninja.exe +0 -0
  668. package/win32/rescript.exe +0 -0
@@ -1710,114 +1710,62 @@ module Bsb_build_schemas
1710
1710
 
1711
1711
  (* let files = "files" *)
1712
1712
  let version = "version"
1713
-
1714
1713
  let name = "name"
1715
1714
 
1716
1715
  (* let ocaml_config = "ocaml-config" *)
1717
1716
  let bsdep = "bsdep"
1718
-
1719
1717
  let ppx_flags = "ppx-flags"
1720
-
1721
1718
  let pp_flags = "pp-flags"
1722
-
1723
1719
  let bsc = "bsc"
1724
-
1725
1720
  let refmt = "refmt"
1726
-
1727
1721
  let bs_external_includes = "bs-external-includes"
1728
-
1729
1722
  let bs_lib_dir = "bs-lib-dir"
1730
-
1731
1723
  let bs_dependencies = "bs-dependencies"
1732
-
1733
1724
  let pinned_dependencies = "pinned-dependencies"
1734
-
1735
1725
  let bs_dev_dependencies = "bs-dev-dependencies"
1736
-
1737
1726
  let sources = "sources"
1738
-
1739
1727
  let dir = "dir"
1740
-
1741
1728
  let files = "files"
1742
-
1743
1729
  let subdirs = "subdirs"
1744
-
1745
1730
  let bsc_flags = "bsc-flags"
1746
-
1747
1731
  let excludes = "excludes"
1748
-
1749
1732
  let slow_re = "slow-re"
1750
-
1751
1733
  let resources = "resources"
1752
-
1753
1734
  let public = "public"
1754
-
1755
1735
  let js_post_build = "js-post-build"
1756
-
1757
1736
  let cmd = "cmd"
1758
-
1759
1737
  let ninja = "ninja"
1760
-
1761
1738
  let package_specs = "package-specs"
1762
-
1763
1739
  let generate_merlin = "generate-merlin"
1764
-
1765
1740
  let type_ = "type"
1766
-
1767
1741
  let dev = "dev"
1768
-
1769
1742
  let export_all = "all"
1770
-
1771
1743
  let export_none = "none"
1772
-
1773
1744
  let use_stdlib = "use-stdlib"
1774
-
1775
1745
  let external_stdlib = "external-stdlib"
1776
-
1777
1746
  let reason = "reason"
1778
-
1779
1747
  let react_jsx = "react-jsx"
1780
-
1781
1748
  let jsx = "jsx"
1782
-
1783
1749
  let jsx_version = "version"
1784
-
1785
1750
  let jsx_module = "module"
1786
-
1787
1751
  let jsx_mode = "mode"
1788
-
1752
+ let jsx_v3_dependencies = "v3-dependencies"
1789
1753
  let entries = "entries"
1790
-
1791
1754
  let backend = "backend"
1792
-
1793
1755
  let main_module = "main-module"
1794
-
1795
1756
  let cut_generators = "cut-generators"
1796
-
1797
1757
  let generators = "generators"
1798
-
1799
1758
  let command = "command"
1800
-
1801
1759
  let edge = "edge"
1802
-
1803
1760
  let namespace = "namespace"
1804
-
1805
1761
  let in_source = "in-source"
1806
-
1807
1762
  let warnings = "warnings"
1808
-
1809
1763
  let number = "number"
1810
-
1811
1764
  let error = "error"
1812
-
1813
1765
  let suffix = "suffix"
1814
-
1815
1766
  let gentypeconfig = "gentypeconfig"
1816
-
1817
1767
  let language = "language"
1818
-
1819
1768
  let path = "path"
1820
-
1821
1769
  let ignored_dirs = "ignored-dirs"
1822
1770
 
1823
1771
  end
@@ -4533,16 +4481,10 @@ let is_empty (x : file_group) =
4533
4481
  Map_string.is_empty x.sources && x.resources = [] && x.generators = []
4534
4482
 
4535
4483
  end
4536
- module Ext_module_system
4537
- = struct
4538
- #1 "ext_module_system.ml"
4539
- type t = NodeJS | Es6 | Es6_global
4540
-
4541
- end
4542
- module Ext_pervasives : sig
4543
- #1 "ext_pervasives.mli"
4484
+ module Bs_version : sig
4485
+ #1 "bs_version.mli"
4544
4486
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4545
- *
4487
+ *
4546
4488
  * This program is free software: you can redistribute it and/or modify
4547
4489
  * it under the terms of the GNU Lesser General Public License as published by
4548
4490
  * the Free Software Foundation, either version 3 of the License, or
@@ -4560,45 +4502,21 @@ module Ext_pervasives : sig
4560
4502
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
4561
4503
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4562
4504
  * GNU Lesser General Public License for more details.
4563
- *
4505
+ *
4564
4506
  * You should have received a copy of the GNU Lesser General Public License
4565
4507
  * along with this program; if not, write to the Free Software
4566
4508
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
4567
4509
 
4568
- (** Extension to standard library [Pervavives] module, safe to open
4569
- *)
4570
-
4571
- external reraise : exn -> 'a = "%reraise"
4572
-
4573
- val finally : 'a -> clean:('a -> unit) -> ('a -> 'b) -> 'b
4574
-
4575
- (* val try_it : (unit -> 'a) -> unit *)
4576
-
4577
- val with_file_as_chan : string -> (out_channel -> 'a) -> 'a
4578
-
4579
- val max_int : int -> int -> int
4580
-
4581
- val min_int : int -> int -> int
4582
-
4583
- val max_int_option : int option -> int option -> int option
4584
-
4585
- (* external id : 'a -> 'a = "%identity" *)
4586
-
4587
- (** Copied from {!Btype.hash_variant}:
4588
- need sync up and add test case
4589
- *)
4590
- (* val hash_variant : string -> int *)
4591
-
4592
- (* val todo : string -> 'a *)
4510
+ val version : string
4593
4511
 
4594
- val nat_of_string_exn : string -> int
4512
+ val header : string
4595
4513
 
4596
- val parse_nat_of_string : string -> int ref -> int
4514
+ val package_name : string ref
4597
4515
 
4598
4516
  end = struct
4599
- #1 "ext_pervasives.ml"
4517
+ #1 "bs_version.ml"
4600
4518
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4601
- *
4519
+ *
4602
4520
  * This program is free software: you can redistribute it and/or modify
4603
4521
  * it under the terms of the GNU Lesser General Public License as published by
4604
4522
  * the Free Software Foundation, either version 3 of the License, or
@@ -4616,135 +4534,19 @@ end = struct
4616
4534
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
4617
4535
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4618
4536
  * GNU Lesser General Public License for more details.
4619
- *
4537
+ *
4620
4538
  * You should have received a copy of the GNU Lesser General Public License
4621
4539
  * along with this program; if not, write to the Free Software
4622
4540
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
4623
-
4624
- external reraise : exn -> 'a = "%reraise"
4625
-
4626
- let finally v ~clean:action f =
4627
- match f v with
4628
- | exception e ->
4629
- action v;
4630
- reraise e
4631
- | e ->
4632
- action v;
4633
- e
4634
-
4635
- (* let try_it f =
4636
- try ignore (f ()) with _ -> () *)
4637
-
4638
- let with_file_as_chan filename f =
4639
- finally (open_out_bin filename) ~clean:close_out f
4640
-
4641
- let max_int (x : int) y = if x >= y then x else y
4642
-
4643
- let min_int (x : int) y = if x < y then x else y
4644
-
4645
- let max_int_option (x : int option) y =
4646
- match (x, y) with
4647
- | None, _ -> y
4648
- | Some _, None -> x
4649
- | Some x0, Some y0 -> if x0 >= y0 then x else y
4650
-
4651
- (* external id : 'a -> 'a = "%identity" *)
4652
-
4653
- (*
4654
- let hash_variant s =
4655
- let accu = ref 0 in
4656
- for i = 0 to String.length s - 1 do
4657
- accu := 223 * !accu + Char.code s.[i]
4658
- done;
4659
- (* reduce to 31 bits *)
4660
- accu := !accu land (1 lsl 31 - 1);
4661
- (* make it signed for 64 bits architectures *)
4662
- if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu *)
4663
-
4664
- (* let todo loc =
4665
- failwith (loc ^ " Not supported yet")
4666
- *)
4667
-
4668
- let rec int_of_string_aux s acc off len =
4669
- if off >= len then acc
4670
- else
4671
- let d = Char.code (String.unsafe_get s off) - 48 in
4672
- if d >= 0 && d <= 9 then int_of_string_aux s ((10 * acc) + d) (off + 1) len
4673
- else -1
4674
- (* error *)
4675
-
4676
- let nat_of_string_exn (s : string) =
4677
- let acc = int_of_string_aux s 0 0 (String.length s) in
4678
- if acc < 0 then invalid_arg s else acc
4679
-
4680
- (** return index *)
4681
- let parse_nat_of_string (s : string) (cursor : int ref) =
4682
- let current = !cursor in
4683
- assert (current >= 0);
4684
- let acc = ref 0 in
4685
- let s_len = String.length s in
4686
- let todo = ref true in
4687
- let cur = ref current in
4688
- while !todo && !cursor < s_len do
4689
- let d = Char.code (String.unsafe_get s !cur) - 48 in
4690
- if d >= 0 && d <= 9 then (
4691
- acc := (10 * !acc) + d;
4692
- incr cur)
4693
- else todo := false
4694
- done;
4695
- cursor := !cur;
4696
- !acc
4697
-
4698
- end
4699
- module Ext_fmt
4700
- = struct
4701
- #1 "ext_fmt.ml"
4702
- let with_file_as_pp filename f =
4703
- Ext_pervasives.finally (open_out_bin filename) ~clean:close_out (fun chan ->
4704
- let fmt = Format.formatter_of_out_channel chan in
4705
- let v = f fmt in
4706
- Format.pp_print_flush fmt ();
4707
- v)
4708
-
4709
- let failwithf ~loc fmt = Format.ksprintf (fun s -> failwith (loc ^ s)) fmt
4710
-
4711
- let invalid_argf fmt = Format.ksprintf invalid_arg fmt
4541
+ let version = "10.1.4"
4542
+ let header = "// Generated by ReScript, PLEASE EDIT WITH CARE"
4543
+ let package_name = ref "rescript"
4712
4544
 
4713
4545
  end
4714
- module Ext_sys : sig
4715
- #1 "ext_sys.mli"
4716
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4717
- *
4718
- * This program is free software: you can redistribute it and/or modify
4719
- * it under the terms of the GNU Lesser General Public License as published by
4720
- * the Free Software Foundation, either version 3 of the License, or
4721
- * (at your option) any later version.
4722
- *
4723
- * In addition to the permissions granted to you by the LGPL, you may combine
4724
- * or link a "work that uses the Library" with a publicly distributed version
4725
- * of this file to produce a combined library or application, then distribute
4726
- * that combined work under the terms of your choosing, with no requirement
4727
- * to comply with the obligations normally placed on you by section 4 of the
4728
- * LGPL version 3 (or the corresponding section of a later version of the LGPL
4729
- * should you choose to use a later version).
4546
+ module Bsb_pkg_types : sig
4547
+ #1 "bsb_pkg_types.mli"
4548
+ (* Copyright (C) 2019- Hongbo Zhang, Authors of ReScript
4730
4549
  *
4731
- * This program is distributed in the hope that it will be useful,
4732
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4733
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4734
- * GNU Lesser General Public License for more details.
4735
- *
4736
- * You should have received a copy of the GNU Lesser General Public License
4737
- * along with this program; if not, write to the Free Software
4738
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
4739
-
4740
- val is_directory_no_exn : string -> bool
4741
-
4742
- val is_windows_or_cygwin : bool
4743
-
4744
- end = struct
4745
- #1 "ext_sys.pp.ml"
4746
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4747
- *
4748
4550
  * This program is free software: you can redistribute it and/or modify
4749
4551
  * it under the terms of the GNU Lesser General Public License as published by
4750
4552
  * the Free Software Foundation, either version 3 of the License, or
@@ -4762,26 +4564,30 @@ end = struct
4762
4564
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
4763
4565
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4764
4566
  * GNU Lesser General Public License for more details.
4765
- *
4567
+ *
4766
4568
  * You should have received a copy of the GNU Lesser General Public License
4767
4569
  * along with this program; if not, write to the Free Software
4768
4570
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
4769
4571
 
4770
- (** TODO: not exported yet, wait for Windows Fix*)
4572
+ type t = Global of string | Scope of string * scope
4771
4573
 
4772
- external is_directory_no_exn : string -> bool = "caml_sys_is_directory_no_exn"
4574
+ and scope = string
4773
4575
 
4576
+ val to_string : t -> string
4774
4577
 
4578
+ val print : Format.formatter -> t -> unit
4775
4579
 
4776
- let is_windows_or_cygwin = Sys.win32 || Sys.cygwin
4580
+ val equal : t -> t -> bool
4777
4581
 
4582
+ (* The second element could be empty or dropped
4583
+ *)
4584
+ val extract_pkg_name_and_file : string -> t * string
4778
4585
 
4586
+ val string_as_package : string -> t
4779
4587
 
4780
- end
4781
- module Literals
4782
- = struct
4783
- #1 "literals.ml"
4784
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4588
+ end = struct
4589
+ #1 "bsb_pkg_types.ml"
4590
+ (* Copyright (C) 2018- Hongbo Zhang, Authors of ReScript
4785
4591
  *
4786
4592
  * This program is free software: you can redistribute it and/or modify
4787
4593
  * it under the terms of the GNU Lesser General Public License as published by
@@ -4805,167 +4611,77 @@ module Literals
4805
4611
  * along with this program; if not, write to the Free Software
4806
4612
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
4807
4613
 
4808
- let js_array_ctor = "Array"
4614
+ let ( // ) = Filename.concat
4809
4615
 
4810
- let js_type_number = "number"
4616
+ type t = Global of string | Scope of string * scope
4811
4617
 
4812
- let js_type_string = "string"
4813
-
4814
- let js_type_object = "object"
4815
-
4816
- let js_type_boolean = "boolean"
4817
-
4818
- let js_undefined = "undefined"
4819
-
4820
- let js_prop_length = "length"
4821
-
4822
- let prim = "prim"
4823
-
4824
- let param = "param"
4825
-
4826
- let partial_arg = "partial_arg"
4827
-
4828
- let tmp = "tmp"
4829
-
4830
- let create = "create" (* {!Caml_exceptions.create}*)
4831
-
4832
- let runtime = "runtime" (* runtime directory *)
4833
-
4834
- let stdlib = "stdlib"
4835
-
4836
- let imul = "imul" (* signed int32 mul *)
4837
-
4838
- let setter_suffix = "#="
4839
-
4840
- let setter_suffix_len = String.length setter_suffix
4841
-
4842
- let debugger = "debugger"
4843
-
4844
- let fn_run = "fn_run"
4845
-
4846
- let method_run = "method_run"
4847
-
4848
- let fn_method = "fn_method"
4849
-
4850
- let fn_mk = "fn_mk"
4851
- (*let js_fn_runmethod = "js_fn_runmethod"*)
4852
-
4853
- (** nodejs *)
4854
- let node_modules = "node_modules"
4855
-
4856
- let node_modules_length = String.length "node_modules"
4857
-
4858
- let package_json = "package.json"
4859
-
4860
- let bsconfig_json = "bsconfig.json"
4861
-
4862
- let build_ninja = "build.ninja"
4863
-
4864
- (* Name of the library file created for each external dependency. *)
4865
- let library_file = "lib"
4866
-
4867
- let suffix_a = ".a"
4868
-
4869
- let suffix_cmj = ".cmj"
4870
-
4871
- let suffix_cmo = ".cmo"
4872
-
4873
- let suffix_cma = ".cma"
4874
-
4875
- let suffix_cmi = ".cmi"
4876
-
4877
- let suffix_cmx = ".cmx"
4878
-
4879
- let suffix_cmxa = ".cmxa"
4880
-
4881
- let suffix_mll = ".mll"
4882
-
4883
- let suffix_ml = ".ml"
4884
-
4885
- let suffix_mli = ".mli"
4886
-
4887
- let suffix_re = ".re"
4888
-
4889
- let suffix_rei = ".rei"
4890
-
4891
- let suffix_res = ".res"
4892
-
4893
- let suffix_resi = ".resi"
4894
-
4895
- let suffix_mlmap = ".mlmap"
4896
-
4897
- let suffix_cmt = ".cmt"
4898
-
4899
- let suffix_cmti = ".cmti"
4900
-
4901
- let suffix_ast = ".ast"
4902
-
4903
- let suffix_iast = ".iast"
4904
-
4905
- let suffix_d = ".d"
4906
-
4907
- let suffix_js = ".js"
4908
-
4909
- let suffix_bs_js = ".bs.js"
4910
-
4911
- let suffix_mjs = ".mjs"
4912
-
4913
- let suffix_cjs = ".cjs"
4914
-
4915
- let suffix_gen_js = ".gen.js"
4916
-
4917
- let suffix_gen_tsx = ".gen.tsx"
4918
-
4919
- let commonjs = "commonjs"
4920
-
4921
- let es6 = "es6"
4922
-
4923
- let es6_global = "es6-global"
4924
-
4925
- let unused_attribute = "Unused attribute "
4926
-
4927
- (** Used when produce node compatible paths *)
4928
- let node_sep = "/"
4929
-
4930
- let node_parent = ".."
4931
-
4932
- let node_current = "."
4618
+ and scope = string
4933
4619
 
4934
- let gentype_import = "genType.import"
4620
+ let to_string (x : t) =
4621
+ match x with Global s -> s | Scope (s, scope) -> scope // s
4935
4622
 
4936
- let bsbuild_cache = ".bsbuild"
4623
+ let print fmt (x : t) =
4624
+ match x with
4625
+ | Global s -> Format.pp_print_string fmt s
4626
+ | Scope (name, scope) -> Format.fprintf fmt "%s/%s" scope name
4937
4627
 
4938
- let sourcedirs_meta = ".sourcedirs.json"
4628
+ let equal (x : t) y =
4629
+ match (x, y) with
4630
+ | Scope (a0, a1), Scope (b0, b1) -> a0 = b0 && a1 = b1
4631
+ | Global a0, Global b0 -> a0 = b0
4632
+ | Scope _, Global _ | Global _, Scope _ -> false
4939
4633
 
4940
- (* Note the build system should check the validity of filenames
4941
- espeically, it should not contain '-'
4634
+ (**
4635
+ input: {[
4636
+ @hello/yy/xx
4637
+ hello/yy
4638
+ ]}
4639
+ FIXME: fix invalid input
4640
+ {[
4641
+ hello//xh//helo
4642
+ ]}
4942
4643
  *)
4943
- let ns_sep_char = '-'
4944
-
4945
- let ns_sep = "-"
4946
-
4947
- let exception_id = "RE_EXN_ID"
4948
-
4949
- let polyvar_hash = "NAME"
4950
-
4951
- let polyvar_value = "VAL"
4952
-
4953
- let cons = "::"
4954
-
4955
- let hd = "hd"
4956
-
4957
- let tl = "tl"
4958
-
4959
- let lazy_done = "LAZY_DONE"
4644
+ let extract_pkg_name_and_file (s : string) =
4645
+ let len = String.length s in
4646
+ assert (len > 0);
4647
+ let v = String.unsafe_get s 0 in
4648
+ if v = '@' then (
4649
+ let scope_id = Ext_string.no_slash_idx s in
4650
+ assert (scope_id > 0);
4651
+ let pkg_id = Ext_string.no_slash_idx_from s (scope_id + 1) in
4652
+ let scope = String.sub s 0 scope_id in
4960
4653
 
4961
- let lazy_val = "VAL"
4654
+ if pkg_id < 0 then
4655
+ (Scope (String.sub s (scope_id + 1) (len - scope_id - 1), scope), "")
4656
+ else
4657
+ ( Scope (String.sub s (scope_id + 1) (pkg_id - scope_id - 1), scope),
4658
+ String.sub s (pkg_id + 1) (len - pkg_id - 1) ))
4659
+ else
4660
+ let pkg_id = Ext_string.no_slash_idx s in
4661
+ if pkg_id < 0 then (Global s, "")
4662
+ else
4663
+ ( Global (String.sub s 0 pkg_id),
4664
+ String.sub s (pkg_id + 1) (len - pkg_id - 1) )
4962
4665
 
4963
- let pure = "@__PURE__"
4666
+ let string_as_package (s : string) : t =
4667
+ let len = String.length s in
4668
+ assert (len > 0);
4669
+ let v = String.unsafe_get s 0 in
4670
+ if v = '@' then (
4671
+ let scope_id = Ext_string.no_slash_idx s in
4672
+ assert (scope_id > 0);
4673
+ (* better-eror message for invalid scope package:
4674
+ @rescript/std
4675
+ *)
4676
+ Scope
4677
+ (String.sub s (scope_id + 1) (len - scope_id - 1), String.sub s 0 scope_id))
4678
+ else Global s
4964
4679
 
4965
4680
  end
4966
- module Ext_path : sig
4967
- #1 "ext_path.mli"
4968
- (* Copyright (C) 2017 Authors of ReScript
4681
+ module Ext_json_types
4682
+ = struct
4683
+ #1 "ext_json_types.ml"
4684
+ (* Copyright (C) 2015-2017 Bloomberg Finance L.P.
4969
4685
  *
4970
4686
  * This program is free software: you can redistribute it and/or modify
4971
4687
  * it under the terms of the GNU Lesser General Public License as published by
@@ -4989,66 +4705,76 @@ module Ext_path : sig
4989
4705
  * along with this program; if not, write to the Free Software
4990
4706
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
4991
4707
 
4992
- type t
4993
-
4994
- val simple_convert_node_path_to_os_path : string -> string
4995
- (** Js_output is node style, which means
4996
- separator is only '/'
4997
-
4998
- if the path contains 'node_modules',
4999
- [node_relative_path] will discard its prefix and
5000
- just treat it as a library instead
5001
- *)
5002
-
5003
- val combine : string -> string -> string
5004
- (**
5005
- [combine path1 path2]
5006
- 1. add some simplifications when concatenating
5007
- 2. when [path2] is absolute, return [path2]
5008
- *)
4708
+ type loc = Lexing.position
5009
4709
 
5010
- (**
5011
- {[
5012
- get_extension "a.txt" = ".txt"
5013
- get_extension "a" = ""
5014
- ]}
5015
- *)
4710
+ type json_str = { str : string; loc : loc }
5016
4711
 
5017
- val node_rebase_file : from:string -> to_:string -> string -> string
4712
+ type json_flo = { flo : string; loc : loc }
5018
4713
 
5019
- val rel_normalized_absolute_path : from:string -> string -> string
5020
- (**
5021
- TODO: could be highly optimized
5022
- if [from] and [to] resolve to the same path, a zero-length string is returned
5023
- Given that two paths are directory
4714
+ type json_array = { content : t array; loc_start : loc; loc_end : loc }
5024
4715
 
5025
- A typical use case is
5026
- {[
5027
- Filename.concat
5028
- (rel_normalized_absolute_path cwd (Filename.dirname a))
5029
- (Filename.basename a)
5030
- ]}
5031
- *)
4716
+ and json_map = { map : t Map_string.t; loc : loc }
5032
4717
 
5033
- val normalize_absolute_path : string -> string
4718
+ and t =
4719
+ | True of loc
4720
+ | False of loc
4721
+ | Null of loc
4722
+ | Flo of json_flo
4723
+ | Str of json_str
4724
+ | Arr of json_array
4725
+ | Obj of json_map
5034
4726
 
5035
- val absolute_cwd_path : string -> string
4727
+ end
4728
+ module Ext_position : sig
4729
+ #1 "ext_position.mli"
4730
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4731
+ *
4732
+ * This program is free software: you can redistribute it and/or modify
4733
+ * it under the terms of the GNU Lesser General Public License as published by
4734
+ * the Free Software Foundation, either version 3 of the License, or
4735
+ * (at your option) any later version.
4736
+ *
4737
+ * In addition to the permissions granted to you by the LGPL, you may combine
4738
+ * or link a "work that uses the Library" with a publicly distributed version
4739
+ * of this file to produce a combined library or application, then distribute
4740
+ * that combined work under the terms of your choosing, with no requirement
4741
+ * to comply with the obligations normally placed on you by section 4 of the
4742
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
4743
+ * should you choose to use a later version).
4744
+ *
4745
+ * This program is distributed in the hope that it will be useful,
4746
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4747
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4748
+ * GNU Lesser General Public License for more details.
4749
+ *
4750
+ * You should have received a copy of the GNU Lesser General Public License
4751
+ * along with this program; if not, write to the Free Software
4752
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5036
4753
 
5037
- val concat : string -> string -> string
5038
- (** [concat dirname filename]
5039
- The same as {!Filename.concat} except a tiny optimization
5040
- for current directory simplification
4754
+ type t = Lexing.position = {
4755
+ pos_fname : string;
4756
+ pos_lnum : int;
4757
+ pos_bol : int;
4758
+ pos_cnum : int;
4759
+ }
4760
+
4761
+ val offset : t -> t -> t
4762
+ (** [offset pos newpos]
4763
+ return a new position
4764
+ here [newpos] is zero based, the use case is that
4765
+ at position [pos], we get a string and Lexing from that string,
4766
+ therefore, we get a [newpos] and we need rebase it on top of
4767
+ [pos]
5041
4768
  *)
5042
4769
 
5043
- val check_suffix_case : string -> string -> bool
4770
+ val lexbuf_from_channel_with_fname : in_channel -> string -> Lexing.lexbuf
5044
4771
 
5045
- (* It is lazy so that it will not hit errors when in script mode *)
5046
- val package_dir : string Lazy.t
4772
+ val print : Format.formatter -> t -> unit
5047
4773
 
5048
4774
  end = struct
5049
- #1 "ext_path.ml"
5050
- (* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
5051
- *
4775
+ #1 "ext_position.ml"
4776
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4777
+ *
5052
4778
  * This program is free software: you can redistribute it and/or modify
5053
4779
  * it under the terms of the GNU Lesser General Public License as published by
5054
4780
  * the Free Software Foundation, either version 3 of the License, or
@@ -5066,267 +4792,102 @@ end = struct
5066
4792
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5067
4793
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5068
4794
  * GNU Lesser General Public License for more details.
5069
- *
4795
+ *
5070
4796
  * You should have received a copy of the GNU Lesser General Public License
5071
4797
  * along with this program; if not, write to the Free Software
5072
4798
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5073
4799
 
5074
- (* [@@@warning "-37"] *)
5075
- type t = (* | File of string *)
5076
- | Dir of string [@@unboxed]
5077
-
5078
- let simple_convert_node_path_to_os_path =
5079
- if Sys.unix then fun x -> x
5080
- else if Sys.win32 || Sys.cygwin then Ext_string.replace_slash_backward
5081
- else failwith ("Unknown OS : " ^ Sys.os_type)
5082
-
5083
- let cwd = lazy (Sys.getcwd ())
5084
-
5085
- let split_by_sep_per_os : string -> string list =
5086
- if Ext_sys.is_windows_or_cygwin then fun x ->
5087
- (* on Windows, we can still accept -bs-package-output lib/js *)
5088
- Ext_string.split_by
5089
- (fun x -> match x with '/' | '\\' -> true | _ -> false)
5090
- x
5091
- else fun x -> Ext_string.split x '/'
4800
+ type t = Lexing.position = {
4801
+ pos_fname : string;
4802
+ pos_lnum : int;
4803
+ pos_bol : int;
4804
+ pos_cnum : int;
4805
+ }
5092
4806
 
5093
- (** example
5094
- {[
5095
- "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj"
5096
- "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml"
5097
- ]}
4807
+ let offset (x : t) (y : t) =
4808
+ {
4809
+ x with
4810
+ pos_lnum = x.pos_lnum + y.pos_lnum - 1;
4811
+ pos_cnum = x.pos_cnum + y.pos_cnum;
4812
+ pos_bol = (if y.pos_lnum = 1 then x.pos_bol else x.pos_cnum + y.pos_bol);
4813
+ }
5098
4814
 
5099
- The other way
5100
- {[
4815
+ let print fmt (pos : t) =
4816
+ Format.fprintf fmt "(line %d, column %d)" pos.pos_lnum
4817
+ (pos.pos_cnum - pos.pos_bol)
5101
4818
 
5102
- "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml"
5103
- "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj"
5104
- ]}
5105
- {[
5106
- "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib//ocaml_array.ml"
5107
- ]}
5108
- {[
5109
- /a/b
5110
- /c/d
5111
- ]}
5112
- *)
5113
- let node_relative_path ~from:(file_or_dir_2 : t) (file_or_dir_1 : t) =
5114
- let relevant_dir1 =
5115
- match file_or_dir_1 with Dir x -> x
5116
- (* | File file1 -> Filename.dirname file1 *)
5117
- in
5118
- let relevant_dir2 =
5119
- match file_or_dir_2 with Dir x -> x
5120
- (* | File file2 -> Filename.dirname file2 *)
5121
- in
5122
- let dir1 = split_by_sep_per_os relevant_dir1 in
5123
- let dir2 = split_by_sep_per_os relevant_dir2 in
5124
- let rec go (dir1 : string list) (dir2 : string list) =
5125
- match (dir1, dir2) with
5126
- | "." :: xs, ys -> go xs ys
5127
- | xs, "." :: ys -> go xs ys
5128
- | x :: xs, y :: ys when x = y -> go xs ys
5129
- | _, _ -> Ext_list.map_append dir2 dir1 (fun _ -> Literals.node_parent)
4819
+ let lexbuf_from_channel_with_fname ic fname =
4820
+ let x = Lexing.from_function (fun buf n -> input ic buf 0 n) in
4821
+ let pos : t =
4822
+ {
4823
+ pos_fname = fname;
4824
+ pos_lnum = 1;
4825
+ pos_bol = 0;
4826
+ pos_cnum = 0 (* copied from zero_pos*);
4827
+ }
5130
4828
  in
5131
- match go dir1 dir2 with
5132
- | x :: _ as ys when x = Literals.node_parent ->
5133
- String.concat Literals.node_sep ys
5134
- | ys -> String.concat Literals.node_sep @@ (Literals.node_current :: ys)
5135
-
5136
- let node_concat ~dir base = dir ^ Literals.node_sep ^ base
4829
+ x.lex_start_p <- pos;
4830
+ x.lex_curr_p <- pos;
4831
+ x
5137
4832
 
5138
- let node_rebase_file ~from ~to_ file =
5139
- node_concat
5140
- ~dir:
5141
- (if from = to_ then Literals.node_current
5142
- else node_relative_path ~from:(Dir from) (Dir to_))
5143
- file
4833
+ end
4834
+ module Ext_json : sig
4835
+ #1 "ext_json.mli"
4836
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4837
+ *
4838
+ * This program is free software: you can redistribute it and/or modify
4839
+ * it under the terms of the GNU Lesser General Public License as published by
4840
+ * the Free Software Foundation, either version 3 of the License, or
4841
+ * (at your option) any later version.
4842
+ *
4843
+ * In addition to the permissions granted to you by the LGPL, you may combine
4844
+ * or link a "work that uses the Library" with a publicly distributed version
4845
+ * of this file to produce a combined library or application, then distribute
4846
+ * that combined work under the terms of your choosing, with no requirement
4847
+ * to comply with the obligations normally placed on you by section 4 of the
4848
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
4849
+ * should you choose to use a later version).
4850
+ *
4851
+ * This program is distributed in the hope that it will be useful,
4852
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4853
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4854
+ * GNU Lesser General Public License for more details.
4855
+ *
4856
+ * You should have received a copy of the GNU Lesser General Public License
4857
+ * along with this program; if not, write to the Free Software
4858
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5144
4859
 
5145
- (***
5146
- {[
5147
- Filename.concat "." "";;
5148
- "./"
5149
- ]}
5150
- *)
5151
- let combine path1 path2 =
5152
- if Filename.is_relative path2 then
5153
- if Ext_string.is_empty path2 then path1
5154
- else if path1 = Filename.current_dir_name then path2
5155
- else if path2 = Filename.current_dir_name then path1
5156
- else Filename.concat path1 path2
5157
- else path2
4860
+ type path = string list
5158
4861
 
5159
- let ( // ) x y =
5160
- if x = Filename.current_dir_name then y
5161
- else if y = Filename.current_dir_name then x
5162
- else Filename.concat x y
4862
+ type status = No_path | Found of Ext_json_types.t | Wrong_type of path
5163
4863
 
5164
- (**
5165
- {[
5166
- split_aux "//ghosg//ghsogh/";;
5167
- - : string * string list = ("/", ["ghosg"; "ghsogh"])
5168
- ]}
5169
- Note that
5170
- {[
5171
- Filename.dirname "/a/" = "/"
5172
- Filename.dirname "/a/b/" = Filename.dirname "/a/b" = "/a"
5173
- ]}
5174
- Special case:
5175
- {[
5176
- basename "//" = "/"
5177
- basename "///" = "/"
5178
- ]}
5179
- {[
5180
- basename "" = "."
5181
- basename "" = "."
5182
- dirname "" = "."
5183
- dirname "" = "."
5184
- ]}
5185
- *)
5186
- let split_aux p =
5187
- let rec go p acc =
5188
- let dir = Filename.dirname p in
5189
- if dir = p then (dir, acc)
5190
- else
5191
- let new_path = Filename.basename p in
5192
- if Ext_string.equal new_path Filename.dir_sep then go dir acc
5193
- (* We could do more path simplification here
5194
- leave to [rel_normalized_absolute_path]
5195
- *)
5196
- else go dir (new_path :: acc)
5197
- in
4864
+ type callback =
4865
+ [ `Str of string -> unit
4866
+ | `Str_loc of string -> Lexing.position -> unit
4867
+ | `Flo of string -> unit
4868
+ | `Flo_loc of string -> Lexing.position -> unit
4869
+ | `Bool of bool -> unit
4870
+ | `Obj of Ext_json_types.t Map_string.t -> unit
4871
+ | `Arr of Ext_json_types.t array -> unit
4872
+ | `Arr_loc of
4873
+ Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit
4874
+ | `Null of unit -> unit
4875
+ | `Not_found of unit -> unit
4876
+ | `Id of Ext_json_types.t -> unit ]
5198
4877
 
5199
- go p []
4878
+ val test :
4879
+ ?fail:(unit -> unit) ->
4880
+ string ->
4881
+ callback ->
4882
+ Ext_json_types.t Map_string.t ->
4883
+ Ext_json_types.t Map_string.t
5200
4884
 
5201
- (**
5202
- TODO: optimization
5203
- if [from] and [to] resolve to the same path, a zero-length string is returned
4885
+ val loc_of : Ext_json_types.t -> Ext_position.t
5204
4886
 
5205
- This function is useed in [es6-global] and
5206
- [amdjs-global] format and tailored for `rollup`
5207
- *)
5208
- let rel_normalized_absolute_path ~from to_ =
5209
- let root1, paths1 = split_aux from in
5210
- let root2, paths2 = split_aux to_ in
5211
- if root1 <> root2 then root2
5212
- else
5213
- let rec go xss yss =
5214
- match (xss, yss) with
5215
- | x :: xs, y :: ys ->
5216
- if Ext_string.equal x y then go xs ys
5217
- else if x = Filename.current_dir_name then go xs yss
5218
- else if y = Filename.current_dir_name then go xss ys
5219
- else
5220
- let start =
5221
- Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ ->
5222
- acc // Ext_string.parent_dir_lit)
5223
- in
5224
- Ext_list.fold_left yss start (fun acc v -> acc // v)
5225
- | [], [] -> Ext_string.empty
5226
- | [], y :: ys -> Ext_list.fold_left ys y (fun acc x -> acc // x)
5227
- | _ :: xs, [] ->
5228
- Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ ->
5229
- acc // Ext_string.parent_dir_lit)
5230
- in
5231
- let v = go paths1 paths2 in
5232
-
5233
- if Ext_string.is_empty v then Literals.node_current
5234
- else if
5235
- v = "." || v = ".."
5236
- || Ext_string.starts_with v "./"
5237
- || Ext_string.starts_with v "../"
5238
- then v
5239
- else "./" ^ v
5240
-
5241
- (*TODO: could be hgighly optimized later
5242
- {[
5243
- normalize_absolute_path "/gsho/./..";;
5244
-
5245
- normalize_absolute_path "/a/b/../c../d/e/f";;
5246
-
5247
- normalize_absolute_path "/gsho/./..";;
5248
-
5249
- normalize_absolute_path "/gsho/./../..";;
5250
-
5251
- normalize_absolute_path "/a/b/c/d";;
5252
-
5253
- normalize_absolute_path "/a/b/c/d/";;
5254
-
5255
- normalize_absolute_path "/a/";;
5256
-
5257
- normalize_absolute_path "/a";;
5258
- ]}
5259
- *)
5260
-
5261
- (** See tests in {!Ounit_path_tests} *)
5262
- let normalize_absolute_path x =
5263
- let drop_if_exist xs = match xs with [] -> [] | _ :: xs -> xs in
5264
- let rec normalize_list acc paths =
5265
- match paths with
5266
- | [] -> acc
5267
- | x :: xs ->
5268
- if Ext_string.equal x Ext_string.current_dir_lit then
5269
- normalize_list acc xs
5270
- else if Ext_string.equal x Ext_string.parent_dir_lit then
5271
- normalize_list (drop_if_exist acc) xs
5272
- else normalize_list (x :: acc) xs
5273
- in
5274
- let root, paths = split_aux x in
5275
- let rev_paths = normalize_list [] paths in
5276
- let rec go acc rev_paths =
5277
- match rev_paths with
5278
- | [] -> Filename.concat root acc
5279
- | last :: rest -> go (Filename.concat last acc) rest
5280
- in
5281
- match rev_paths with [] -> root | last :: rest -> go last rest
5282
-
5283
- let absolute_path cwd s =
5284
- let process s =
5285
- let s = if Filename.is_relative s then Lazy.force cwd // s else s in
5286
- (* Now simplify . and .. components *)
5287
- let rec aux s =
5288
- let base, dir = (Filename.basename s, Filename.dirname s) in
5289
- if dir = s then dir
5290
- else if base = Filename.current_dir_name then aux dir
5291
- else if base = Filename.parent_dir_name then Filename.dirname (aux dir)
5292
- else aux dir // base
5293
- in
5294
- aux s
5295
- in
5296
- process s
5297
-
5298
- let absolute_cwd_path s = absolute_path cwd s
5299
-
5300
- (* let absolute cwd s =
5301
- match s with
5302
- | File x -> File (absolute_path cwd x )
5303
- | Dir x -> Dir (absolute_path cwd x) *)
5304
-
5305
- let concat dirname filename =
5306
- if filename = Filename.current_dir_name then dirname
5307
- else if dirname = Filename.current_dir_name then filename
5308
- else Filename.concat dirname filename
5309
-
5310
- let check_suffix_case = Ext_string.ends_with
5311
-
5312
- (* Input must be absolute directory *)
5313
- let rec find_root_filename ~cwd filename =
5314
- if Sys.file_exists (Filename.concat cwd filename) then cwd
5315
- else
5316
- let cwd' = Filename.dirname cwd in
5317
- if String.length cwd' < String.length cwd then
5318
- find_root_filename ~cwd:cwd' filename
5319
- else Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" filename cwd
5320
-
5321
- let find_package_json_dir cwd = find_root_filename ~cwd Literals.bsconfig_json
5322
-
5323
- let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
5324
-
5325
- end
5326
- module Bsb_config : sig
5327
- #1 "bsb_config.mli"
5328
- (* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
5329
- * Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
4887
+ end = struct
4888
+ #1 "ext_json.ml"
4889
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4890
+ *
5330
4891
  * This program is free software: you can redistribute it and/or modify
5331
4892
  * it under the terms of the GNU Lesser General Public License as published by
5332
4893
  * the Free Software Foundation, either version 3 of the License, or
@@ -5344,39 +4905,60 @@ module Bsb_config : sig
5344
4905
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5345
4906
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5346
4907
  * GNU Lesser General Public License for more details.
5347
- *
4908
+ *
5348
4909
  * You should have received a copy of the GNU Lesser General Public License
5349
4910
  * along with this program; if not, write to the Free Software
5350
4911
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5351
4912
 
5352
- val ocaml_bin_install_prefix : string -> string
5353
-
5354
- val proj_rel : string -> string
5355
-
5356
- val lib_lit : string
5357
-
5358
- val lib_js : string
5359
-
5360
- val lib_bs : string
5361
-
5362
- val lib_es6 : string
5363
-
5364
- val lib_es6_global : string
5365
-
5366
- val lib_ocaml : string
4913
+ type callback =
4914
+ [ `Str of string -> unit
4915
+ | `Str_loc of string -> Lexing.position -> unit
4916
+ | `Flo of string -> unit
4917
+ | `Flo_loc of string -> Lexing.position -> unit
4918
+ | `Bool of bool -> unit
4919
+ | `Obj of Ext_json_types.t Map_string.t -> unit
4920
+ | `Arr of Ext_json_types.t array -> unit
4921
+ | `Arr_loc of
4922
+ Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit
4923
+ | `Null of unit -> unit
4924
+ | `Not_found of unit -> unit
4925
+ | `Id of Ext_json_types.t -> unit ]
5367
4926
 
5368
- val all_lib_artifacts : string list
4927
+ type path = string list
5369
4928
 
5370
- (* we need generate path relative to [lib/bs] directory in the opposite direction *)
5371
- val rev_lib_bs_prefix : string -> string
4929
+ type status = No_path | Found of Ext_json_types.t | Wrong_type of path
5372
4930
 
5373
- val lib_bs_prefix_of_format : Ext_module_system.t -> string
4931
+ let test ?(fail = fun () -> ()) key (cb : callback)
4932
+ (m : Ext_json_types.t Map_string.t) =
4933
+ (match (Map_string.find_exn m key, cb) with
4934
+ | exception Not_found -> (
4935
+ match cb with `Not_found f -> f () | _ -> fail ())
4936
+ | True _, `Bool cb -> cb true
4937
+ | False _, `Bool cb -> cb false
4938
+ | Flo { flo = s }, `Flo cb -> cb s
4939
+ | Flo { flo = s; loc }, `Flo_loc cb -> cb s loc
4940
+ | Obj { map = b }, `Obj cb -> cb b
4941
+ | Arr { content }, `Arr cb -> cb content
4942
+ | Arr { content; loc_start; loc_end }, `Arr_loc cb ->
4943
+ cb content loc_start loc_end
4944
+ | Null _, `Null cb -> cb ()
4945
+ | Str { str = s }, `Str cb -> cb s
4946
+ | Str { str = s; loc }, `Str_loc cb -> cb s loc
4947
+ | any, `Id cb -> cb any
4948
+ | _, _ -> fail ());
4949
+ m
5374
4950
 
5375
- val top_prefix_of_format : Ext_module_system.t -> string
5376
- (** default not install, only when -make-world, its dependencies will be installed *)
4951
+ let loc_of (x : Ext_json_types.t) =
4952
+ match x with
4953
+ | True p | False p | Null p -> p
4954
+ | Str p -> p.loc
4955
+ | Arr p -> p.loc_start
4956
+ | Obj p -> p.loc
4957
+ | Flo p -> p.loc
5377
4958
 
5378
- end = struct
5379
- #1 "bsb_config.ml"
4959
+ end
4960
+ module Bsb_exception : sig
4961
+ #1 "bsb_exception.mli"
5380
4962
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5381
4963
  * Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
5382
4964
  * This program is free software: you can redistribute it and/or modify
@@ -5396,59 +4978,40 @@ end = struct
5396
4978
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5397
4979
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5398
4980
  * GNU Lesser General Public License for more details.
5399
- *
4981
+ *
5400
4982
  * You should have received a copy of the GNU Lesser General Public License
5401
4983
  * along with this program; if not, write to the Free Software
5402
4984
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5403
- let ( // ) = Ext_path.combine
5404
-
5405
- let lib_lit = "lib"
5406
4985
 
5407
- let lib_js = lib_lit // "js"
5408
-
5409
- let lib_ocaml = lib_lit // "ocaml"
5410
-
5411
- let lib_bs = lib_lit // "bs"
5412
-
5413
- let lib_es6 = lib_lit // "es6"
4986
+ type error
4987
+ (**
4988
+ This module is used for fatal errros
4989
+ *)
5414
4990
 
5415
- let lib_es6_global = lib_lit // "es6_global"
4991
+ exception Error of error
5416
4992
 
5417
- let all_lib_artifacts = [ lib_js; lib_ocaml; lib_bs; lib_es6; lib_es6_global ]
4993
+ val print : Format.formatter -> error -> unit
5418
4994
 
5419
- let rev_lib_bs = ".." // ".."
4995
+ val package_not_found : pkg:Bsb_pkg_types.t -> json:string option -> 'a
5420
4996
 
5421
- (* access the js directory from "lib/bs",
5422
- it would be '../js'
5423
- *)
5424
- let lib_bs_prefix_of_format (x : Ext_module_system.t) =
5425
- ".."
5426
- // match x with NodeJS -> "js" | Es6 -> "es6" | Es6_global -> "es6_global"
4997
+ val conflict_module : string -> string -> string -> exn
5427
4998
 
5428
- (* lib/js, lib/es6, lib/es6_global *)
5429
- let top_prefix_of_format (x : Ext_module_system.t) =
5430
- match x with
5431
- | NodeJS -> lib_js
5432
- | Es6 -> lib_es6
5433
- | Es6_global -> lib_es6_global
4999
+ val errorf : loc:Ext_position.t -> ('a, unit, string, 'b) format4 -> 'a
5434
5000
 
5435
- let rev_lib_bs_prefix p = rev_lib_bs // p
5001
+ val config_error : Ext_json_types.t -> string -> 'a
5436
5002
 
5437
- let ocaml_bin_install_prefix p = lib_ocaml // p
5003
+ val invalid_spec : string -> 'a
5438
5004
 
5439
- let proj_rel path = rev_lib_bs // path
5005
+ val invalid_json : string -> 'a
5440
5006
 
5441
- (** it may not be a bad idea to hard code the binary path
5442
- of bsb in configuration time
5443
- *)
5007
+ val no_implementation : string -> 'a
5444
5008
 
5445
- (* let cmd_package_specs = ref None *)
5009
+ val not_consistent : string -> 'a
5446
5010
 
5447
- end
5448
- module Bs_version : sig
5449
- #1 "bs_version.mli"
5011
+ end = struct
5012
+ #1 "bsb_exception.ml"
5450
5013
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5451
- *
5014
+ * Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
5452
5015
  * This program is free software: you can redistribute it and/or modify
5453
5016
  * it under the terms of the GNU Lesser General Public License as published by
5454
5017
  * the Free Software Foundation, either version 3 of the License, or
@@ -5471,46 +5034,199 @@ module Bs_version : sig
5471
5034
  * along with this program; if not, write to the Free Software
5472
5035
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5473
5036
 
5474
- val version : string
5475
-
5476
- val header : string
5477
-
5478
- val package_name : string ref
5479
-
5480
- end = struct
5481
- #1 "bs_version.ml"
5482
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5483
- *
5484
- * This program is free software: you can redistribute it and/or modify
5485
- * it under the terms of the GNU Lesser General Public License as published by
5486
- * the Free Software Foundation, either version 3 of the License, or
5487
- * (at your option) any later version.
5488
- *
5489
- * In addition to the permissions granted to you by the LGPL, you may combine
5490
- * or link a "work that uses the Library" with a publicly distributed version
5491
- * of this file to produce a combined library or application, then distribute
5492
- * that combined work under the terms of your choosing, with no requirement
5493
- * to comply with the obligations normally placed on you by section 4 of the
5494
- * LGPL version 3 (or the corresponding section of a later version of the LGPL
5495
- * should you choose to use a later version).
5496
- *
5497
- * This program is distributed in the hope that it will be useful,
5498
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
5499
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5500
- * GNU Lesser General Public License for more details.
5501
- *
5502
- * You should have received a copy of the GNU Lesser General Public License
5503
- * along with this program; if not, write to the Free Software
5504
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5505
- let version = "10.1.0-alpha.1"
5506
- let header = "// Generated by ReScript, PLEASE EDIT WITH CARE"
5507
- let package_name = ref "rescript"
5037
+ type error =
5038
+ | Package_not_found of Bsb_pkg_types.t * string option (* json file *)
5039
+ | Json_config of Ext_position.t * string
5040
+ | Invalid_json of string
5041
+ | Invalid_spec of string
5042
+ | Conflict_module of string * string * string
5043
+ | No_implementation of string
5044
+ | Not_consistent of string
5045
+
5046
+ exception Error of error
5047
+
5048
+ let error err = raise (Error err)
5049
+
5050
+ let package_not_found ~pkg ~json = error (Package_not_found (pkg, json))
5051
+
5052
+ let print (fmt : Format.formatter) (x : error) =
5053
+ match x with
5054
+ | Conflict_module (modname, dir1, dir2) ->
5055
+ Format.fprintf fmt
5056
+ "@{<error>Error:@} %s found in two directories: (%s, %s)\n\
5057
+ File names must be unique per project" modname dir1 dir2
5058
+ | Not_consistent modname ->
5059
+ Format.fprintf fmt
5060
+ "@{<error>Error:@} %s has implementation/interface in non-consistent \
5061
+ syntax(reason/ocaml)"
5062
+ modname
5063
+ | No_implementation modname ->
5064
+ Format.fprintf fmt
5065
+ "@{<error>Error:@} %s does not have implementation file" modname
5066
+ | Package_not_found (name, json_opt) ->
5067
+ let in_json =
5068
+ match json_opt with None -> Ext_string.empty | Some x -> " in " ^ x
5069
+ in
5070
+ let name = Bsb_pkg_types.to_string name in
5071
+ if Ext_string.equal name !Bs_version.package_name then
5072
+ Format.fprintf fmt
5073
+ "File \"bsconfig.json\", line 1\n\
5074
+ @{<error>Error:@} package @{<error>%s@} is not found %s\n\
5075
+ It's the basic, required package. If you have it installed globally,\n\
5076
+ Please run `npm link rescript` to make it available" name in_json
5077
+ else
5078
+ Format.fprintf fmt
5079
+ "File \"bsconfig.json\", line 1\n\
5080
+ @{<error>Error:@} package @{<error>%s@} not found or built %s\n\
5081
+ - Did you install it?\n\
5082
+ - If you did, did you run `rescript build -with-deps`?" name in_json
5083
+ | Json_config (pos, s) ->
5084
+ Format.fprintf fmt
5085
+ "File %S, line %d:\n\
5086
+ @{<error>Error:@} %s \n\
5087
+ For more details, please checkout the schema \
5088
+ https://rescript-lang.org/docs/manual/latest/build-configuration-schema"
5089
+ pos.pos_fname pos.pos_lnum s
5090
+ | Invalid_spec s ->
5091
+ Format.fprintf fmt "@{<error>Error: Invalid bsconfig.json %s@}" s
5092
+ | Invalid_json s ->
5093
+ Format.fprintf fmt
5094
+ "File %S, line 1\n@{<error>Error: Invalid json format@}" s
5095
+
5096
+ let conflict_module modname dir1 dir2 =
5097
+ Error (Conflict_module (modname, dir1, dir2))
5098
+
5099
+ let no_implementation modname = error (No_implementation modname)
5100
+
5101
+ let not_consistent modname = error (Not_consistent modname)
5102
+
5103
+ let errorf ~loc fmt =
5104
+ Format.ksprintf (fun s -> error (Json_config (loc, s))) fmt
5105
+
5106
+ let config_error config fmt =
5107
+ let loc = Ext_json.loc_of config in
5108
+
5109
+ error (Json_config (loc, fmt))
5110
+
5111
+ let invalid_spec s = error (Invalid_spec s)
5112
+
5113
+ let invalid_json s = error (Invalid_json s)
5114
+
5115
+ let () =
5116
+ Printexc.register_printer (fun x ->
5117
+ match x with Error x -> Some (Format.asprintf "%a" print x) | _ -> None)
5508
5118
 
5509
5119
  end
5510
- module Bsb_pkg_types : sig
5511
- #1 "bsb_pkg_types.mli"
5512
- (* Copyright (C) 2019- Hongbo Zhang, Authors of ReScript
5513
- *
5120
+ module Bsb_jsx
5121
+ = struct
5122
+ #1 "bsb_jsx.ml"
5123
+ type version = Jsx_v3 | Jsx_v4
5124
+ type module_ = React
5125
+ type mode = Classic | Automatic
5126
+ type dependencies = string list
5127
+
5128
+ type t = {
5129
+ version : version option;
5130
+ module_ : module_ option;
5131
+ mode : mode option;
5132
+ v3_dependencies : dependencies;
5133
+ }
5134
+
5135
+ let encode_no_nl jsx =
5136
+ (match jsx.version with
5137
+ | None -> ""
5138
+ | Some Jsx_v3 -> "3"
5139
+ | Some Jsx_v4 -> "4")
5140
+ ^ (match jsx.module_ with None -> "" | Some React -> "React")
5141
+ ^
5142
+ match jsx.mode with
5143
+ | None -> ""
5144
+ | Some Classic -> "Classic"
5145
+ | Some Automatic -> "Automatic"
5146
+
5147
+ let ( .?() ) = Map_string.find_opt
5148
+ let ( |? ) m (key, cb) = m |> Ext_json.test key cb
5149
+
5150
+ let get_list_string_acc (s : Ext_json_types.t array) acc =
5151
+ Ext_array.to_list_map_acc s acc (fun x ->
5152
+ match x with Str x -> Some x.str | _ -> None)
5153
+
5154
+ let get_list_string s = get_list_string_acc s []
5155
+
5156
+ let from_map map =
5157
+ let version : version option ref = ref None in
5158
+ let module_ : module_ option ref = ref None in
5159
+ let mode : mode option ref = ref None in
5160
+ let v3_dependencies : dependencies ref = ref [] in
5161
+ map
5162
+ |? ( Bsb_build_schemas.jsx,
5163
+ `Obj
5164
+ (fun m ->
5165
+ match m.?(Bsb_build_schemas.jsx_version) with
5166
+ | Some (Flo { loc; flo }) -> (
5167
+ match flo with
5168
+ | "3" -> version := Some Jsx_v3
5169
+ | "4" -> version := Some Jsx_v4
5170
+ | _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo
5171
+ )
5172
+ | Some x ->
5173
+ Bsb_exception.config_error x
5174
+ "Unexpected input (expect a version number) for jsx version"
5175
+ | None -> ()) )
5176
+ |? ( Bsb_build_schemas.jsx,
5177
+ `Obj
5178
+ (fun m ->
5179
+ match m.?(Bsb_build_schemas.jsx_module) with
5180
+ | Some (Str { loc; str }) -> (
5181
+ match str with
5182
+ | "react" -> module_ := Some React
5183
+ | _ -> Bsb_exception.errorf ~loc "Unsupported jsx module %s" str)
5184
+ | Some x ->
5185
+ Bsb_exception.config_error x
5186
+ "Unexpected input (jsx module name) for jsx module"
5187
+ | None -> ()) )
5188
+ |? ( Bsb_build_schemas.jsx,
5189
+ `Obj
5190
+ (fun m ->
5191
+ match m.?(Bsb_build_schemas.jsx_mode) with
5192
+ | Some (Str { loc; str }) -> (
5193
+ match str with
5194
+ | "classic" -> mode := Some Classic
5195
+ | "automatic" -> mode := Some Automatic
5196
+ | _ -> Bsb_exception.errorf ~loc "Unsupported jsx mode %s" str)
5197
+ | Some x ->
5198
+ Bsb_exception.config_error x
5199
+ "Unexpected input (expect classic or automatic) for jsx mode"
5200
+ | None -> ()) )
5201
+ |? ( Bsb_build_schemas.jsx,
5202
+ `Obj
5203
+ (fun m ->
5204
+ match m.?(Bsb_build_schemas.jsx_v3_dependencies) with
5205
+ | Some (Arr { content }) ->
5206
+ v3_dependencies := get_list_string content
5207
+ | Some x ->
5208
+ Bsb_exception.config_error x
5209
+ "Unexpected input for jsx v3-dependencies"
5210
+ | None -> ()) )
5211
+ |> ignore;
5212
+ {
5213
+ version = !version;
5214
+ module_ = !module_;
5215
+ mode = !mode;
5216
+ v3_dependencies = !v3_dependencies;
5217
+ }
5218
+
5219
+ end
5220
+ module Ext_module_system
5221
+ = struct
5222
+ #1 "ext_module_system.ml"
5223
+ type t = NodeJS | Es6 | Es6_global
5224
+
5225
+ end
5226
+ module Ext_pervasives : sig
5227
+ #1 "ext_pervasives.mli"
5228
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5229
+ *
5514
5230
  * This program is free software: you can redistribute it and/or modify
5515
5231
  * it under the terms of the GNU Lesser General Public License as published by
5516
5232
  * the Free Software Foundation, either version 3 of the License, or
@@ -5528,31 +5244,45 @@ module Bsb_pkg_types : sig
5528
5244
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5529
5245
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5530
5246
  * GNU Lesser General Public License for more details.
5531
- *
5247
+ *
5532
5248
  * You should have received a copy of the GNU Lesser General Public License
5533
5249
  * along with this program; if not, write to the Free Software
5534
5250
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5535
5251
 
5536
- type t = Global of string | Scope of string * scope
5252
+ (** Extension to standard library [Pervavives] module, safe to open
5253
+ *)
5537
5254
 
5538
- and scope = string
5255
+ external reraise : exn -> 'a = "%reraise"
5539
5256
 
5540
- val to_string : t -> string
5257
+ val finally : 'a -> clean:('a -> unit) -> ('a -> 'b) -> 'b
5541
5258
 
5542
- val print : Format.formatter -> t -> unit
5259
+ (* val try_it : (unit -> 'a) -> unit *)
5543
5260
 
5544
- val equal : t -> t -> bool
5261
+ val with_file_as_chan : string -> (out_channel -> 'a) -> 'a
5545
5262
 
5546
- (* The second element could be empty or dropped
5263
+ val max_int : int -> int -> int
5264
+
5265
+ val min_int : int -> int -> int
5266
+
5267
+ val max_int_option : int option -> int option -> int option
5268
+
5269
+ (* external id : 'a -> 'a = "%identity" *)
5270
+
5271
+ (** Copied from {!Btype.hash_variant}:
5272
+ need sync up and add test case
5547
5273
  *)
5548
- val extract_pkg_name_and_file : string -> t * string
5274
+ (* val hash_variant : string -> int *)
5549
5275
 
5550
- val string_as_package : string -> t
5276
+ (* val todo : string -> 'a *)
5277
+
5278
+ val nat_of_string_exn : string -> int
5279
+
5280
+ val parse_nat_of_string : string -> int ref -> int
5551
5281
 
5552
5282
  end = struct
5553
- #1 "bsb_pkg_types.ml"
5554
- (* Copyright (C) 2018- Hongbo Zhang, Authors of ReScript
5555
- *
5283
+ #1 "ext_pervasives.ml"
5284
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5285
+ *
5556
5286
  * This program is free software: you can redistribute it and/or modify
5557
5287
  * it under the terms of the GNU Lesser General Public License as published by
5558
5288
  * the Free Software Foundation, either version 3 of the License, or
@@ -5570,82 +5300,104 @@ end = struct
5570
5300
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5571
5301
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5572
5302
  * GNU Lesser General Public License for more details.
5573
- *
5303
+ *
5574
5304
  * You should have received a copy of the GNU Lesser General Public License
5575
5305
  * along with this program; if not, write to the Free Software
5576
5306
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5577
5307
 
5578
- let ( // ) = Filename.concat
5308
+ external reraise : exn -> 'a = "%reraise"
5579
5309
 
5580
- type t = Global of string | Scope of string * scope
5310
+ let finally v ~clean:action f =
5311
+ match f v with
5312
+ | exception e ->
5313
+ action v;
5314
+ reraise e
5315
+ | e ->
5316
+ action v;
5317
+ e
5581
5318
 
5582
- and scope = string
5319
+ (* let try_it f =
5320
+ try ignore (f ()) with _ -> () *)
5583
5321
 
5584
- let to_string (x : t) =
5585
- match x with Global s -> s | Scope (s, scope) -> scope // s
5322
+ let with_file_as_chan filename f =
5323
+ finally (open_out_bin filename) ~clean:close_out f
5586
5324
 
5587
- let print fmt (x : t) =
5588
- match x with
5589
- | Global s -> Format.pp_print_string fmt s
5590
- | Scope (name, scope) -> Format.fprintf fmt "%s/%s" scope name
5325
+ let max_int (x : int) y = if x >= y then x else y
5591
5326
 
5592
- let equal (x : t) y =
5593
- match (x, y) with
5594
- | Scope (a0, a1), Scope (b0, b1) -> a0 = b0 && a1 = b1
5595
- | Global a0, Global b0 -> a0 = b0
5596
- | Scope _, Global _ | Global _, Scope _ -> false
5327
+ let min_int (x : int) y = if x < y then x else y
5597
5328
 
5598
- (**
5599
- input: {[
5600
- @hello/yy/xx
5601
- hello/yy
5602
- ]}
5603
- FIXME: fix invalid input
5604
- {[
5605
- hello//xh//helo
5606
- ]}
5329
+ let max_int_option (x : int option) y =
5330
+ match (x, y) with
5331
+ | None, _ -> y
5332
+ | Some _, None -> x
5333
+ | Some x0, Some y0 -> if x0 >= y0 then x else y
5334
+
5335
+ (* external id : 'a -> 'a = "%identity" *)
5336
+
5337
+ (*
5338
+ let hash_variant s =
5339
+ let accu = ref 0 in
5340
+ for i = 0 to String.length s - 1 do
5341
+ accu := 223 * !accu + Char.code s.[i]
5342
+ done;
5343
+ (* reduce to 31 bits *)
5344
+ accu := !accu land (1 lsl 31 - 1);
5345
+ (* make it signed for 64 bits architectures *)
5346
+ if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu *)
5347
+
5348
+ (* let todo loc =
5349
+ failwith (loc ^ " Not supported yet")
5607
5350
  *)
5608
- let extract_pkg_name_and_file (s : string) =
5609
- let len = String.length s in
5610
- assert (len > 0);
5611
- let v = String.unsafe_get s 0 in
5612
- if v = '@' then (
5613
- let scope_id = Ext_string.no_slash_idx s in
5614
- assert (scope_id > 0);
5615
- let pkg_id = Ext_string.no_slash_idx_from s (scope_id + 1) in
5616
- let scope = String.sub s 0 scope_id in
5617
5351
 
5618
- if pkg_id < 0 then
5619
- (Scope (String.sub s (scope_id + 1) (len - scope_id - 1), scope), "")
5620
- else
5621
- ( Scope (String.sub s (scope_id + 1) (pkg_id - scope_id - 1), scope),
5622
- String.sub s (pkg_id + 1) (len - pkg_id - 1) ))
5352
+ let rec int_of_string_aux s acc off len =
5353
+ if off >= len then acc
5623
5354
  else
5624
- let pkg_id = Ext_string.no_slash_idx s in
5625
- if pkg_id < 0 then (Global s, "")
5626
- else
5627
- ( Global (String.sub s 0 pkg_id),
5628
- String.sub s (pkg_id + 1) (len - pkg_id - 1) )
5355
+ let d = Char.code (String.unsafe_get s off) - 48 in
5356
+ if d >= 0 && d <= 9 then int_of_string_aux s ((10 * acc) + d) (off + 1) len
5357
+ else -1
5358
+ (* error *)
5629
5359
 
5630
- let string_as_package (s : string) : t =
5631
- let len = String.length s in
5632
- assert (len > 0);
5633
- let v = String.unsafe_get s 0 in
5634
- if v = '@' then (
5635
- let scope_id = Ext_string.no_slash_idx s in
5636
- assert (scope_id > 0);
5637
- (* better-eror message for invalid scope package:
5638
- @rescript/std
5639
- *)
5640
- Scope
5641
- (String.sub s (scope_id + 1) (len - scope_id - 1), String.sub s 0 scope_id))
5642
- else Global s
5360
+ let nat_of_string_exn (s : string) =
5361
+ let acc = int_of_string_aux s 0 0 (String.length s) in
5362
+ if acc < 0 then invalid_arg s else acc
5363
+
5364
+ (** return index *)
5365
+ let parse_nat_of_string (s : string) (cursor : int ref) =
5366
+ let current = !cursor in
5367
+ assert (current >= 0);
5368
+ let acc = ref 0 in
5369
+ let s_len = String.length s in
5370
+ let todo = ref true in
5371
+ let cur = ref current in
5372
+ while !todo && !cursor < s_len do
5373
+ let d = Char.code (String.unsafe_get s !cur) - 48 in
5374
+ if d >= 0 && d <= 9 then (
5375
+ acc := (10 * !acc) + d;
5376
+ incr cur)
5377
+ else todo := false
5378
+ done;
5379
+ cursor := !cur;
5380
+ !acc
5643
5381
 
5644
5382
  end
5645
- module Ext_json_types
5383
+ module Ext_fmt
5646
5384
  = struct
5647
- #1 "ext_json_types.ml"
5648
- (* Copyright (C) 2015-2017 Bloomberg Finance L.P.
5385
+ #1 "ext_fmt.ml"
5386
+ let with_file_as_pp filename f =
5387
+ Ext_pervasives.finally (open_out_bin filename) ~clean:close_out (fun chan ->
5388
+ let fmt = Format.formatter_of_out_channel chan in
5389
+ let v = f fmt in
5390
+ Format.pp_print_flush fmt ();
5391
+ v)
5392
+
5393
+ let failwithf ~loc fmt = Format.ksprintf (fun s -> failwith (loc ^ s)) fmt
5394
+
5395
+ let invalid_argf fmt = Format.ksprintf invalid_arg fmt
5396
+
5397
+ end
5398
+ module Ext_sys : sig
5399
+ #1 "ext_sys.mli"
5400
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5649
5401
  *
5650
5402
  * This program is free software: you can redistribute it and/or modify
5651
5403
  * it under the terms of the GNU Lesser General Public License as published by
@@ -5669,30 +5421,14 @@ module Ext_json_types
5669
5421
  * along with this program; if not, write to the Free Software
5670
5422
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5671
5423
 
5672
- type loc = Lexing.position
5673
-
5674
- type json_str = { str : string; loc : loc }
5675
-
5676
- type json_flo = { flo : string; loc : loc }
5677
-
5678
- type json_array = { content : t array; loc_start : loc; loc_end : loc }
5679
-
5680
- and json_map = { map : t Map_string.t; loc : loc }
5424
+ val is_directory_no_exn : string -> bool
5681
5425
 
5682
- and t =
5683
- | True of loc
5684
- | False of loc
5685
- | Null of loc
5686
- | Flo of json_flo
5687
- | Str of json_str
5688
- | Arr of json_array
5689
- | Obj of json_map
5426
+ val is_windows_or_cygwin : bool
5690
5427
 
5691
- end
5692
- module Ext_position : sig
5693
- #1 "ext_position.mli"
5428
+ end = struct
5429
+ #1 "ext_sys.pp.ml"
5694
5430
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5695
- *
5431
+ *
5696
5432
  * This program is free software: you can redistribute it and/or modify
5697
5433
  * it under the terms of the GNU Lesser General Public License as published by
5698
5434
  * the Free Software Foundation, either version 3 of the License, or
@@ -5710,33 +5446,25 @@ module Ext_position : sig
5710
5446
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5711
5447
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5712
5448
  * GNU Lesser General Public License for more details.
5713
- *
5449
+ *
5714
5450
  * You should have received a copy of the GNU Lesser General Public License
5715
5451
  * along with this program; if not, write to the Free Software
5716
5452
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5717
5453
 
5718
- type t = Lexing.position = {
5719
- pos_fname : string;
5720
- pos_lnum : int;
5721
- pos_bol : int;
5722
- pos_cnum : int;
5723
- }
5454
+ (** TODO: not exported yet, wait for Windows Fix*)
5724
5455
 
5725
- val offset : t -> t -> t
5726
- (** [offset pos newpos]
5727
- return a new position
5728
- here [newpos] is zero based, the use case is that
5729
- at position [pos], we get a string and Lexing from that string,
5730
- therefore, we get a [newpos] and we need rebase it on top of
5731
- [pos]
5732
- *)
5456
+ external is_directory_no_exn : string -> bool = "caml_sys_is_directory_no_exn"
5733
5457
 
5734
- val lexbuf_from_channel_with_fname : in_channel -> string -> Lexing.lexbuf
5735
5458
 
5736
- val print : Format.formatter -> t -> unit
5737
5459
 
5738
- end = struct
5739
- #1 "ext_position.ml"
5460
+ let is_windows_or_cygwin = Sys.win32 || Sys.cygwin
5461
+
5462
+
5463
+
5464
+ end
5465
+ module Literals
5466
+ = struct
5467
+ #1 "literals.ml"
5740
5468
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5741
5469
  *
5742
5470
  * This program is free software: you can redistribute it and/or modify
@@ -5761,100 +5489,176 @@ end = struct
5761
5489
  * along with this program; if not, write to the Free Software
5762
5490
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5763
5491
 
5764
- type t = Lexing.position = {
5765
- pos_fname : string;
5766
- pos_lnum : int;
5767
- pos_bol : int;
5768
- pos_cnum : int;
5769
- }
5492
+ let js_array_ctor = "Array"
5770
5493
 
5771
- let offset (x : t) (y : t) =
5772
- {
5773
- x with
5774
- pos_lnum = x.pos_lnum + y.pos_lnum - 1;
5775
- pos_cnum = x.pos_cnum + y.pos_cnum;
5776
- pos_bol = (if y.pos_lnum = 1 then x.pos_bol else x.pos_cnum + y.pos_bol);
5777
- }
5494
+ let js_type_number = "number"
5778
5495
 
5779
- let print fmt (pos : t) =
5780
- Format.fprintf fmt "(line %d, column %d)" pos.pos_lnum
5781
- (pos.pos_cnum - pos.pos_bol)
5496
+ let js_type_string = "string"
5782
5497
 
5783
- let lexbuf_from_channel_with_fname ic fname =
5784
- let x = Lexing.from_function (fun buf n -> input ic buf 0 n) in
5785
- let pos : t =
5786
- {
5787
- pos_fname = fname;
5788
- pos_lnum = 1;
5789
- pos_bol = 0;
5790
- pos_cnum = 0 (* copied from zero_pos*);
5791
- }
5792
- in
5793
- x.lex_start_p <- pos;
5794
- x.lex_curr_p <- pos;
5795
- x
5498
+ let js_type_object = "object"
5796
5499
 
5797
- end
5798
- module Ext_json : sig
5799
- #1 "ext_json.mli"
5800
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5801
- *
5802
- * This program is free software: you can redistribute it and/or modify
5803
- * it under the terms of the GNU Lesser General Public License as published by
5804
- * the Free Software Foundation, either version 3 of the License, or
5805
- * (at your option) any later version.
5806
- *
5807
- * In addition to the permissions granted to you by the LGPL, you may combine
5808
- * or link a "work that uses the Library" with a publicly distributed version
5809
- * of this file to produce a combined library or application, then distribute
5810
- * that combined work under the terms of your choosing, with no requirement
5811
- * to comply with the obligations normally placed on you by section 4 of the
5812
- * LGPL version 3 (or the corresponding section of a later version of the LGPL
5813
- * should you choose to use a later version).
5814
- *
5815
- * This program is distributed in the hope that it will be useful,
5816
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
5817
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5818
- * GNU Lesser General Public License for more details.
5819
- *
5820
- * You should have received a copy of the GNU Lesser General Public License
5821
- * along with this program; if not, write to the Free Software
5822
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5500
+ let js_type_boolean = "boolean"
5823
5501
 
5824
- type path = string list
5502
+ let js_undefined = "undefined"
5825
5503
 
5826
- type status = No_path | Found of Ext_json_types.t | Wrong_type of path
5504
+ let js_prop_length = "length"
5827
5505
 
5828
- type callback =
5829
- [ `Str of string -> unit
5830
- | `Str_loc of string -> Lexing.position -> unit
5831
- | `Flo of string -> unit
5832
- | `Flo_loc of string -> Lexing.position -> unit
5833
- | `Bool of bool -> unit
5834
- | `Obj of Ext_json_types.t Map_string.t -> unit
5835
- | `Arr of Ext_json_types.t array -> unit
5836
- | `Arr_loc of
5837
- Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit
5838
- | `Null of unit -> unit
5839
- | `Not_found of unit -> unit
5840
- | `Id of Ext_json_types.t -> unit ]
5506
+ let prim = "prim"
5841
5507
 
5842
- val test :
5843
- ?fail:(unit -> unit) ->
5844
- string ->
5845
- callback ->
5846
- Ext_json_types.t Map_string.t ->
5847
- Ext_json_types.t Map_string.t
5508
+ let param = "param"
5848
5509
 
5849
- val loc_of : Ext_json_types.t -> Ext_position.t
5510
+ let partial_arg = "partial_arg"
5850
5511
 
5851
- end = struct
5852
- #1 "ext_json.ml"
5853
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5854
- *
5855
- * This program is free software: you can redistribute it and/or modify
5856
- * it under the terms of the GNU Lesser General Public License as published by
5857
- * the Free Software Foundation, either version 3 of the License, or
5512
+ let tmp = "tmp"
5513
+
5514
+ let create = "create" (* {!Caml_exceptions.create}*)
5515
+
5516
+ let runtime = "runtime" (* runtime directory *)
5517
+
5518
+ let stdlib = "stdlib"
5519
+
5520
+ let imul = "imul" (* signed int32 mul *)
5521
+
5522
+ let setter_suffix = "#="
5523
+
5524
+ let setter_suffix_len = String.length setter_suffix
5525
+
5526
+ let debugger = "debugger"
5527
+
5528
+ let fn_run = "fn_run"
5529
+
5530
+ let method_run = "method_run"
5531
+
5532
+ let fn_method = "fn_method"
5533
+
5534
+ let fn_mk = "fn_mk"
5535
+ (*let js_fn_runmethod = "js_fn_runmethod"*)
5536
+
5537
+ (** nodejs *)
5538
+ let node_modules = "node_modules"
5539
+
5540
+ let node_modules_length = String.length "node_modules"
5541
+
5542
+ let package_json = "package.json"
5543
+
5544
+ let bsconfig_json = "bsconfig.json"
5545
+
5546
+ let build_ninja = "build.ninja"
5547
+
5548
+ (* Name of the library file created for each external dependency. *)
5549
+ let library_file = "lib"
5550
+
5551
+ let suffix_a = ".a"
5552
+
5553
+ let suffix_cmj = ".cmj"
5554
+
5555
+ let suffix_cmo = ".cmo"
5556
+
5557
+ let suffix_cma = ".cma"
5558
+
5559
+ let suffix_cmi = ".cmi"
5560
+
5561
+ let suffix_cmx = ".cmx"
5562
+
5563
+ let suffix_cmxa = ".cmxa"
5564
+
5565
+ let suffix_mll = ".mll"
5566
+
5567
+ let suffix_ml = ".ml"
5568
+
5569
+ let suffix_mli = ".mli"
5570
+
5571
+ let suffix_re = ".re"
5572
+
5573
+ let suffix_rei = ".rei"
5574
+
5575
+ let suffix_res = ".res"
5576
+
5577
+ let suffix_resi = ".resi"
5578
+
5579
+ let suffix_mlmap = ".mlmap"
5580
+
5581
+ let suffix_cmt = ".cmt"
5582
+
5583
+ let suffix_cmti = ".cmti"
5584
+
5585
+ let suffix_ast = ".ast"
5586
+
5587
+ let suffix_iast = ".iast"
5588
+
5589
+ let suffix_d = ".d"
5590
+
5591
+ let suffix_js = ".js"
5592
+
5593
+ let suffix_bs_js = ".bs.js"
5594
+
5595
+ let suffix_mjs = ".mjs"
5596
+
5597
+ let suffix_bs_mjs = ".bs.mjs"
5598
+
5599
+ let suffix_cjs = ".cjs"
5600
+
5601
+ let suffix_bs_cjs = ".bs.cjs"
5602
+
5603
+ let suffix_gen_js = ".gen.js"
5604
+
5605
+ let suffix_gen_tsx = ".gen.tsx"
5606
+
5607
+ let commonjs = "commonjs"
5608
+
5609
+ let es6 = "es6"
5610
+
5611
+ let es6_global = "es6-global"
5612
+
5613
+ let unused_attribute = "Unused attribute "
5614
+
5615
+ (** Used when produce node compatible paths *)
5616
+ let node_sep = "/"
5617
+
5618
+ let node_parent = ".."
5619
+
5620
+ let node_current = "."
5621
+
5622
+ let gentype_import1 = "genType.import"
5623
+ let gentype_import2 = "gentype.import"
5624
+
5625
+ let bsbuild_cache = ".bsbuild"
5626
+
5627
+ let sourcedirs_meta = ".sourcedirs.json"
5628
+
5629
+ (* Note the build system should check the validity of filenames
5630
+ espeically, it should not contain '-'
5631
+ *)
5632
+ let ns_sep_char = '-'
5633
+
5634
+ let ns_sep = "-"
5635
+
5636
+ let exception_id = "RE_EXN_ID"
5637
+
5638
+ let polyvar_hash = "NAME"
5639
+
5640
+ let polyvar_value = "VAL"
5641
+
5642
+ let cons = "::"
5643
+
5644
+ let hd = "hd"
5645
+
5646
+ let tl = "tl"
5647
+
5648
+ let lazy_done = "LAZY_DONE"
5649
+
5650
+ let lazy_val = "VAL"
5651
+
5652
+ let pure = "@__PURE__"
5653
+
5654
+ end
5655
+ module Ext_path : sig
5656
+ #1 "ext_path.mli"
5657
+ (* Copyright (C) 2017 Authors of ReScript
5658
+ *
5659
+ * This program is free software: you can redistribute it and/or modify
5660
+ * it under the terms of the GNU Lesser General Public License as published by
5661
+ * the Free Software Foundation, either version 3 of the License, or
5858
5662
  * (at your option) any later version.
5859
5663
  *
5860
5664
  * In addition to the permissions granted to you by the LGPL, you may combine
@@ -5869,61 +5673,348 @@ end = struct
5869
5673
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5870
5674
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5871
5675
  * GNU Lesser General Public License for more details.
5872
- *
5676
+ *
5873
5677
  * You should have received a copy of the GNU Lesser General Public License
5874
5678
  * along with this program; if not, write to the Free Software
5875
5679
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5876
5680
 
5877
- type callback =
5878
- [ `Str of string -> unit
5879
- | `Str_loc of string -> Lexing.position -> unit
5880
- | `Flo of string -> unit
5881
- | `Flo_loc of string -> Lexing.position -> unit
5882
- | `Bool of bool -> unit
5883
- | `Obj of Ext_json_types.t Map_string.t -> unit
5884
- | `Arr of Ext_json_types.t array -> unit
5885
- | `Arr_loc of
5886
- Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit
5887
- | `Null of unit -> unit
5888
- | `Not_found of unit -> unit
5889
- | `Id of Ext_json_types.t -> unit ]
5681
+ type t
5890
5682
 
5891
- type path = string list
5683
+ val simple_convert_node_path_to_os_path : string -> string
5684
+ (** Js_output is node style, which means
5685
+ separator is only '/'
5892
5686
 
5893
- type status = No_path | Found of Ext_json_types.t | Wrong_type of path
5687
+ if the path contains 'node_modules',
5688
+ [node_relative_path] will discard its prefix and
5689
+ just treat it as a library instead
5690
+ *)
5894
5691
 
5895
- let test ?(fail = fun () -> ()) key (cb : callback)
5896
- (m : Ext_json_types.t Map_string.t) =
5897
- (match (Map_string.find_exn m key, cb) with
5898
- | exception Not_found -> (
5899
- match cb with `Not_found f -> f () | _ -> fail ())
5900
- | True _, `Bool cb -> cb true
5901
- | False _, `Bool cb -> cb false
5902
- | Flo { flo = s }, `Flo cb -> cb s
5903
- | Flo { flo = s; loc }, `Flo_loc cb -> cb s loc
5904
- | Obj { map = b }, `Obj cb -> cb b
5905
- | Arr { content }, `Arr cb -> cb content
5906
- | Arr { content; loc_start; loc_end }, `Arr_loc cb ->
5907
- cb content loc_start loc_end
5908
- | Null _, `Null cb -> cb ()
5909
- | Str { str = s }, `Str cb -> cb s
5910
- | Str { str = s; loc }, `Str_loc cb -> cb s loc
5911
- | any, `Id cb -> cb any
5912
- | _, _ -> fail ());
5913
- m
5692
+ val combine : string -> string -> string
5693
+ (**
5694
+ [combine path1 path2]
5695
+ 1. add some simplifications when concatenating
5696
+ 2. when [path2] is absolute, return [path2]
5697
+ *)
5914
5698
 
5915
- let loc_of (x : Ext_json_types.t) =
5916
- match x with
5917
- | True p | False p | Null p -> p
5918
- | Str p -> p.loc
5919
- | Arr p -> p.loc_start
5920
- | Obj p -> p.loc
5921
- | Flo p -> p.loc
5699
+ (**
5700
+ {[
5701
+ get_extension "a.txt" = ".txt"
5702
+ get_extension "a" = ""
5703
+ ]}
5704
+ *)
5922
5705
 
5923
- end
5924
- module Bsb_exception : sig
5925
- #1 "bsb_exception.mli"
5926
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5706
+ val node_rebase_file : from:string -> to_:string -> string -> string
5707
+
5708
+ val rel_normalized_absolute_path : from:string -> string -> string
5709
+ (**
5710
+ TODO: could be highly optimized
5711
+ if [from] and [to] resolve to the same path, a zero-length string is returned
5712
+ Given that two paths are directory
5713
+
5714
+ A typical use case is
5715
+ {[
5716
+ Filename.concat
5717
+ (rel_normalized_absolute_path cwd (Filename.dirname a))
5718
+ (Filename.basename a)
5719
+ ]}
5720
+ *)
5721
+
5722
+ val normalize_absolute_path : string -> string
5723
+
5724
+ val absolute_cwd_path : string -> string
5725
+
5726
+ val concat : string -> string -> string
5727
+ (** [concat dirname filename]
5728
+ The same as {!Filename.concat} except a tiny optimization
5729
+ for current directory simplification
5730
+ *)
5731
+
5732
+ val check_suffix_case : string -> string -> bool
5733
+
5734
+ (* It is lazy so that it will not hit errors when in script mode *)
5735
+ val package_dir : string Lazy.t
5736
+
5737
+ end = struct
5738
+ #1 "ext_path.ml"
5739
+ (* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
5740
+ *
5741
+ * This program is free software: you can redistribute it and/or modify
5742
+ * it under the terms of the GNU Lesser General Public License as published by
5743
+ * the Free Software Foundation, either version 3 of the License, or
5744
+ * (at your option) any later version.
5745
+ *
5746
+ * In addition to the permissions granted to you by the LGPL, you may combine
5747
+ * or link a "work that uses the Library" with a publicly distributed version
5748
+ * of this file to produce a combined library or application, then distribute
5749
+ * that combined work under the terms of your choosing, with no requirement
5750
+ * to comply with the obligations normally placed on you by section 4 of the
5751
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
5752
+ * should you choose to use a later version).
5753
+ *
5754
+ * This program is distributed in the hope that it will be useful,
5755
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
5756
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5757
+ * GNU Lesser General Public License for more details.
5758
+ *
5759
+ * You should have received a copy of the GNU Lesser General Public License
5760
+ * along with this program; if not, write to the Free Software
5761
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5762
+
5763
+ (* [@@@warning "-37"] *)
5764
+ type t = (* | File of string *)
5765
+ | Dir of string [@@unboxed]
5766
+
5767
+ let simple_convert_node_path_to_os_path =
5768
+ if Sys.unix then fun x -> x
5769
+ else if Sys.win32 || Sys.cygwin then Ext_string.replace_slash_backward
5770
+ else failwith ("Unknown OS : " ^ Sys.os_type)
5771
+
5772
+ let cwd = lazy (Sys.getcwd ())
5773
+
5774
+ let split_by_sep_per_os : string -> string list =
5775
+ if Ext_sys.is_windows_or_cygwin then fun x ->
5776
+ (* on Windows, we can still accept -bs-package-output lib/js *)
5777
+ Ext_string.split_by
5778
+ (fun x -> match x with '/' | '\\' -> true | _ -> false)
5779
+ x
5780
+ else fun x -> Ext_string.split x '/'
5781
+
5782
+ (** example
5783
+ {[
5784
+ "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj"
5785
+ "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml"
5786
+ ]}
5787
+
5788
+ The other way
5789
+ {[
5790
+
5791
+ "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml"
5792
+ "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj"
5793
+ ]}
5794
+ {[
5795
+ "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib//ocaml_array.ml"
5796
+ ]}
5797
+ {[
5798
+ /a/b
5799
+ /c/d
5800
+ ]}
5801
+ *)
5802
+ let node_relative_path ~from:(file_or_dir_2 : t) (file_or_dir_1 : t) =
5803
+ let relevant_dir1 =
5804
+ match file_or_dir_1 with Dir x -> x
5805
+ (* | File file1 -> Filename.dirname file1 *)
5806
+ in
5807
+ let relevant_dir2 =
5808
+ match file_or_dir_2 with Dir x -> x
5809
+ (* | File file2 -> Filename.dirname file2 *)
5810
+ in
5811
+ let dir1 = split_by_sep_per_os relevant_dir1 in
5812
+ let dir2 = split_by_sep_per_os relevant_dir2 in
5813
+ let rec go (dir1 : string list) (dir2 : string list) =
5814
+ match (dir1, dir2) with
5815
+ | "." :: xs, ys -> go xs ys
5816
+ | xs, "." :: ys -> go xs ys
5817
+ | x :: xs, y :: ys when x = y -> go xs ys
5818
+ | _, _ -> Ext_list.map_append dir2 dir1 (fun _ -> Literals.node_parent)
5819
+ in
5820
+ match go dir1 dir2 with
5821
+ | x :: _ as ys when x = Literals.node_parent ->
5822
+ String.concat Literals.node_sep ys
5823
+ | ys -> String.concat Literals.node_sep @@ (Literals.node_current :: ys)
5824
+
5825
+ let node_concat ~dir base = dir ^ Literals.node_sep ^ base
5826
+
5827
+ let node_rebase_file ~from ~to_ file =
5828
+ node_concat
5829
+ ~dir:
5830
+ (if from = to_ then Literals.node_current
5831
+ else node_relative_path ~from:(Dir from) (Dir to_))
5832
+ file
5833
+
5834
+ (***
5835
+ {[
5836
+ Filename.concat "." "";;
5837
+ "./"
5838
+ ]}
5839
+ *)
5840
+ let combine path1 path2 =
5841
+ if Filename.is_relative path2 then
5842
+ if Ext_string.is_empty path2 then path1
5843
+ else if path1 = Filename.current_dir_name then path2
5844
+ else if path2 = Filename.current_dir_name then path1
5845
+ else Filename.concat path1 path2
5846
+ else path2
5847
+
5848
+ let ( // ) x y =
5849
+ if x = Filename.current_dir_name then y
5850
+ else if y = Filename.current_dir_name then x
5851
+ else Filename.concat x y
5852
+
5853
+ (**
5854
+ {[
5855
+ split_aux "//ghosg//ghsogh/";;
5856
+ - : string * string list = ("/", ["ghosg"; "ghsogh"])
5857
+ ]}
5858
+ Note that
5859
+ {[
5860
+ Filename.dirname "/a/" = "/"
5861
+ Filename.dirname "/a/b/" = Filename.dirname "/a/b" = "/a"
5862
+ ]}
5863
+ Special case:
5864
+ {[
5865
+ basename "//" = "/"
5866
+ basename "///" = "/"
5867
+ ]}
5868
+ {[
5869
+ basename "" = "."
5870
+ basename "" = "."
5871
+ dirname "" = "."
5872
+ dirname "" = "."
5873
+ ]}
5874
+ *)
5875
+ let split_aux p =
5876
+ let rec go p acc =
5877
+ let dir = Filename.dirname p in
5878
+ if dir = p then (dir, acc)
5879
+ else
5880
+ let new_path = Filename.basename p in
5881
+ if Ext_string.equal new_path Filename.dir_sep then go dir acc
5882
+ (* We could do more path simplification here
5883
+ leave to [rel_normalized_absolute_path]
5884
+ *)
5885
+ else go dir (new_path :: acc)
5886
+ in
5887
+
5888
+ go p []
5889
+
5890
+ (**
5891
+ TODO: optimization
5892
+ if [from] and [to] resolve to the same path, a zero-length string is returned
5893
+
5894
+ This function is useed in [es6-global] and
5895
+ [amdjs-global] format and tailored for `rollup`
5896
+ *)
5897
+ let rel_normalized_absolute_path ~from to_ =
5898
+ let root1, paths1 = split_aux from in
5899
+ let root2, paths2 = split_aux to_ in
5900
+ if root1 <> root2 then root2
5901
+ else
5902
+ let rec go xss yss =
5903
+ match (xss, yss) with
5904
+ | x :: xs, y :: ys ->
5905
+ if Ext_string.equal x y then go xs ys
5906
+ else if x = Filename.current_dir_name then go xs yss
5907
+ else if y = Filename.current_dir_name then go xss ys
5908
+ else
5909
+ let start =
5910
+ Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ ->
5911
+ acc // Ext_string.parent_dir_lit)
5912
+ in
5913
+ Ext_list.fold_left yss start (fun acc v -> acc // v)
5914
+ | [], [] -> Ext_string.empty
5915
+ | [], y :: ys -> Ext_list.fold_left ys y (fun acc x -> acc // x)
5916
+ | _ :: xs, [] ->
5917
+ Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ ->
5918
+ acc // Ext_string.parent_dir_lit)
5919
+ in
5920
+ let v = go paths1 paths2 in
5921
+
5922
+ if Ext_string.is_empty v then Literals.node_current
5923
+ else if
5924
+ v = "." || v = ".."
5925
+ || Ext_string.starts_with v "./"
5926
+ || Ext_string.starts_with v "../"
5927
+ then v
5928
+ else "./" ^ v
5929
+
5930
+ (*TODO: could be hgighly optimized later
5931
+ {[
5932
+ normalize_absolute_path "/gsho/./..";;
5933
+
5934
+ normalize_absolute_path "/a/b/../c../d/e/f";;
5935
+
5936
+ normalize_absolute_path "/gsho/./..";;
5937
+
5938
+ normalize_absolute_path "/gsho/./../..";;
5939
+
5940
+ normalize_absolute_path "/a/b/c/d";;
5941
+
5942
+ normalize_absolute_path "/a/b/c/d/";;
5943
+
5944
+ normalize_absolute_path "/a/";;
5945
+
5946
+ normalize_absolute_path "/a";;
5947
+ ]}
5948
+ *)
5949
+
5950
+ (** See tests in {!Ounit_path_tests} *)
5951
+ let normalize_absolute_path x =
5952
+ let drop_if_exist xs = match xs with [] -> [] | _ :: xs -> xs in
5953
+ let rec normalize_list acc paths =
5954
+ match paths with
5955
+ | [] -> acc
5956
+ | x :: xs ->
5957
+ if Ext_string.equal x Ext_string.current_dir_lit then
5958
+ normalize_list acc xs
5959
+ else if Ext_string.equal x Ext_string.parent_dir_lit then
5960
+ normalize_list (drop_if_exist acc) xs
5961
+ else normalize_list (x :: acc) xs
5962
+ in
5963
+ let root, paths = split_aux x in
5964
+ let rev_paths = normalize_list [] paths in
5965
+ let rec go acc rev_paths =
5966
+ match rev_paths with
5967
+ | [] -> Filename.concat root acc
5968
+ | last :: rest -> go (Filename.concat last acc) rest
5969
+ in
5970
+ match rev_paths with [] -> root | last :: rest -> go last rest
5971
+
5972
+ let absolute_path cwd s =
5973
+ let process s =
5974
+ let s = if Filename.is_relative s then Lazy.force cwd // s else s in
5975
+ (* Now simplify . and .. components *)
5976
+ let rec aux s =
5977
+ let base, dir = (Filename.basename s, Filename.dirname s) in
5978
+ if dir = s then dir
5979
+ else if base = Filename.current_dir_name then aux dir
5980
+ else if base = Filename.parent_dir_name then Filename.dirname (aux dir)
5981
+ else aux dir // base
5982
+ in
5983
+ aux s
5984
+ in
5985
+ process s
5986
+
5987
+ let absolute_cwd_path s = absolute_path cwd s
5988
+
5989
+ (* let absolute cwd s =
5990
+ match s with
5991
+ | File x -> File (absolute_path cwd x )
5992
+ | Dir x -> Dir (absolute_path cwd x) *)
5993
+
5994
+ let concat dirname filename =
5995
+ if filename = Filename.current_dir_name then dirname
5996
+ else if dirname = Filename.current_dir_name then filename
5997
+ else Filename.concat dirname filename
5998
+
5999
+ let check_suffix_case = Ext_string.ends_with
6000
+
6001
+ (* Input must be absolute directory *)
6002
+ let rec find_root_filename ~cwd filename =
6003
+ if Sys.file_exists (Filename.concat cwd filename) then cwd
6004
+ else
6005
+ let cwd' = Filename.dirname cwd in
6006
+ if String.length cwd' < String.length cwd then
6007
+ find_root_filename ~cwd:cwd' filename
6008
+ else Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" filename cwd
6009
+
6010
+ let find_package_json_dir cwd = find_root_filename ~cwd Literals.bsconfig_json
6011
+
6012
+ let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
6013
+
6014
+ end
6015
+ module Bsb_config : sig
6016
+ #1 "bsb_config.mli"
6017
+ (* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
5927
6018
  * Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
5928
6019
  * This program is free software: you can redistribute it and/or modify
5929
6020
  * it under the terms of the GNU Lesser General Public License as published by
@@ -5942,38 +6033,39 @@ module Bsb_exception : sig
5942
6033
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5943
6034
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5944
6035
  * GNU Lesser General Public License for more details.
5945
- *
6036
+ *
5946
6037
  * You should have received a copy of the GNU Lesser General Public License
5947
6038
  * along with this program; if not, write to the Free Software
5948
6039
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5949
6040
 
5950
- type error
5951
- (**
5952
- This module is used for fatal errros
5953
- *)
6041
+ val ocaml_bin_install_prefix : string -> string
5954
6042
 
5955
- exception Error of error
6043
+ val proj_rel : string -> string
5956
6044
 
5957
- val print : Format.formatter -> error -> unit
6045
+ val lib_lit : string
5958
6046
 
5959
- val package_not_found : pkg:Bsb_pkg_types.t -> json:string option -> 'a
6047
+ val lib_js : string
5960
6048
 
5961
- val conflict_module : string -> string -> string -> exn
6049
+ val lib_bs : string
5962
6050
 
5963
- val errorf : loc:Ext_position.t -> ('a, unit, string, 'b) format4 -> 'a
6051
+ val lib_es6 : string
5964
6052
 
5965
- val config_error : Ext_json_types.t -> string -> 'a
6053
+ val lib_es6_global : string
5966
6054
 
5967
- val invalid_spec : string -> 'a
6055
+ val lib_ocaml : string
5968
6056
 
5969
- val invalid_json : string -> 'a
6057
+ val all_lib_artifacts : string list
5970
6058
 
5971
- val no_implementation : string -> 'a
6059
+ (* we need generate path relative to [lib/bs] directory in the opposite direction *)
6060
+ val rev_lib_bs_prefix : string -> string
5972
6061
 
5973
- val not_consistent : string -> 'a
6062
+ val lib_bs_prefix_of_format : Ext_module_system.t -> string
6063
+
6064
+ val top_prefix_of_format : Ext_module_system.t -> string
6065
+ (** default not install, only when -make-world, its dependencies will be installed *)
5974
6066
 
5975
6067
  end = struct
5976
- #1 "bsb_exception.ml"
6068
+ #1 "bsb_config.ml"
5977
6069
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5978
6070
  * Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
5979
6071
  * This program is free software: you can redistribute it and/or modify
@@ -5993,92 +6085,53 @@ end = struct
5993
6085
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
5994
6086
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5995
6087
  * GNU Lesser General Public License for more details.
5996
- *
6088
+ *
5997
6089
  * You should have received a copy of the GNU Lesser General Public License
5998
6090
  * along with this program; if not, write to the Free Software
5999
6091
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
6092
+ let ( // ) = Ext_path.combine
6000
6093
 
6001
- type error =
6002
- | Package_not_found of Bsb_pkg_types.t * string option (* json file *)
6003
- | Json_config of Ext_position.t * string
6004
- | Invalid_json of string
6005
- | Invalid_spec of string
6006
- | Conflict_module of string * string * string
6007
- | No_implementation of string
6008
- | Not_consistent of string
6094
+ let lib_lit = "lib"
6009
6095
 
6010
- exception Error of error
6096
+ let lib_js = lib_lit // "js"
6011
6097
 
6012
- let error err = raise (Error err)
6098
+ let lib_ocaml = lib_lit // "ocaml"
6013
6099
 
6014
- let package_not_found ~pkg ~json = error (Package_not_found (pkg, json))
6100
+ let lib_bs = lib_lit // "bs"
6015
6101
 
6016
- let print (fmt : Format.formatter) (x : error) =
6017
- match x with
6018
- | Conflict_module (modname, dir1, dir2) ->
6019
- Format.fprintf fmt
6020
- "@{<error>Error:@} %s found in two directories: (%s, %s)\n\
6021
- File names must be unique per project" modname dir1 dir2
6022
- | Not_consistent modname ->
6023
- Format.fprintf fmt
6024
- "@{<error>Error:@} %s has implementation/interface in non-consistent \
6025
- syntax(reason/ocaml)"
6026
- modname
6027
- | No_implementation modname ->
6028
- Format.fprintf fmt
6029
- "@{<error>Error:@} %s does not have implementation file" modname
6030
- | Package_not_found (name, json_opt) ->
6031
- let in_json =
6032
- match json_opt with None -> Ext_string.empty | Some x -> " in " ^ x
6033
- in
6034
- let name = Bsb_pkg_types.to_string name in
6035
- if Ext_string.equal name !Bs_version.package_name then
6036
- Format.fprintf fmt
6037
- "File \"bsconfig.json\", line 1\n\
6038
- @{<error>Error:@} package @{<error>%s@} is not found %s\n\
6039
- It's the basic, required package. If you have it installed globally,\n\
6040
- Please run `npm link rescript` to make it available" name in_json
6041
- else
6042
- Format.fprintf fmt
6043
- "File \"bsconfig.json\", line 1\n\
6044
- @{<error>Error:@} package @{<error>%s@} not found or built %s\n\
6045
- - Did you install it?\n\
6046
- - If you did, did you run `rescript build -with-deps`?" name in_json
6047
- | Json_config (pos, s) ->
6048
- Format.fprintf fmt
6049
- "File %S, line %d:\n\
6050
- @{<error>Error:@} %s \n\
6051
- For more details, please checkout the schema \
6052
- https://rescript-lang.org/docs/manual/latest/build-configuration-schema"
6053
- pos.pos_fname pos.pos_lnum s
6054
- | Invalid_spec s ->
6055
- Format.fprintf fmt "@{<error>Error: Invalid bsconfig.json %s@}" s
6056
- | Invalid_json s ->
6057
- Format.fprintf fmt
6058
- "File %S, line 1\n@{<error>Error: Invalid json format@}" s
6102
+ let lib_es6 = lib_lit // "es6"
6059
6103
 
6060
- let conflict_module modname dir1 dir2 =
6061
- Error (Conflict_module (modname, dir1, dir2))
6104
+ let lib_es6_global = lib_lit // "es6_global"
6062
6105
 
6063
- let no_implementation modname = error (No_implementation modname)
6106
+ let all_lib_artifacts = [ lib_js; lib_ocaml; lib_bs; lib_es6; lib_es6_global ]
6064
6107
 
6065
- let not_consistent modname = error (Not_consistent modname)
6108
+ let rev_lib_bs = ".." // ".."
6066
6109
 
6067
- let errorf ~loc fmt =
6068
- Format.ksprintf (fun s -> error (Json_config (loc, s))) fmt
6110
+ (* access the js directory from "lib/bs",
6111
+ it would be '../js'
6112
+ *)
6113
+ let lib_bs_prefix_of_format (x : Ext_module_system.t) =
6114
+ ".."
6115
+ // match x with NodeJS -> "js" | Es6 -> "es6" | Es6_global -> "es6_global"
6069
6116
 
6070
- let config_error config fmt =
6071
- let loc = Ext_json.loc_of config in
6117
+ (* lib/js, lib/es6, lib/es6_global *)
6118
+ let top_prefix_of_format (x : Ext_module_system.t) =
6119
+ match x with
6120
+ | NodeJS -> lib_js
6121
+ | Es6 -> lib_es6
6122
+ | Es6_global -> lib_es6_global
6072
6123
 
6073
- error (Json_config (loc, fmt))
6124
+ let rev_lib_bs_prefix p = rev_lib_bs // p
6074
6125
 
6075
- let invalid_spec s = error (Invalid_spec s)
6126
+ let ocaml_bin_install_prefix p = lib_ocaml // p
6076
6127
 
6077
- let invalid_json s = error (Invalid_json s)
6128
+ let proj_rel path = rev_lib_bs // path
6078
6129
 
6079
- let () =
6080
- Printexc.register_printer (fun x ->
6081
- match x with Error x -> Some (Format.asprintf "%a" print x) | _ -> None)
6130
+ (** it may not be a bad idea to hard code the binary path
6131
+ of bsb in configuration time
6132
+ *)
6133
+
6134
+ (* let cmd_package_specs = ref None *)
6082
6135
 
6083
6136
  end
6084
6137
  module Ext_color : sig
@@ -6421,6 +6474,184 @@ let real_path p =
6421
6474
 
6422
6475
  let is_same_paths_via_io a b = if a = b then true else real_path a = real_path b
6423
6476
 
6477
+ end
6478
+ module Ext_utf8 : sig
6479
+ #1 "ext_utf8.mli"
6480
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
6481
+ *
6482
+ * This program is free software: you can redistribute it and/or modify
6483
+ * it under the terms of the GNU Lesser General Public License as published by
6484
+ * the Free Software Foundation, either version 3 of the License, or
6485
+ * (at your option) any later version.
6486
+ *
6487
+ * In addition to the permissions granted to you by the LGPL, you may combine
6488
+ * or link a "work that uses the Library" with a publicly distributed version
6489
+ * of this file to produce a combined library or application, then distribute
6490
+ * that combined work under the terms of your choosing, with no requirement
6491
+ * to comply with the obligations normally placed on you by section 4 of the
6492
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
6493
+ * should you choose to use a later version).
6494
+ *
6495
+ * This program is distributed in the hope that it will be useful,
6496
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
6497
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6498
+ * GNU Lesser General Public License for more details.
6499
+ *
6500
+ * You should have received a copy of the GNU Lesser General Public License
6501
+ * along with this program; if not, write to the Free Software
6502
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
6503
+
6504
+ type byte = Single of int | Cont of int | Leading of int * int | Invalid
6505
+
6506
+ val classify : char -> byte
6507
+
6508
+ val follow : string -> int -> int -> int -> int * int
6509
+
6510
+ val next : string -> remaining:int -> int -> int
6511
+ (**
6512
+ return [-1] if failed
6513
+ *)
6514
+
6515
+ exception Invalid_utf8 of string
6516
+
6517
+ val decode_utf8_string : string -> int list
6518
+
6519
+ val encode_codepoint : int -> string
6520
+
6521
+ end = struct
6522
+ #1 "ext_utf8.ml"
6523
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
6524
+ *
6525
+ * This program is free software: you can redistribute it and/or modify
6526
+ * it under the terms of the GNU Lesser General Public License as published by
6527
+ * the Free Software Foundation, either version 3 of the License, or
6528
+ * (at your option) any later version.
6529
+ *
6530
+ * In addition to the permissions granted to you by the LGPL, you may combine
6531
+ * or link a "work that uses the Library" with a publicly distributed version
6532
+ * of this file to produce a combined library or application, then distribute
6533
+ * that combined work under the terms of your choosing, with no requirement
6534
+ * to comply with the obligations normally placed on you by section 4 of the
6535
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
6536
+ * should you choose to use a later version).
6537
+ *
6538
+ * This program is distributed in the hope that it will be useful,
6539
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
6540
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6541
+ * GNU Lesser General Public License for more details.
6542
+ *
6543
+ * You should have received a copy of the GNU Lesser General Public License
6544
+ * along with this program; if not, write to the Free Software
6545
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
6546
+
6547
+ type byte = Single of int | Cont of int | Leading of int * int | Invalid
6548
+
6549
+ (** [classify chr] returns the {!byte} corresponding to [chr] *)
6550
+ let classify chr =
6551
+ let c = int_of_char chr in
6552
+ (* Classify byte according to leftmost 0 bit *)
6553
+ if c land 0b1000_0000 = 0 then Single c
6554
+ else if (* c 0b0____*)
6555
+ c land 0b0100_0000 = 0 then Cont (c land 0b0011_1111)
6556
+ else if (* c 0b10___*)
6557
+ c land 0b0010_0000 = 0 then Leading (1, c land 0b0001_1111)
6558
+ else if (* c 0b110__*)
6559
+ c land 0b0001_0000 = 0 then Leading (2, c land 0b0000_1111)
6560
+ else if (* c 0b1110_ *)
6561
+ c land 0b0000_1000 = 0 then Leading (3, c land 0b0000_0111)
6562
+ else if (* c 0b1111_0___*)
6563
+ c land 0b0000_0100 = 0 then Leading (4, c land 0b0000_0011)
6564
+ else if (* c 0b1111_10__*)
6565
+ c land 0b0000_0010 = 0 then Leading (5, c land 0b0000_0001)
6566
+ (* c 0b1111_110__ *)
6567
+ else Invalid
6568
+
6569
+ exception Invalid_utf8 of string
6570
+
6571
+ (* when the first char is [Leading],
6572
+ TODO: need more error checking
6573
+ when out of bond
6574
+ *)
6575
+ let rec follow s n (c : int) offset =
6576
+ if n = 0 then (c, offset)
6577
+ else
6578
+ match classify s.[offset + 1] with
6579
+ | Cont cc -> follow s (n - 1) ((c lsl 6) lor (cc land 0x3f)) (offset + 1)
6580
+ | _ -> raise (Invalid_utf8 "Continuation byte expected")
6581
+
6582
+ let rec next s ~remaining offset =
6583
+ if remaining = 0 then offset
6584
+ else
6585
+ match classify s.[offset + 1] with
6586
+ | Cont _cc -> next s ~remaining:(remaining - 1) (offset + 1)
6587
+ | _ -> -1
6588
+ | exception _ -> -1
6589
+ (* it can happen when out of bound *)
6590
+
6591
+ let decode_utf8_string s =
6592
+ let lst = ref [] in
6593
+ let add elem = lst := elem :: !lst in
6594
+ let rec decode_utf8_cont s i s_len =
6595
+ if i = s_len then ()
6596
+ else
6597
+ match classify s.[i] with
6598
+ | Single c ->
6599
+ add c;
6600
+ decode_utf8_cont s (i + 1) s_len
6601
+ | Cont _ -> raise (Invalid_utf8 "Unexpected continuation byte")
6602
+ | Leading (n, c) ->
6603
+ let c', i' = follow s n c i in
6604
+ add c';
6605
+ decode_utf8_cont s (i' + 1) s_len
6606
+ | Invalid -> raise (Invalid_utf8 "Invalid byte")
6607
+ in
6608
+ decode_utf8_cont s 0 (String.length s);
6609
+ List.rev !lst
6610
+
6611
+ (** To decode {j||j} we need verify in the ast so that we have better error
6612
+ location, then we do the decode later
6613
+ *)
6614
+
6615
+ (* let verify s loc =
6616
+ assert false *)
6617
+
6618
+ let encode_codepoint c =
6619
+ (* reused from syntax/src/res_utf8.ml *)
6620
+ let h2 = 0b1100_0000 in
6621
+ let h3 = 0b1110_0000 in
6622
+ let h4 = 0b1111_0000 in
6623
+ let cont_mask = 0b0011_1111 in
6624
+ if c <= 127 then (
6625
+ let bytes = (Bytes.create [@doesNotRaise]) 1 in
6626
+ Bytes.unsafe_set bytes 0 (Char.unsafe_chr c);
6627
+ Bytes.unsafe_to_string bytes)
6628
+ else if c <= 2047 then (
6629
+ let bytes = (Bytes.create [@doesNotRaise]) 2 in
6630
+ Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h2 lor (c lsr 6)));
6631
+ Bytes.unsafe_set bytes 1
6632
+ (Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
6633
+ Bytes.unsafe_to_string bytes)
6634
+ else if c <= 65535 then (
6635
+ let bytes = (Bytes.create [@doesNotRaise]) 3 in
6636
+ Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h3 lor (c lsr 12)));
6637
+ Bytes.unsafe_set bytes 1
6638
+ (Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
6639
+ Bytes.unsafe_set bytes 2
6640
+ (Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
6641
+ Bytes.unsafe_to_string bytes)
6642
+ else
6643
+ (* if c <= max then *)
6644
+ let bytes = (Bytes.create [@doesNotRaise]) 4 in
6645
+ Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h4 lor (c lsr 18)));
6646
+ Bytes.unsafe_set bytes 1
6647
+ (Char.unsafe_chr (0b1000_0000 lor ((c lsr 12) land cont_mask)));
6648
+ Bytes.unsafe_set bytes 2
6649
+ (Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
6650
+ Bytes.unsafe_set bytes 3
6651
+ (Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
6652
+ Bytes.unsafe_to_string bytes
6653
+
6654
+
6424
6655
  end
6425
6656
  module Ext_util : sig
6426
6657
  #1 "ext_util.mli"
@@ -6452,6 +6683,9 @@ val power_2_above : int -> int -> int
6452
6683
 
6453
6684
  val stats_to_string : Hashtbl.statistics -> string
6454
6685
 
6686
+ val string_of_int_as_char : int -> string
6687
+
6688
+
6455
6689
  end = struct
6456
6690
  #1 "ext_util.ml"
6457
6691
  (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -6497,6 +6731,25 @@ let stats_to_string
6497
6731
  (String.concat ","
6498
6732
  (Array.to_list (Array.map string_of_int bucket_histogram)))
6499
6733
 
6734
+ let string_of_int_as_char (i : int) : string =
6735
+ if i <= 255 && i >= 0 then Format.asprintf "%C" (Char.unsafe_chr i)
6736
+ else
6737
+ let str =
6738
+ match Char.unsafe_chr i with
6739
+ | '\'' -> "\\'"
6740
+ | '\\' -> "\\\\"
6741
+ | '\n' -> "\\n"
6742
+ | '\t' -> "\\t"
6743
+ | '\r' -> "\\r"
6744
+ | '\b' -> "\\b"
6745
+ | ' ' .. '~' as c ->
6746
+ let s = (Bytes.create [@doesNotRaise]) 1 in
6747
+ Bytes.unsafe_set s 0 c;
6748
+ Bytes.unsafe_to_string s
6749
+ | _ -> Ext_utf8.encode_codepoint i
6750
+ in
6751
+ Printf.sprintf "\'%s\'" str
6752
+
6500
6753
  end
6501
6754
  module Hash_gen
6502
6755
  = struct
@@ -7051,22 +7304,33 @@ end
7051
7304
  module Ext_js_suffix
7052
7305
  = struct
7053
7306
  #1 "ext_js_suffix.ml"
7054
- type t = Js | Bs_js | Mjs | Cjs | Unknown_extension
7307
+ type t =
7308
+ | Js
7309
+ | Mjs
7310
+ | Cjs
7311
+ | Bs_js
7312
+ | Bs_mjs
7313
+ | Bs_cjs
7314
+ | Unknown_extension
7055
7315
 
7056
7316
  let to_string (x : t) =
7057
7317
  match x with
7058
7318
  | Js -> Literals.suffix_js
7059
- | Bs_js -> Literals.suffix_bs_js
7060
7319
  | Mjs -> Literals.suffix_mjs
7061
7320
  | Cjs -> Literals.suffix_cjs
7321
+ | Bs_js -> Literals.suffix_bs_js
7322
+ | Bs_mjs -> Literals.suffix_bs_mjs
7323
+ | Bs_cjs -> Literals.suffix_bs_cjs
7062
7324
  | Unknown_extension -> assert false
7063
7325
 
7064
7326
  let of_string (x : string) : t =
7065
7327
  match () with
7066
7328
  | () when x = Literals.suffix_js -> Js
7067
- | () when x = Literals.suffix_bs_js -> Bs_js
7068
7329
  | () when x = Literals.suffix_mjs -> Mjs
7069
7330
  | () when x = Literals.suffix_cjs -> Cjs
7331
+ | () when x = Literals.suffix_bs_js -> Bs_js
7332
+ | () when x = Literals.suffix_bs_mjs -> Bs_mjs
7333
+ | () when x = Literals.suffix_bs_cjs -> Bs_cjs
7070
7334
  | _ -> Unknown_extension
7071
7335
 
7072
7336
  end
@@ -7806,7 +8070,8 @@ let extract_bs_suffix_exn (map : json_map) : Ext_js_suffix.t =
7806
8070
  | Some (Str { str; loc }) ->
7807
8071
  let s = Ext_js_suffix.of_string str in
7808
8072
  if s = Unknown_extension then
7809
- Bsb_exception.errorf ~loc "expect .bs.js, .js, .cjs, .mjs here"
8073
+ Bsb_exception.errorf ~loc
8074
+ "expect .js, .mjs, .cjs or .bs.js, .bs.mjs, .bs.cjs here"
7810
8075
  else s
7811
8076
  | Some config ->
7812
8077
  Bsb_exception.config_error config
@@ -7858,10 +8123,12 @@ module Bsb_package_kind
7858
8123
  * along with this program; if not, write to the Free Software
7859
8124
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
7860
8125
 
8126
+ type dep_payload = { package_specs : Bsb_package_specs.t; jsx : Bsb_jsx.t }
8127
+
7861
8128
  type t =
7862
8129
  | Toplevel
7863
- | Dependency of Bsb_package_specs.t
7864
- | Pinned_dependency of Bsb_package_specs.t
8130
+ | Dependency of dep_payload
8131
+ | Pinned_dependency of dep_payload
7865
8132
  (* This package specs comes from the toplevel to
7866
8133
  override the current settings
7867
8134
  *)
@@ -7870,9 +8137,15 @@ let encode_no_nl (x : t) =
7870
8137
  match x with
7871
8138
  | Toplevel -> "0"
7872
8139
  | Dependency x ->
7873
- "1" ^ Bsb_package_specs.package_flag_of_package_specs x ~dirname:"."
8140
+ "1"
8141
+ ^ Bsb_package_specs.package_flag_of_package_specs x.package_specs
8142
+ ~dirname:"."
8143
+ ^ Bsb_jsx.encode_no_nl x.jsx
7874
8144
  | Pinned_dependency x ->
7875
- "2" ^ Bsb_package_specs.package_flag_of_package_specs x ~dirname:"."
8145
+ "2"
8146
+ ^ Bsb_package_specs.package_flag_of_package_specs x.package_specs
8147
+ ~dirname:"."
8148
+ ^ Bsb_jsx.encode_no_nl x.jsx
7876
8149
 
7877
8150
  end
7878
8151
  module Bsc_warnings
@@ -8132,9 +8405,6 @@ type dependencies = dependency list
8132
8405
  type reason_react_jsx = Jsx_v3
8133
8406
  (* string option *)
8134
8407
 
8135
- type jsx_version = Jsx_v3 | Jsx_v4
8136
- type jsx_module = React
8137
- type jsx_mode = Classic | Automatic
8138
8408
  type refmt = string option
8139
8409
  type gentype_config = bool
8140
8410
  type command = string
@@ -8165,9 +8435,7 @@ type t = {
8165
8435
  files_to_install : Bsb_db.module_info Queue.t;
8166
8436
  generate_merlin : bool;
8167
8437
  reason_react_jsx : reason_react_jsx option;
8168
- jsx_version : jsx_version option;
8169
- jsx_module : jsx_module option;
8170
- jsx_mode : jsx_mode option;
8438
+ jsx: Bsb_jsx.t;
8171
8439
  (* whether apply PPX transform or not*)
8172
8440
  generators : command Map_string.t;
8173
8441
  cut_generators : bool;
@@ -10068,6 +10336,9 @@ and parsing_single_source ({ package_kind; is_dev; cwd } as cxt)
10068
10336
  let dir =
10069
10337
  match map.?(Bsb_build_schemas.dir) with
10070
10338
  | Some (Str { str }) ->
10339
+ if str = Literals.library_file then
10340
+ Bsb_exception.config_error x (Printf.sprintf "dir field should be different from `%s`" Literals.library_file)
10341
+ else
10071
10342
  Ext_path.simple_convert_node_path_to_os_path str
10072
10343
  | Some x ->
10073
10344
  Bsb_exception.config_error x "dir expected to be a string"
@@ -10238,7 +10509,7 @@ module Bsb_config_parse : sig
10238
10509
  * along with this program; if not, write to the Free Software
10239
10510
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
10240
10511
 
10241
- val package_specs_from_bsconfig : unit -> Bsb_package_specs.t * Set_string.t
10512
+ val deps_from_bsconfig : unit -> Bsb_package_specs.t * Bsb_jsx.t * Set_string.t
10242
10513
 
10243
10514
  val interpret_json :
10244
10515
  package_kind:Bsb_package_kind.t -> per_proj_dir:string -> Bsb_config_types.t
@@ -10335,8 +10606,7 @@ let check_stdlib (map : json_map) : bool =
10335
10606
  | Some (False _) -> false
10336
10607
  | None | Some _ -> true
10337
10608
 
10338
- let extract_gentype_config (map : json_map) :
10339
- Bsb_config_types.gentype_config =
10609
+ let extract_gentype_config (map : json_map) : Bsb_config_types.gentype_config =
10340
10610
  match map.?(Bsb_build_schemas.gentypeconfig) with
10341
10611
  | None -> false
10342
10612
  | Some (Obj _) -> true
@@ -10391,53 +10661,6 @@ let extract_reason_react_jsx (map : json_map) =
10391
10661
  |> ignore;
10392
10662
  !default
10393
10663
 
10394
- let extract_jsx (map : json_map) =
10395
- let version : Bsb_config_types.jsx_version option ref = ref None in
10396
- let module_ : Bsb_config_types.jsx_module option ref = ref None in
10397
- let mode : Bsb_config_types.jsx_mode option ref = ref None in
10398
- map
10399
- |? ( Bsb_build_schemas.jsx,
10400
- `Obj
10401
- (fun m ->
10402
- match m.?(Bsb_build_schemas.jsx_version) with
10403
- | Some (Flo { loc; flo }) -> (
10404
- match flo with
10405
- | "3" -> version := Some Jsx_v3
10406
- | "4" -> version := Some Jsx_v4
10407
- | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-version %s" flo
10408
- )
10409
- | Some x ->
10410
- Bsb_exception.config_error x
10411
- "Unexpected input (expect a version number) for jsx-version"
10412
- | None -> ()) )
10413
- |? ( Bsb_build_schemas.jsx,
10414
- `Obj
10415
- (fun m ->
10416
- match m.?(Bsb_build_schemas.jsx_module) with
10417
- | Some (Str { loc; str }) -> (
10418
- match str with
10419
- | "react" -> module_ := Some React
10420
- | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-module %s" str)
10421
- | Some x ->
10422
- Bsb_exception.config_error x
10423
- "Unexpected input (jsx module name) for jsx-mode"
10424
- | None -> ()) )
10425
- |? ( Bsb_build_schemas.jsx,
10426
- `Obj
10427
- (fun m ->
10428
- match m.?(Bsb_build_schemas.jsx_mode) with
10429
- | Some (Str { loc; str }) -> (
10430
- match str with
10431
- | "classic" -> mode := Some Classic
10432
- | "automatic" -> mode := Some Automatic
10433
- | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-mode %s" str)
10434
- | Some x ->
10435
- Bsb_exception.config_error x
10436
- "Unexpected input (expect classic or automatic) for jsx-mode"
10437
- | None -> ()) )
10438
- |> ignore;
10439
- (!version, !module_, !mode)
10440
-
10441
10664
  let extract_warning (map : json_map) =
10442
10665
  match map.?(Bsb_build_schemas.warnings) with
10443
10666
  | None -> Bsb_warning.use_default
@@ -10586,7 +10809,6 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
10586
10809
  .path)
10587
10810
  in
10588
10811
  let reason_react_jsx = extract_reason_react_jsx map in
10589
- let jsx_version, jsx_module, jsx_mode = extract_jsx map in
10590
10812
  let bs_dependencies =
10591
10813
  extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dependencies
10592
10814
  in
@@ -10609,6 +10831,17 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
10609
10831
  (* ~namespace *)
10610
10832
  sources
10611
10833
  in
10834
+ let bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags in
10835
+ let jsx = Bsb_jsx.from_map map in
10836
+ let jsx, bsc_flags =
10837
+ match package_kind with
10838
+ | Pinned_dependency x | Dependency x ->
10839
+ if List.mem package_name x.jsx.v3_dependencies then
10840
+ ( { jsx with version = Some Jsx_v3 },
10841
+ "-open ReactV3" :: bsc_flags )
10842
+ else (x.jsx, bsc_flags)
10843
+ | _ -> (jsx, bsc_flags)
10844
+ in
10612
10845
  {
10613
10846
  pinned_dependencies;
10614
10847
  gentype_config;
@@ -10617,7 +10850,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
10617
10850
  warning = extract_warning map;
10618
10851
  external_includes =
10619
10852
  extract_string_list map Bsb_build_schemas.bs_external_includes;
10620
- bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags;
10853
+ bsc_flags;
10621
10854
  ppx_files =
10622
10855
  extract_ppx map ~cwd:per_proj_dir Bsb_build_schemas.ppx_flags;
10623
10856
  pp_file = pp_flags;
@@ -10637,16 +10870,14 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
10637
10870
  package_specs =
10638
10871
  (match package_kind with
10639
10872
  | Toplevel -> Bsb_package_specs.from_map ~cwd:per_proj_dir map
10640
- | Pinned_dependency x | Dependency x -> x);
10873
+ | Pinned_dependency x | Dependency x -> x.package_specs);
10641
10874
  file_groups = groups;
10642
10875
  files_to_install = Queue.create ();
10643
10876
  built_in_dependency = built_in_package;
10644
10877
  generate_merlin =
10645
10878
  extract_boolean map Bsb_build_schemas.generate_merlin false;
10646
10879
  reason_react_jsx;
10647
- jsx_version;
10648
- jsx_module;
10649
- jsx_mode;
10880
+ jsx;
10650
10881
  generators = extract_generators map;
10651
10882
  cut_generators;
10652
10883
  }
@@ -10654,11 +10885,12 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
10654
10885
  Bsb_exception.invalid_spec "no sources specified in bsconfig.json")
10655
10886
  | _ -> Bsb_exception.invalid_spec "bsconfig.json expect a json object {}"
10656
10887
 
10657
- let package_specs_from_bsconfig () =
10888
+ let deps_from_bsconfig () =
10658
10889
  let json = Ext_json_parse.parse_json_from_file Literals.bsconfig_json in
10659
10890
  match json with
10660
10891
  | Obj { map } ->
10661
10892
  ( Bsb_package_specs.from_map ~cwd:Bsb_global_paths.cwd map,
10893
+ Bsb_jsx.from_map map,
10662
10894
  extract_pinned_dependencies map )
10663
10895
  | _ -> assert false
10664
10896
 
@@ -10874,9 +11106,7 @@ let clean_bs_garbage proj_dir =
10874
11106
  Bsb_log.warn "@{<warning>Failed@} to clean due to %s" (Printexc.to_string e)
10875
11107
 
10876
11108
  let clean_bs_deps proj_dir =
10877
- let _, pinned_dependencies =
10878
- Bsb_config_parse.package_specs_from_bsconfig ()
10879
- in
11109
+ let _, _, pinned_dependencies = Bsb_config_parse.deps_from_bsconfig () in
10880
11110
  let queue = Bsb_build_util.walk_all_deps proj_dir ~pinned_dependencies in
10881
11111
  Queue.iter
10882
11112
  (fun (pkg_cxt : Bsb_build_util.package_context) ->
@@ -11573,7 +11803,7 @@ type builtin = {
11573
11803
  (***********************************************************)
11574
11804
 
11575
11805
  (** rules are generally composed of built-in rules and customized rules, there are two design choices:
11576
- 1. respect custom rules with the same name, then we need adjust our built-in
11806
+ 1. respect custom rules with the same name, then we need adjust our built-in
11577
11807
  rules dynamically in case the conflict.
11578
11808
  2. respect our built-in rules, then we only need re-load custom rules for each bsconfig.json
11579
11809
  *)
@@ -11589,12 +11819,10 @@ val make_custom_rules :
11589
11819
  pp_file:string option ->
11590
11820
  has_builtin:bool ->
11591
11821
  reason_react_jsx:Bsb_config_types.reason_react_jsx option ->
11592
- jsx_version:Bsb_config_types.jsx_version option ->
11593
- jsx_module:Bsb_config_types.jsx_module option ->
11594
- jsx_mode:Bsb_config_types.jsx_mode option ->
11822
+ jsx:Bsb_jsx.t ->
11595
11823
  digest:string ->
11596
- refmt:string option ->
11597
11824
  package_specs:Bsb_package_specs.t ->
11825
+ refmt:string option ->
11598
11826
  namespace:string option ->
11599
11827
  package_name:string ->
11600
11828
  warnings:string ->
@@ -11703,10 +11931,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
11703
11931
  ~(has_postbuild : string option) ~(pp_file : string option)
11704
11932
  ~(has_builtin : bool)
11705
11933
  ~(reason_react_jsx : Bsb_config_types.reason_react_jsx option)
11706
- ~(jsx_version : Bsb_config_types.jsx_version option)
11707
- ~(jsx_module : Bsb_config_types.jsx_module option)
11708
- ~(jsx_mode : Bsb_config_types.jsx_mode option) ~(digest : string)
11709
- ~(refmt : string option) ~(package_specs : Bsb_package_specs.t)
11934
+ ~(jsx : Bsb_jsx.t) ~(digest : string) ~(package_specs : Bsb_package_specs.t)
11935
+ ~(refmt : string option)
11710
11936
  ~(namespace : string option) ~package_name ~warnings
11711
11937
  ~(ppx_files : Bsb_config_types.ppx list) ~bsc_flags ~(dpkg_incls : string)
11712
11938
  ~(lib_incls : string) ~(dev_incls : string) ~bs_dependencies
@@ -11779,15 +12005,15 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
11779
12005
  | None -> ()
11780
12006
  | Some flag ->
11781
12007
  Ext_buffer.add_char_string buf ' ' (Bsb_build_util.pp_flag flag));
11782
- (match (reason_react_jsx, jsx_version) with
12008
+ (match (reason_react_jsx, jsx.version) with
11783
12009
  | _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
11784
12010
  | _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
11785
12011
  | Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
11786
12012
  | None, None -> ());
11787
- (match jsx_module with
12013
+ (match jsx.module_ with
11788
12014
  | None -> ()
11789
12015
  | Some React -> Ext_buffer.add_string buf " -bs-jsx-module react");
11790
- (match jsx_mode with
12016
+ (match jsx.mode with
11791
12017
  | None -> ()
11792
12018
  | Some Classic -> Ext_buffer.add_string buf " -bs-jsx-mode classic"
11793
12019
  | Some Automatic -> Ext_buffer.add_string buf " -bs-jsx-mode automatic");
@@ -12398,9 +12624,7 @@ let output_ninja_and_namespace_map ~per_proj_dir ~package_kind
12398
12624
  files_to_install;
12399
12625
  built_in_dependency;
12400
12626
  reason_react_jsx;
12401
- jsx_version;
12402
- jsx_module;
12403
- jsx_mode;
12627
+ jsx;
12404
12628
  generators;
12405
12629
  namespace;
12406
12630
  warning;
@@ -12447,9 +12671,8 @@ let output_ninja_and_namespace_map ~per_proj_dir ~package_kind
12447
12671
  let rules : Bsb_ninja_rule.builtin =
12448
12672
  Bsb_ninja_rule.make_custom_rules ~refmt ~gentype_config
12449
12673
  ~has_postbuild:js_post_build_cmd ~pp_file ~has_builtin:built_in_dependency
12450
- ~reason_react_jsx ~jsx_version ~jsx_module ~jsx_mode ~package_specs
12451
- ~namespace ~digest ~package_name ~warnings ~ppx_files ~bsc_flags
12452
- ~dpkg_incls (* dev dependencies *)
12674
+ ~reason_react_jsx ~jsx ~package_specs ~namespace ~digest ~package_name
12675
+ ~warnings ~ppx_files ~bsc_flags ~dpkg_incls (* dev dependencies *)
12453
12676
  ~lib_incls (* its own libs *)
12454
12677
  ~dev_incls (* its own devs *)
12455
12678
  ~bs_dependencies ~bs_dev_dependencies generators
@@ -15112,20 +15335,20 @@ end = struct
15112
15335
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
15113
15336
 
15114
15337
  let ( // ) = Ext_path.combine
15115
-
15116
15338
  let vendor_ninja = Bsb_global_paths.vendor_ninja
15117
15339
 
15118
15340
  let make_world_deps cwd (config : Bsb_config_types.t option)
15119
15341
  (ninja_args : string array) =
15120
- let deps, pinned_dependencies =
15342
+ let package_specs, jsx, pinned_dependencies =
15121
15343
  match config with
15122
15344
  | None ->
15123
15345
  (* When this running bsb does not read bsconfig.json,
15124
15346
  we will read such json file to know which [package-specs]
15125
15347
  it wants
15126
15348
  *)
15127
- Bsb_config_parse.package_specs_from_bsconfig ()
15128
- | Some config -> (config.package_specs, config.pinned_dependencies)
15349
+ Bsb_config_parse.deps_from_bsconfig ()
15350
+ | Some config ->
15351
+ (config.package_specs, config.jsx, config.pinned_dependencies)
15129
15352
  in
15130
15353
  let args =
15131
15354
  if Ext_array.is_empty ninja_args then [| vendor_ninja |]
@@ -15157,8 +15380,8 @@ let make_world_deps cwd (config : Bsb_config_types.t option)
15157
15380
  let _config : _ option =
15158
15381
  Bsb_ninja_regen.regenerate_ninja
15159
15382
  ~package_kind:
15160
- (if is_pinned then Pinned_dependency deps
15161
- else Dependency deps)
15383
+ (if is_pinned then Pinned_dependency { package_specs; jsx }
15384
+ else Dependency { package_specs; jsx })
15162
15385
  ~per_proj_dir:proj_dir ~forced:false
15163
15386
  in
15164
15387
  let command =